Merge branch 'cc/maint-diff-CC-binary' into maint
authorJunio C Hamano <gitster@pobox.com>
Tue, 22 Jun 2010 16:04:14 +0000 (09:04 -0700)
committerJunio C Hamano <gitster@pobox.com>
Tue, 22 Jun 2010 16:27:07 +0000 (09:27 -0700)
* cc/maint-diff-CC-binary:
  diff: fix "git show -C -C" output when renaming a binary file

Conflicts:
diff.c

1  2 
diff.c

diff --cc diff.c
index 230c310952f0296d195c32fbe18b26b279b3fd54,426fd046652bdfd82ec0ce399446acecb1a5ba49..57e1212fbcc9783d3fdbd248762247d8e0efd886
--- 1/diff.c
--- 2/diff.c
+++ b/diff.c
@@@ -1649,21 -1646,24 +1650,24 @@@ static void builtin_diff(const char *na
        if (lbl[0][0] == '/') {
                /* /dev/null */
                strbuf_addf(&header, "%snew file mode %06o%s\n", set, two->mode, reset);
 -              if (xfrm_msg && xfrm_msg[0])
 -                      strbuf_addf(&header, "%s%s%s\n", set, xfrm_msg, reset);
 +              if (xfrm_msg)
 +                      strbuf_addstr(&header, xfrm_msg);
+               must_show_header = 1;
        }
        else if (lbl[1][0] == '/') {
                strbuf_addf(&header, "%sdeleted file mode %06o%s\n", set, one->mode, reset);
 -              if (xfrm_msg && xfrm_msg[0])
 -                      strbuf_addf(&header, "%s%s%s\n", set, xfrm_msg, reset);
 +              if (xfrm_msg)
 +                      strbuf_addstr(&header, xfrm_msg);
+               must_show_header = 1;
        }
        else {
                if (one->mode != two->mode) {
                        strbuf_addf(&header, "%sold mode %06o%s\n", set, one->mode, reset);
                        strbuf_addf(&header, "%snew mode %06o%s\n", set, two->mode, reset);
+                       must_show_header = 1;
                }
 -              if (xfrm_msg && xfrm_msg[0])
 -                      strbuf_addf(&header, "%s%s%s\n", set, xfrm_msg, reset);
 +              if (xfrm_msg)
 +                      strbuf_addstr(&header, xfrm_msg);
  
                /*
                 * we do not run diff between different kind
@@@ -2320,11 -2323,9 +2327,13 @@@ static void fill_metainfo(struct strbu
                          struct diff_filespec *two,
                          struct diff_options *o,
                          struct diff_filepair *p,
 -                        int *must_show_header)
++                        int *must_show_header,
 +                        int use_color)
  {
 +      const char *set = diff_get_color(use_color, DIFF_METAINFO);
 +      const char *reset = diff_get_color(use_color, DIFF_RESET);
 +
+       *must_show_header = 1;
        strbuf_init(msg, PATH_MAX * 2 + 300);
        switch (p->status) {
        case DIFF_STATUS_COPIED:
                }
                /* fallthru */
        default:
--              /* nothing */
-               ;
+               *must_show_header = 0;
        }
        if (one && two && hashcmp(one->sha1, two->sha1)) {
                int abbrev = DIFF_OPT_TST(o, FULL_INDEX) ? 40 : DEFAULT_ABBREV;
@@@ -2386,7 -2387,13 +2394,8 @@@ static void run_diff_cmd(const char *pg
  {
        const char *xfrm_msg = NULL;
        int complete_rewrite = (p->status == DIFF_STATUS_MODIFIED) && p->score;
+       int must_show_header = 0;
  
 -      if (msg) {
 -              fill_metainfo(msg, name, other, one, two, o, p, &must_show_header);
 -              xfrm_msg = msg->len ? msg->buf : NULL;
 -      }
 -
        if (!DIFF_OPT_TST(o, ALLOW_EXTERNAL))
                pgm = NULL;
        else {
                        pgm = drv->external;
        }
  
 +      if (msg) {
 +              /*
 +               * don't use colors when the header is intended for an
 +               * external diff driver
 +               */
 +              fill_metainfo(msg, name, other, one, two, o, p,
++                            &must_show_header,
 +                            DIFF_OPT_TST(o, COLOR_DIFF) && !pgm);
 +              xfrm_msg = msg->len ? msg->buf : NULL;
 +      }
 +
        if (pgm) {
                run_external_diff(pgm, name, other, one, two, xfrm_msg,
                                  complete_rewrite);