summaryrefslogtreecommitdiff
path: root/diff.c
diff options
context:
space:
mode:
authorPhillip Wood <phillip.wood@dunelm.org.uk>2018-09-04 14:52:58 +0100
committerJunio C Hamano <gitster@pobox.com>2018-09-11 13:40:49 -0700
commitfab01ec52e83df886ca952879e196b8d8bd42013 (patch)
treeaec69101dfd395a83499db0aae1fc2ac905f47a3 /diff.c
parent626c0b5d395196ddabcf9b9a430db385722689d4 (diff)
downloadgit-fab01ec52e83df886ca952879e196b8d8bd42013.tar.gz
diff: fix --color-moved-ws=allow-indentation-change
If there is more than one potential moved block and the longest block is not the first element of the array of potential blocks then the block is cut short. With --color-moved=blocks this can leave moved lines unpainted if the shortened block does not meet the block length requirement. With --color-moved=zebra then in addition to the unpainted lines the moved color can change in the middle of a single block. Fix this by freeing the whitespace delta of the match we're discarding rather than the one we're keeping. Signed-off-by: Phillip Wood <phillip.wood@dunelm.org.uk> Acked-by: Stefan Beller <sbeller@google.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'diff.c')
-rw-r--r--diff.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/diff.c b/diff.c
index 5089c6eb3a..9393993e33 100644
--- a/diff.c
+++ b/diff.c
@@ -955,8 +955,13 @@ static void pmb_advance_or_null_multi_match(struct diff_options *o,
/* Carry the white space delta forward */
pmb[i]->next_line->wsd = pmb[i]->wsd;
pmb[i] = pmb[i]->next_line;
- } else
+ } else {
+ if (pmb[i]->wsd) {
+ free(pmb[i]->wsd->string);
+ FREE_AND_NULL(pmb[i]->wsd);
+ }
pmb[i] = NULL;
+ }
}
}
@@ -977,10 +982,6 @@ static int shrink_potential_moved_blocks(struct moved_entry **pmb,
if (lp < pmb_nr && rp > -1 && lp < rp) {
pmb[lp] = pmb[rp];
- if (pmb[rp]->wsd) {
- free(pmb[rp]->wsd->string);
- FREE_AND_NULL(pmb[rp]->wsd);
- }
pmb[rp] = NULL;
rp--;
lp++;