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
a212716f
Commit
a212716f
authored
Mar 03, 2015
by
Edward Thomson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
diff_tform: don't compare empty hashsig_heaps
Don't try to compare two empty hashsig_heaps.
parent
76f03418
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
41 additions
and
0 deletions
+41
-0
src/hashsig.c
+3
-0
tests/diff/rename.c
+38
-0
No files found.
src/hashsig.c
View file @
a212716f
...
...
@@ -314,6 +314,9 @@ static int hashsig_heap_compare(const hashsig_heap *a, const hashsig_heap *b)
assert
(
a
->
cmp
==
b
->
cmp
);
if
(
a
->
size
+
b
->
size
==
0
)
return
0
;
/* hash heaps are sorted - just look for overlap vs total */
for
(
i
=
0
,
j
=
0
;
i
<
a
->
size
&&
j
<
b
->
size
;
)
{
...
...
tests/diff/rename.c
View file @
a212716f
...
...
@@ -1602,3 +1602,41 @@ void test_diff_rename__by_config_doesnt_mess_with_whitespace_settings(void)
git_tree_free
(
tree1
);
git_tree_free
(
tree2
);
}
/* test some variations on empty files */
void
test_diff_rename__empty_files
(
void
)
{
git_index
*
index
;
git_diff
*
diff
=
NULL
;
diff_expects
exp
;
git_diff_options
diffopts
=
GIT_DIFF_OPTIONS_INIT
;
git_diff_find_options
findopts
=
GIT_DIFF_FIND_OPTIONS_INIT
;
diffopts
.
flags
=
GIT_DIFF_INCLUDE_UNTRACKED
;
findopts
.
flags
=
GIT_DIFF_FIND_FOR_UNTRACKED
|
GIT_DIFF_FIND_AND_BREAK_REWRITES
|
GIT_DIFF_FIND_RENAMES_FROM_REWRITES
;
cl_git_pass
(
git_repository_index
(
&
index
,
g_repo
));
cl_git_rewritefile
(
"renames/ikeepsix.txt"
,
""
);
cl_git_pass
(
git_index_add_bypath
(
index
,
"ikeepsix.txt"
));
cl_git_rmfile
(
"renames/ikeepsix.txt"
);
cl_git_rewritefile
(
"renames/ikeepsix2.txt"
,
"
\n\n\n
"
);
cl_git_pass
(
git_diff_index_to_workdir
(
&
diff
,
g_repo
,
index
,
&
diffopts
));
cl_git_pass
(
git_diff_find_similar
(
diff
,
&
findopts
));
memset
(
&
exp
,
0
,
sizeof
(
exp
));
cl_git_pass
(
git_diff_foreach
(
diff
,
diff_file_cb
,
diff_hunk_cb
,
diff_line_cb
,
&
exp
));
cl_assert_equal_i
(
2
,
exp
.
files
);
cl_assert_equal_i
(
1
,
exp
.
file_status
[
GIT_DELTA_DELETED
]);
cl_assert_equal_i
(
1
,
exp
.
file_status
[
GIT_DELTA_UNTRACKED
]);
git_diff_free
(
diff
);
git_index_free
(
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