From: Junio C Hamano Date: Wed, 25 Jan 2006 22:26:22 +0000 (-0800) Subject: diff-tree --cc: squelch header generation on empty patch. X-Git-Tag: v1.2.0~100^3~2 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=8828cdcb445fc420de9e869d359596ceefce76be;p=git.git diff-tree --cc: squelch header generation on empty patch. Earlier round showed the commit log header and "diff --combined" header even for paths that had no interesting hunk under --cc flag. Move the header display logic around to squelch them. With this, a merge that does not have any interesting merges will not be shown with --cc option, unless -m is used at the same time. Signed-off-by: Junio C Hamano --- diff --git a/combine-diff.c b/combine-diff.c index a91cafbd9..3b219a01a 100644 --- a/combine-diff.c +++ b/combine-diff.c @@ -323,12 +323,13 @@ static unsigned long line_all_diff(struct sline *sline, unsigned long all_mask) return different; } -static void make_hunks(struct sline *sline, unsigned long cnt, +static int make_hunks(struct sline *sline, unsigned long cnt, int num_parent, int dense) { unsigned long all_mask = (1UL<parent_sha1[i], ourtmp, sline, cnt, i); - make_hunks(sline, cnt, num_parent, dense); + show_hunks = make_hunks(sline, cnt, num_parent, dense); - dump_sline(sline, cnt, num_parent); + if (header && (show_hunks || show_empty)) { + shown_header++; + puts(header); + } + if (show_hunks) { + printf("diff --%s ", dense ? "cc" : "combined"); + if (quote_c_style(elem->path, NULL, NULL, 0)) + quote_c_style(elem->path, NULL, stdout, 0); + else + printf("%s", elem->path); + putchar('\n'); + dump_sline(sline, cnt, num_parent); + } unlink(ourtmp); free(result); @@ -496,6 +514,7 @@ static void show_combined_diff(struct path_list *elem, int num_parent, } } free(sline); + return shown_header; } int diff_tree_combined_merge(const unsigned char *sha1, @@ -535,17 +554,12 @@ int diff_tree_combined_merge(const unsigned char *sha1, num_paths++; } if (num_paths || show_empty_merge) { - puts(header); for (p = paths; p; p = p->next) { if (!p->len) continue; - printf("diff --%s ", dense ? "cc" : "combined"); - if (quote_c_style(p->path, NULL, NULL, 0)) - quote_c_style(p->path, NULL, stdout, 0); - else - printf("%s", p->path); - putchar('\n'); - show_combined_diff(p, num_parent, dense); + if (show_combined_diff(p, num_parent, dense, header, + show_empty_merge)) + header = NULL; } }