Skip to content

Commit 4c462bb

Browse files
committed
diff: Fix bug in git_diff_find_similar.
When a split src gets turned into a rename, it should also lose the IS_RENAME_TARGET flag, so that it doesn't get processed in a subsequent iteration as a rename target. Doing so can cause an assertion failure because it no longer has the SPLIT flag. Fixes libgit2#5811.
1 parent ff78aea commit 4c462bb

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/diff_tform.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1039,15 +1039,15 @@ int git_diff_find_similar(
10391039
memcpy(&src->old_file, &swap, sizeof(src->old_file));
10401040

10411041
/* if we've just swapped the new element into the correct
1042-
* place, clear the SPLIT flag
1042+
* place, clear the SPLIT and RENAME_TARGET flags
10431043
*/
10441044
if (tgt2src[s].idx == t &&
10451045
tgt2src[s].similarity >
10461046
opts.rename_from_rewrite_threshold) {
10471047
src->status = GIT_DELTA_RENAMED;
10481048
src->similarity = tgt2src[s].similarity;
10491049
tgt2src[s].similarity = 0;
1050-
src->flags &= ~GIT_DIFF_FLAG__TO_SPLIT;
1050+
src->flags &= ~(GIT_DIFF_FLAG__TO_SPLIT | GIT_DIFF_FLAG__IS_RENAME_TARGET);
10511051
num_rewrites--;
10521052
}
10531053
/* otherwise, if we just overwrote a source, update mapping */

0 commit comments

Comments
 (0)