Skip to content

Commit

Permalink
diff --color-words -U0: fix the location of hunk headers
Browse files Browse the repository at this point in the history
Colored word diff without context lines firstly printed all the hunk
headers among each other and then printed the diff.

This was due to the code relying on getting at least one context line at
the end of each hunk, where the colored words would be flushed (it is
done that way to be able to ignore rewrapped lines).

Noticed by Markus Heidelberg.

Signed-off-by: Johannes Schindelin <[email protected]>
Signed-off-by: Junio C Hamano <[email protected]>
  • Loading branch information
dscho authored and gitster committed Oct 30, 2009
1 parent 168eff3 commit a4ca146
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
6 changes: 6 additions & 0 deletions diff.c
Original file line number Diff line number Diff line change
Expand Up @@ -656,6 +656,12 @@ static void fn_out_consume(void *priv, char *line, unsigned long len)
for (i = 0; i < len && line[i] == '@'; i++)
;
if (2 <= i && i < len && line[i] == ' ') {
/* flush --color-words even for --unified=0 */
if (ecbdata->diff_words &&
(ecbdata->diff_words->minus.text.size ||
ecbdata->diff_words->plus.text.size))
diff_words_show(ecbdata->diff_words);

ecbdata->nparents = i - 1;
len = sane_truncate_line(ecbdata, line, len);
emit_line(ecbdata->file,
Expand Down
2 changes: 1 addition & 1 deletion t/t4034-diff-words.sh
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ cat > expect <<\EOF
<GREEN>aeff = aeff * ( aaa )<RESET>
EOF

test_expect_failure 'word diff without context' '
test_expect_success 'word diff without context' '
word_diff --color-words --unified=0
Expand Down

0 comments on commit a4ca146

Please sign in to comment.