summaryrefslogtreecommitdiff
path: root/diff.c
diff options
context:
space:
mode:
authorLibravatar Junio C Hamano <gitster@pobox.com>2009-11-16 00:01:56 -0800
committerLibravatar Junio C Hamano <gitster@pobox.com>2009-11-16 00:01:56 -0800
commitd404a3e1a5588fa075e4fae6679603a5add2e4df (patch)
tree499295d3bfe889ac42d11a0cd7e7a26fb9d40225 /diff.c
parentMerge branch 'tz/maint-rpm' into maint (diff)
parentdiff --color-words: bit of clean-up (diff)
downloadtgif-d404a3e1a5588fa075e4fae6679603a5add2e4df.tar.xz
Merge branch 'js/maint-diff-color-words' into maint
* js/maint-diff-color-words: diff --color-words: bit of clean-up diff --color-words -U0: fix the location of hunk headers t4034-diff-words: add a test for word diff without context Conflicts: diff.c
Diffstat (limited to 'diff.c')
-rw-r--r--diff.c20
1 files changed, 12 insertions, 8 deletions
diff --git a/diff.c b/diff.c
index b88c7d11b1..cc0cb2b31f 100644
--- a/diff.c
+++ b/diff.c
@@ -685,14 +685,18 @@ static void diff_words_show(struct diff_words_data *diff_words)
diff_words->minus.text.size = diff_words->plus.text.size = 0;
}
+/* In "color-words" mode, show word-diff of words accumulated in the buffer */
+static void diff_words_flush(struct emit_callback *ecbdata)
+{
+ if (ecbdata->diff_words->minus.text.size ||
+ ecbdata->diff_words->plus.text.size)
+ diff_words_show(ecbdata->diff_words);
+}
+
static void free_diff_words_data(struct emit_callback *ecbdata)
{
if (ecbdata->diff_words) {
- /* flush buffers */
- if (ecbdata->diff_words->minus.text.size ||
- ecbdata->diff_words->plus.text.size)
- diff_words_show(ecbdata->diff_words);
-
+ diff_words_flush(ecbdata);
free (ecbdata->diff_words->minus.text.ptr);
free (ecbdata->diff_words->minus.orig);
free (ecbdata->diff_words->plus.text.ptr);
@@ -772,6 +776,8 @@ static void fn_out_consume(void *priv, char *line, unsigned long len)
}
if (line[0] == '@') {
+ if (ecbdata->diff_words)
+ diff_words_flush(ecbdata);
len = sane_truncate_line(ecbdata, line, len);
find_lno(line, ecbdata);
emit_line(ecbdata->file,
@@ -797,9 +803,7 @@ static void fn_out_consume(void *priv, char *line, unsigned long len)
&ecbdata->diff_words->plus);
return;
}
- if (ecbdata->diff_words->minus.text.size ||
- ecbdata->diff_words->plus.text.size)
- diff_words_show(ecbdata->diff_words);
+ diff_words_flush(ecbdata);
line++;
len--;
emit_line(ecbdata->file, plain, reset, line, len);