diff options
author | Junio C Hamano <gitster@pobox.com> | 2009-11-15 16:41:29 -0800 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2009-11-15 16:41:29 -0800 |
commit | 002a9ec005cd3d4273e3c6b7dbe7a2fb9e70c1bc (patch) | |
tree | 4cc388911d3a2e414ea48e6b52e489efa792c9ac /diff.c | |
parent | 934c042c9cf09a14762b3fa094f1ba15ec721161 (diff) | |
parent | 76fd28283f7eeea246a06994edd43ab60e59d853 (diff) | |
download | git-002a9ec005cd3d4273e3c6b7dbe7a2fb9e70c1bc.tar.gz git-002a9ec005cd3d4273e3c6b7dbe7a2fb9e70c1bc.tar.xz |
Merge branch 'js/maint-diff-color-words'
* 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.c | 20 |
1 files changed, 12 insertions, 8 deletions
@@ -686,14 +686,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); @@ -773,6 +777,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, @@ -798,9 +804,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); |