summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKartikaya Gupta <kats@pancake.staktrace.com>2021-04-13 13:20:34 -0400
committerEdward Thomson <ethomson@edwardthomson.com>2021-06-30 08:58:12 -0500
commit99ba19c45d283a8dc38a60b0ab8b27369e31a2c4 (patch)
tree5f99748fd8633d5444ead04f9013a03919cd7643
parent168cc6d02d87c4ff0a0611ce617d423c1ac63109 (diff)
downloadlibgit2-99ba19c45d283a8dc38a60b0ab8b27369e31a2c4.tar.gz
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 #5811.
-rw-r--r--src/diff_tform.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/diff_tform.c b/src/diff_tform.c
index 7de88bd0d..385209213 100644
--- a/src/diff_tform.c
+++ b/src/diff_tform.c
@@ -1038,7 +1038,7 @@ find_best_matches:
memcpy(&src->old_file, &swap, sizeof(src->old_file));
/* if we've just swapped the new element into the correct
- * place, clear the SPLIT flag
+ * place, clear the SPLIT and RENAME_TARGET flags
*/
if (tgt2src[s].idx == t &&
tgt2src[s].similarity >
@@ -1046,7 +1046,7 @@ find_best_matches:
src->status = GIT_DELTA_RENAMED;
src->similarity = tgt2src[s].similarity;
tgt2src[s].similarity = 0;
- src->flags &= ~GIT_DIFF_FLAG__TO_SPLIT;
+ src->flags &= ~(GIT_DIFF_FLAG__TO_SPLIT | GIT_DIFF_FLAG__IS_RENAME_TARGET);
num_rewrites--;
}
/* otherwise, if we just overwrote a source, update mapping */