[PATCHv3 10/10] git-log: put space after commit mark

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxxxxxxxxxxxx>
---
 git-svn.perl |    2 +-
 log-tree.c   |    4 ++--
 revision.c   |    9 +++++++++
 revision.h   |    1 +
 4 files changed, 13 insertions(+), 3 deletions(-)

diff --git a/git-svn.perl b/git-svn.perl
index 177dd25..a5857c1 100755
--- a/git-svn.perl
+++ b/git-svn.perl
@@ -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};
diff --git a/log-tree.c b/log-tree.c
index 1257040..2a1e3a9 100644
--- a/log-tree.c
+++ b/log-tree.c
@@ -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);
@@ -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)
diff --git a/revision.c b/revision.c
index 4881263..725f9b7 100644
--- a/revision.c
+++ b/revision.c
@@ -2303,3 +2303,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(' ');
+}
diff --git a/revision.h b/revision.h
index d38f135..1c0abf0 100644
--- a/revision.h
+++ b/revision.h
@@ -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);
-- 
1.7.4.1.317.gf445f

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]