Merge branch 'js/maint-diff-color-words' into maint
authorJunio C Hamano <gitster@pobox.com>
Mon, 16 Nov 2009 08:01:56 +0000 (00:01 -0800)
committerJunio C Hamano <gitster@pobox.com>
Mon, 16 Nov 2009 08:01:56 +0000 (00:01 -0800)
* 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

1  2 
diff.c

diff --cc diff.c
index b88c7d11b100ddf3a63b1039f2f18bd6cdc7fe39,8c66e4a0d4e5ab1729f400f7e95c4970952ec202..cc0cb2b31f3f9b4ff00b12ad1d07671c7228749d
--- 1/diff.c
--- 2/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);