Skip to content

Commit

Permalink
git-log: put space after commit mark
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Michael J Gruber authored and Junio C Hamano committed Mar 11, 2011
1 parent fe3b59e commit b1b4755
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 3 deletions.
2 changes: 1 addition & 1 deletion git-svn.perl
Original file line number Diff line number Diff line change
Expand Up @@ -5734,7 +5734,7 @@ sub cmd_show_log {
my (@k, $c, $d, $stat);
my $esc_color = qr/(?:\033\[(?:(?:\d+;)*\d*)?m)*/;
while (<$log>) {
if (/^${esc_color}commit -?($::sha1_short)/o) {
if (/^${esc_color}commit (- )?($::sha1_short)/o) {
my $cmt = $1;
if ($c && cmt_showable($c) && $c->{r} != $r_last) {
$r_last = $c->{r};
Expand Down
4 changes: 2 additions & 2 deletions log-tree.c
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,7 @@ void show_log(struct rev_info *opt)
graph_show_commit(opt->graph);

if (!opt->graph)
fputs(get_revision_mark(opt, commit), stdout);
put_revision_mark(opt, commit);
fputs(find_unique_abbrev(commit->object.sha1, abbrev_commit), stdout);
if (opt->print_parents)
show_parents(commit, abbrev_commit);
Expand Down Expand Up @@ -439,7 +439,7 @@ void show_log(struct rev_info *opt)
fputs("commit ", stdout);

if (!opt->graph)
fputs(get_revision_mark(opt, commit), stdout);
put_revision_mark(opt, commit);
fputs(find_unique_abbrev(commit->object.sha1, abbrev_commit),
stdout);
if (opt->print_parents)
Expand Down
9 changes: 9 additions & 0 deletions revision.c
Original file line number Diff line number Diff line change
Expand Up @@ -2302,3 +2302,12 @@ char *get_revision_mark(const struct rev_info *revs, const struct commit *commit
return "+";
return "";
}

void put_revision_mark(const struct rev_info *revs, const struct commit *commit)
{
char *mark = get_revision_mark(revs, commit);
if (!strlen(mark))
return;
fputs(mark, stdout);
putchar(' ');
}
1 change: 1 addition & 0 deletions revision.h
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@ extern int handle_revision_arg(const char *arg, struct rev_info *revs,int flags,
extern int prepare_revision_walk(struct rev_info *revs);
extern struct commit *get_revision(struct rev_info *revs);
extern char *get_revision_mark(const struct rev_info *revs, const struct commit *commit);
extern void put_revision_mark(const struct rev_info *revs, const struct commit *commit);

extern void mark_parents_uninteresting(struct commit *commit);
extern void mark_tree_uninteresting(struct tree *tree);
Expand Down

0 comments on commit b1b4755

Please sign in to comment.