From: Junio C Hamano Date: Tue, 22 Jun 2010 16:04:14 +0000 (-0700) Subject: Merge branch 'cc/maint-diff-CC-binary' into maint X-Git-Tag: v1.7.2-rc0~7^2~10 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=3c656899cdfbfdd40987625c4615a8c941d5968a;p=git.git Merge branch 'cc/maint-diff-CC-binary' into maint * cc/maint-diff-CC-binary: diff: fix "git show -C -C" output when renaming a binary file Conflicts: diff.c --- 3c656899cdfbfdd40987625c4615a8c941d5968a diff --cc diff.c index 230c31095,426fd0466..57e1212fb --- a/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: @@@ -2353,8 -2352,8 +2362,7 @@@ } /* 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 { @@@ -2395,16 -2402,6 +2404,17 @@@ 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);