Skip to content

Commit eab144a

Browse files
Linus TorvaldsJunio C Hamano
authored andcommitted
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 <junkio@cox.net>
1 parent 9153983 commit eab144a

File tree

2 files changed

+17
-8
lines changed

2 files changed

+17
-8
lines changed

combine-diff.c

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -585,6 +585,16 @@ static void reuse_combine_diff(struct sline *sline, unsigned long cnt,
585585
sline->p_lno[i] = sline->p_lno[j];
586586
}
587587

588+
static void dump_quoted_path(const char *prefix, const char *path)
589+
{
590+
fputs(prefix, stdout);
591+
if (quote_c_style(path, NULL, NULL, 0))
592+
quote_c_style(path, NULL, stdout, 0);
593+
else
594+
printf("%s", path);
595+
putchar('\n');
596+
}
597+
588598
static int show_patch_diff(struct combine_diff_path *elem, int num_parent,
589599
int dense, struct rev_info *rev)
590600
{
@@ -692,12 +702,7 @@ static int show_patch_diff(struct combine_diff_path *elem, int num_parent,
692702

693703
if (rev->loginfo)
694704
show_log(rev, rev->loginfo, "\n");
695-
printf("diff --%s ", dense ? "cc" : "combined");
696-
if (quote_c_style(elem->path, NULL, NULL, 0))
697-
quote_c_style(elem->path, NULL, stdout, 0);
698-
else
699-
printf("%s", elem->path);
700-
putchar('\n');
705+
dump_quoted_path(dense ? "diff --cc " : "diff --combined ", elem->path);
701706
printf("index ");
702707
for (i = 0; i < num_parent; i++) {
703708
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,
728733
}
729734
putchar('\n');
730735
}
736+
dump_quoted_path("--- a/", elem->path);
737+
dump_quoted_path("+++ b/", elem->path);
731738
dump_sline(sline, cnt, num_parent);
732739
}
733740
free(result);
@@ -861,6 +868,9 @@ void diff_tree_combined_merge(const unsigned char *sha1,
861868
&diffopts);
862869
diffcore_std(&diffopts);
863870
paths = intersect_paths(paths, i, num_parent);
871+
872+
if (diffopts.with_stat && rev->loginfo)
873+
show_log(rev, rev->loginfo, "---\n");
864874
diff_flush(&diffopts);
865875
}
866876

log-tree.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
#include "cache.h"
32
#include "diff.h"
43
#include "commit.h"
@@ -55,7 +54,7 @@ int log_tree_diff_flush(struct rev_info *opt)
5554
}
5655

5756
if (opt->loginfo && !opt->no_commit_id)
58-
show_log(opt, opt->loginfo, "\n");
57+
show_log(opt, opt->loginfo, opt->diffopt.with_stat ? "---\n" : "\n");
5958
diff_flush(&opt->diffopt);
6059
return 1;
6160
}

0 commit comments

Comments
 (0)