path: root/combine-diff.c
diff options
authorLinus Torvalds <>2006-04-17 23:59:42 (GMT)
committerJunio C Hamano <>2006-04-18 04:43:15 (GMT)
commiteab144ac49c18d981261c2d0ba964d6380d9f1da (patch)
tree00085821c84825ac7c47d974a9c8e3780282c236 /combine-diff.c
parent9153983310a169a340bd1023dccafd80b70b05bc (diff)
Log message printout cleanups (#2)
Here's a further patch on top of the previous one with cosmetic improvements (no "real" code changes, just trivial updates): - it gets the "---" before a diffstat right, including for the combined merge case. Righ now the logic is that we always use "---" when we have a diffstat, and an empty line otherwise. That's how I visually prefer it, but hey, it can be tweaked later. - I made "diff --cc/combined" add the "---/+++" header lines too. The thing won't be mistaken for a valid diff, since the "@@" lines have too many "@" characters (three or more), but it just makes it visually match a real diff, which at least to me makes a big difference in readability. Without them, it just looks very "wrong". I guess I should have taken the filename from each individual entry (and had one "---" file per parent), but I didn't even bother to try to see how that works, so this was the simple thing. With this, doing a git log --cc --patch-with-stat looks quite readable, I think. The only nagging issue - as far as I'm concerned - is that diffstats for merges are pretty questionable the way they are done now. I suspect it would be better to just have the _first_ diffstat, and always make the merge diffstat be the one for "result against first parent". Signed-off-by: Junio C Hamano <>
Diffstat (limited to 'combine-diff.c')
1 files changed, 16 insertions, 6 deletions
diff --git a/combine-diff.c b/combine-diff.c
index b4fa9c9..aef9006 100644
--- a/combine-diff.c
+++ b/combine-diff.c
@@ -585,6 +585,16 @@ static void reuse_combine_diff(struct sline *sline, unsigned long cnt,
sline->p_lno[i] = sline->p_lno[j];
+static void dump_quoted_path(const char *prefix, const char *path)
+ fputs(prefix, stdout);
+ if (quote_c_style(path, NULL, NULL, 0))
+ quote_c_style(path, NULL, stdout, 0);
+ else
+ printf("%s", path);
+ putchar('\n');
static int show_patch_diff(struct combine_diff_path *elem, int num_parent,
int dense, struct rev_info *rev)
@@ -692,12 +702,7 @@ static int show_patch_diff(struct combine_diff_path *elem, int num_parent,
if (rev->loginfo)
show_log(rev, rev->loginfo, "\n");
- 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_quoted_path(dense ? "diff --cc " : "diff --combined ", elem->path);
printf("index ");
for (i = 0; i < num_parent; i++) {
abb = find_unique_abbrev(elem->parent[i].sha1,
@@ -728,6 +733,8 @@ static int show_patch_diff(struct combine_diff_path *elem, int num_parent,
+ dump_quoted_path("--- a/", elem->path);
+ dump_quoted_path("+++ b/", elem->path);
dump_sline(sline, cnt, num_parent);
@@ -861,6 +868,9 @@ void diff_tree_combined_merge(const unsigned char *sha1,
paths = intersect_paths(paths, i, num_parent);
+ if (diffopts.with_stat && rev->loginfo)
+ show_log(rev, rev->loginfo, "---\n");