From: Junio C Hamano Date: Mon, 16 Nov 2009 08:01:56 +0000 (-0800) Subject: Merge branch 'js/maint-diff-color-words' into maint X-Git-Tag: v1.6.5.3~3 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=d404a3e1a5588fa075e4fae6679603a5add2e4df;p=git.git 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 --- d404a3e1a5588fa075e4fae6679603a5add2e4df diff --cc diff.c index b88c7d11b,8c66e4a0d..cc0cb2b31 --- a/diff.c +++ b/diff.c @@@ -685,6 -529,26 +685,14 @@@ static void diff_words_show(struct diff diff_words->minus.text.size = diff_words->plus.text.size = 0; } -typedef unsigned long (*sane_truncate_fn)(char *line, unsigned long len); - -struct emit_callback { - int nparents, color_diff; - unsigned ws_rule; - sane_truncate_fn truncate; - const char **label_path; - struct diff_words_data *diff_words; - int *found_changesp; - FILE *file; -}; - + /* 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) { @@@ -771,9 -654,16 +775,11 @@@ static void fn_out_consume(void *priv, len = 1; } - /* This is not really necessary for now because - * this codepath only deals with two-way diffs. - */ - for (i = 0; i < len && line[i] == '@'; i++) - ; - if (2 <= i && i < len && line[i] == ' ') { + if (line[0] == '@') { + if (ecbdata->diff_words) + diff_words_flush(ecbdata); - ecbdata->nparents = i - 1; len = sane_truncate_line(ecbdata, line, len); + find_lno(line, ecbdata); emit_line(ecbdata->file, diff_get_color(ecbdata->color_diff, DIFF_FRAGINFO), reset, line, len);