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

git-log: put space after commit mark

Currently, commit marks (left, right, boundary, cherry) are output right before the commit sha1, which makes it difficult to copy sha1s. Sample output for "git log --oneline --cherry": =049c269 t6007: test rev-list --cherry Change this to = 049c269 t6007: test rev-list --cherry which matches exactly the current output of "git log --graph". Leave "git rev-list" output as is (no space) so that they do not break. Adjust "git-svn" which uses "git log --pretty=raw --boundary". Signed-off-by: Michael J Gruber <git@drmicha.warpmail.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Michael J Gruber committed Mar 10, 2011 at 15:45 UTC b1b47554ae889ca76b66349819c9b95a8be5f646
4 files changed +13 -3
git-svn.perl
+1 -1
@@ -5734,7 +5734,7 @@ sub cmd_show_log {
5734 my (@k, $c, $d, $stat);
5735 my $esc_color = qr/(?:\033\[(?:(?:\d+;)*\d*)?m)*/;
5736 while (<$log>) {
5737 - if (/^${esc_color}commit -?($::sha1_short)/o) {
5737 + if (/^${esc_color}commit (- )?($::sha1_short)/o) {
5738 my $cmt = $1;
5739 if ($c && cmt_showable($c) && $c->{r} != $r_last) {
5740 $r_last = $c->{r};
log-tree.c
+2 -2
@@ -381,7 +381,7 @@ void show_log(struct rev_info *opt)
381 graph_show_commit(opt->graph);
382
383 if (!opt->graph)
384 - fputs(get_revision_mark(opt, commit), stdout);
384 + put_revision_mark(opt, commit);
385 fputs(find_unique_abbrev(commit->object.sha1, abbrev_commit), stdout);
386 if (opt->print_parents)
387 show_parents(commit, abbrev_commit);
@@ -439,7 +439,7 @@ void show_log(struct rev_info *opt)
439 fputs("commit ", stdout);
440
441 if (!opt->graph)
442 - fputs(get_revision_mark(opt, commit), stdout);
442 + put_revision_mark(opt, commit);
443 fputs(find_unique_abbrev(commit->object.sha1, abbrev_commit),
444 stdout);
445 if (opt->print_parents)
revision.c
+9
@@ -2302,3 +2302,12 @@ char *get_revision_mark(const struct rev_info *revs, const struct commit *commit
2302 return "+";
2303 return "";
2304 }
2305 +
2306 +void put_revision_mark(const struct rev_info *revs, const struct commit *commit)
2307 +{
2308 + char *mark = get_revision_mark(revs, commit);
2309 + if (!strlen(mark))
2310 + return;
2311 + fputs(mark, stdout);
2312 + putchar(' ');
2313 +}
revision.h
+1
@@ -168,6 +168,7 @@ extern int handle_revision_arg(const char *arg, struct rev_info *revs,int flags,
168 extern int prepare_revision_walk(struct rev_info *revs);
169 extern struct commit *get_revision(struct rev_info *revs);
170 extern char *get_revision_mark(const struct rev_info *revs, const struct commit *commit);
171 +extern void put_revision_mark(const struct rev_info *revs, const struct commit *commit);
172
173 extern void mark_parents_uninteresting(struct commit *commit);
174 extern void mark_tree_uninteresting(struct tree *tree);