From: Junio C Hamano Date: Mon, 16 Nov 2009 00:41:29 +0000 (-0800) Subject: Merge branch 'js/maint-diff-color-words' X-Git-Tag: v1.6.6-rc0~46 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=002a9ec005cd3d4273e3c6b7dbe7a2fb9e70c1bc;p=git.git 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 --- 002a9ec005cd3d4273e3c6b7dbe7a2fb9e70c1bc diff --cc diff.c index 3ad1f8c31,8c66e4a0d..0d7f5ea4a --- a/diff.c +++ b/diff.c @@@ -686,6 -529,26 +686,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) { @@@ -772,9 -654,16 +776,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);