@matheusbsbs / matheus-bagliano / commits / eab144ac49
Fork 0

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>

Linus Torvalds committed Apr 17, 2006 at 16:59 UTC eab144ac49c18d981261c2d0ba964d6380d9f1da
2 files changed +17 -8
combine-diff.c
+16 -6
@@ -585,6 +585,16 @@ static void reuse_combine_diff(struct sline *sline, unsigned long cnt,
585 sline->p_lno[i] = sline->p_lno[j];
586 }
587
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 +
598 static int show_patch_diff(struct combine_diff_path *elem, int num_parent,
599 int dense, struct rev_info *rev)
600 {
@@ -692,12 +702,7 @@ static int show_patch_diff(struct combine_diff_path *elem, int num_parent,
702
703 if (rev->loginfo)
704 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);
706 printf("index ");
707 for (i = 0; i < num_parent; i++) {
708 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,
733 }
734 putchar('\n');
735 }
736 + dump_quoted_path("--- a/", elem->path);
737 + dump_quoted_path("+++ b/", elem->path);
738 dump_sline(sline, cnt, num_parent);
739 }
740 free(result);
@@ -861,6 +868,9 @@ void diff_tree_combined_merge(const unsigned char *sha1,
868 &diffopts);
869 diffcore_std(&diffopts);
870 paths = intersect_paths(paths, i, num_parent);
871 +
872 + if (diffopts.with_stat && rev->loginfo)
873 + show_log(rev, rev->loginfo, "---\n");
874 diff_flush(&diffopts);
875 }
876
log-tree.c
+1 -2
@@ -1,4 +1,3 @@
1 -
1 #include "cache.h"
2 #include "diff.h"
3 #include "commit.h"
@@ -55,7 +54,7 @@ int log_tree_diff_flush(struct rev_info *opt)
54 }
55
56 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");
58 diff_flush(&opt->diffopt);
59 return 1;
60 }