diff: simplify allow-indentation-change delta calculation
Now that we reliably end a block when the sign changes we don't need the whitespace delta calculation to rely on the sign. Signed-off-by: Phillip Wood <phillip.wood@dunelm.org.uk> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
committed by
Junio C Hamano
parent
eb89352504
commit
76e32d6193
13
diff.c
13
diff.c
@ -864,23 +864,17 @@ static int compute_ws_delta(const struct emitted_diff_symbol *a,
|
|||||||
a_width = a->indent_width,
|
a_width = a->indent_width,
|
||||||
b_off = b->indent_off,
|
b_off = b->indent_off,
|
||||||
b_width = b->indent_width;
|
b_width = b->indent_width;
|
||||||
int delta;
|
|
||||||
|
|
||||||
if (a_width == INDENT_BLANKLINE && b_width == INDENT_BLANKLINE) {
|
if (a_width == INDENT_BLANKLINE && b_width == INDENT_BLANKLINE) {
|
||||||
*out = INDENT_BLANKLINE;
|
*out = INDENT_BLANKLINE;
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (a->s == DIFF_SYMBOL_PLUS)
|
|
||||||
delta = a_width - b_width;
|
|
||||||
else
|
|
||||||
delta = b_width - a_width;
|
|
||||||
|
|
||||||
if (a_len - a_off != b_len - b_off ||
|
if (a_len - a_off != b_len - b_off ||
|
||||||
memcmp(a->line + a_off, b->line + b_off, a_len - a_off))
|
memcmp(a->line + a_off, b->line + b_off, a_len - a_off))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
*out = delta;
|
*out = a_width - b_width;
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
@ -924,10 +918,7 @@ static int cmp_in_block_with_wsd(const struct diff_options *o,
|
|||||||
* match those of the current block and that the text of 'l' and 'cur'
|
* match those of the current block and that the text of 'l' and 'cur'
|
||||||
* after the indentation match.
|
* after the indentation match.
|
||||||
*/
|
*/
|
||||||
if (cur->es->s == DIFF_SYMBOL_PLUS)
|
delta = c_width - a_width;
|
||||||
delta = a_width - c_width;
|
|
||||||
else
|
|
||||||
delta = c_width - a_width;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* If the previous lines of this block were all blank then set its
|
* If the previous lines of this block were all blank then set its
|
||||||
|
|||||||
Reference in New Issue
Block a user