Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
git2
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
lvzhengyang
git2
Commits
a42c2a8c
Commit
a42c2a8c
authored
Jul 31, 2013
by
Edward Thomson
Committed by
Russell Belfer
Aug 04, 2013
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Rename test for multiple similar matches
A rename test that illustrates a source matching multiple targets.
parent
d730d3f4
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
63 additions
and
3 deletions
+63
-3
tests-clar/diff/rename.c
+63
-3
No files found.
tests-clar/diff/rename.c
View file @
a42c2a8c
...
...
@@ -871,6 +871,8 @@ void test_diff_rename__from_deleted_to_split(void)
struct
rename_expected
{
size_t
len
;
unsigned
int
*
status
;
const
char
**
sources
;
const
char
**
targets
;
...
...
@@ -885,7 +887,7 @@ int test_names_expected(const git_diff_delta *delta, float progress, void *p)
cl_assert
(
expected
->
idx
<
expected
->
len
);
cl_assert_equal_i
(
delta
->
status
,
GIT_DELTA_RENAMED
);
cl_assert_equal_i
(
delta
->
status
,
expected
->
status
[
expected
->
idx
]
);
cl_assert
(
git__strcmp
(
expected
->
sources
[
expected
->
idx
],
delta
->
old_file
.
path
)
==
0
);
...
...
@@ -907,9 +909,10 @@ void test_diff_rename__rejected_match_can_match_others(void)
git_diff_options
diffopts
=
GIT_DIFF_OPTIONS_INIT
;
git_diff_find_options
findopts
=
GIT_DIFF_FIND_OPTIONS_INIT
;
git_buf
one
=
GIT_BUF_INIT
,
two
=
GIT_BUF_INIT
;
unsigned
int
status
[]
=
{
GIT_DELTA_RENAMED
,
GIT_DELTA_RENAMED
};
const
char
*
sources
[]
=
{
"Class1.cs"
,
"Class2.cs"
};
const
char
*
targets
[]
=
{
"ClassA.cs"
,
"ClassB.cs"
};
struct
rename_expected
expect
=
{
2
,
sources
,
targets
};
struct
rename_expected
expect
=
{
2
,
s
tatus
,
s
ources
,
targets
};
char
*
ptr
;
opts
.
checkout_strategy
=
GIT_CHECKOUT_FORCE
;
...
...
@@ -991,9 +994,10 @@ void test_diff_rename__rejected_match_can_match_others_two(void)
git_diff_list
*
diff
;
git_diff_options
diffopts
=
GIT_DIFF_OPTIONS_INIT
;
git_diff_find_options
findopts
=
GIT_DIFF_FIND_OPTIONS_INIT
;
unsigned
int
status
[]
=
{
GIT_DELTA_RENAMED
,
GIT_DELTA_RENAMED
};
const
char
*
sources
[]
=
{
"a.txt"
,
"b.txt"
};
const
char
*
targets
[]
=
{
"c.txt"
,
"d.txt"
};
struct
rename_expected
expect
=
{
2
,
sources
,
targets
};
struct
rename_expected
expect
=
{
2
,
s
tatus
,
s
ources
,
targets
};
opts
.
checkout_strategy
=
GIT_CHECKOUT_FORCE
;
...
...
@@ -1036,6 +1040,62 @@ void test_diff_rename__rejected_match_can_match_others_two(void)
git_reference_free
(
selfsimilar
);
}
void
test_diff_rename__rejected_match_can_match_others_three
(
void
)
{
git_reference
*
head
,
*
selfsimilar
;
git_index
*
index
;
git_tree
*
tree
;
git_checkout_opts
opts
=
GIT_CHECKOUT_OPTS_INIT
;
git_diff_list
*
diff
;
git_diff_options
diffopts
=
GIT_DIFF_OPTIONS_INIT
;
git_diff_find_options
findopts
=
GIT_DIFF_FIND_OPTIONS_INIT
;
/* Both cannot be renames from a.txt */
unsigned
int
status
[]
=
{
GIT_DELTA_ADDED
,
GIT_DELTA_RENAMED
};
const
char
*
sources
[]
=
{
"0001.txt"
,
"a.txt"
};
const
char
*
targets
[]
=
{
"0001.txt"
,
"0002.txt"
};
struct
rename_expected
expect
=
{
2
,
status
,
sources
,
targets
};
opts
.
checkout_strategy
=
GIT_CHECKOUT_FORCE
;
cl_git_pass
(
git_reference_lookup
(
&
head
,
g_repo
,
"HEAD"
));
cl_git_pass
(
git_reference_symbolic_set_target
(
&
selfsimilar
,
head
,
"refs/heads/renames_similar_two"
));
cl_git_pass
(
git_checkout_head
(
g_repo
,
&
opts
));
cl_git_pass
(
git_repository_index
(
&
index
,
g_repo
));
cl_git_pass
(
p_unlink
(
"renames/a.txt"
));
cl_git_pass
(
git_index_remove_bypath
(
index
,
"a.txt"
));
write_similarity_file_two
(
"renames/0001.txt"
,
7
);
write_similarity_file_two
(
"renames/0002.txt"
,
0
);
cl_git_pass
(
git_index_add_bypath
(
index
,
"0001.txt"
));
cl_git_pass
(
git_index_add_bypath
(
index
,
"0002.txt"
));
cl_git_pass
(
git_index_write
(
index
));
cl_git_pass
(
git_revparse_single
((
git_object
**
)
&
tree
,
g_repo
,
"HEAD^{tree}"
));
cl_git_pass
(
git_diff_tree_to_index
(
&
diff
,
g_repo
,
tree
,
index
,
&
diffopts
));
cl_git_pass
(
git_diff_find_similar
(
diff
,
&
findopts
));
cl_git_pass
(
git_diff_foreach
(
diff
,
test_names_expected
,
NULL
,
NULL
,
&
expect
));
cl_assert
(
expect
.
idx
==
expect
.
len
);
git_diff_list_free
(
diff
);
git_tree_free
(
tree
);
git_index_free
(
index
);
git_reference_free
(
head
);
git_reference_free
(
selfsimilar
);
}
void
test_diff_rename__case_changes_are_split
(
void
)
{
git_index
*
index
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment