Skip to content

Commit 76e32d6

Browse files
phillipwoodgitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent eb89352 commit 76e32d6

File tree

1 file changed

+2
-11
lines changed

1 file changed

+2
-11
lines changed

diff.c

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -864,23 +864,17 @@ static int compute_ws_delta(const struct emitted_diff_symbol *a,
864864
a_width = a->indent_width,
865865
b_off = b->indent_off,
866866
b_width = b->indent_width;
867-
int delta;
868867

869868
if (a_width == INDENT_BLANKLINE && b_width == INDENT_BLANKLINE) {
870869
*out = INDENT_BLANKLINE;
871870
return 1;
872871
}
873872

874-
if (a->s == DIFF_SYMBOL_PLUS)
875-
delta = a_width - b_width;
876-
else
877-
delta = b_width - a_width;
878-
879873
if (a_len - a_off != b_len - b_off ||
880874
memcmp(a->line + a_off, b->line + b_off, a_len - a_off))
881875
return 0;
882876

883-
*out = delta;
877+
*out = a_width - b_width;
884878

885879
return 1;
886880
}
@@ -924,10 +918,7 @@ static int cmp_in_block_with_wsd(const struct diff_options *o,
924918
* match those of the current block and that the text of 'l' and 'cur'
925919
* after the indentation match.
926920
*/
927-
if (cur->es->s == DIFF_SYMBOL_PLUS)
928-
delta = a_width - c_width;
929-
else
930-
delta = c_width - a_width;
921+
delta = c_width - a_width;
931922

932923
/*
933924
* If the previous lines of this block were all blank then set its

0 commit comments

Comments
 (0)