diff --color-moved: clear all flags on blocks that are too short

If a block of potentially moved lines is not long enough then the DIFF_SYMBOL_MOVED_LINE flag is cleared on the matching lines so they are not marked as moved. To avoid problems when we start rewinding after an unsuccessful match in a couple of commits time make sure all the move related flags are cleared, not just DIFF_SYMBOL_MOVED_LINE. Signed-off-by: Phillip Wood <phillip.wood@dunelm.org.uk> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Phillip Wood committed Dec 9, 2021 at 10:29 UTC bea084ba41ffcaf5896522e48d67682b6a45b04c
1 file changed +3 -3
diff.c
+3 -3
@@ -1114,6 +1114,8 @@ static int shrink_potential_moved_blocks(struct moved_block *pmb,
1114 * NEEDSWORK: This uses the same heuristic as blame_entry_score() in blame.c.
1115 * Think of a way to unify them.
1116 */
1117 +#define DIFF_SYMBOL_MOVED_LINE_ZEBRA_MASK \
1118 + (DIFF_SYMBOL_MOVED_LINE | DIFF_SYMBOL_MOVED_LINE_ALT)
1119 static int adjust_last_block(struct diff_options *o, int n, int block_length)
1120 {
1121 int i, alnum_count = 0;
@@ -1130,7 +1132,7 @@ static int adjust_last_block(struct diff_options *o, int n, int block_length)
1132 }
1133 }
1134 for (i = 1; i < block_length + 1; i++)
1133 - o->emitted_symbols->buf[n - i].flags &= ~DIFF_SYMBOL_MOVED_LINE;
1135 + o->emitted_symbols->buf[n - i].flags &= ~DIFF_SYMBOL_MOVED_LINE_ZEBRA_MASK;
1136 return 0;
1137 }
1138
@@ -1237,8 +1239,6 @@ static void mark_color_as_moved(struct diff_options *o,
1239 free(pmb);
1240 }
1241
1240 -#define DIFF_SYMBOL_MOVED_LINE_ZEBRA_MASK \
1241 - (DIFF_SYMBOL_MOVED_LINE | DIFF_SYMBOL_MOVED_LINE_ALT)
1242 static void dim_moved_lines(struct diff_options *o)
1243 {
1244 int n;