Commit 4c462bb6 by Kartikaya Gupta

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.
parent ff78aea6
...@@ -1039,7 +1039,7 @@ find_best_matches: ...@@ -1039,7 +1039,7 @@ find_best_matches:
memcpy(&src->old_file, &swap, sizeof(src->old_file)); memcpy(&src->old_file, &swap, sizeof(src->old_file));
/* if we've just swapped the new element into the correct /* 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 && if (tgt2src[s].idx == t &&
tgt2src[s].similarity > tgt2src[s].similarity >
...@@ -1047,7 +1047,7 @@ find_best_matches: ...@@ -1047,7 +1047,7 @@ find_best_matches:
src->status = GIT_DELTA_RENAMED; src->status = GIT_DELTA_RENAMED;
src->similarity = tgt2src[s].similarity; src->similarity = tgt2src[s].similarity;
tgt2src[s].similarity = 0; 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--; num_rewrites--;
} }
/* otherwise, if we just overwrote a source, update mapping */ /* otherwise, if we just overwrote a source, update mapping */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment