git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: "Antoine Beaupré" <anarcat@koumbit.org>
To: git@vger.kernel.org
Cc: "Antoine Beaupré" <anarcat@koumbit.org>
Subject: [PATCH] graph.c: visual difference on subsequent series
Date: Mon, 10 Nov 2014 08:33:32 -0500	[thread overview]
Message-ID: <1415626412-573-1-git-send-email-anarcat@koumbit.org> (raw)

For projects with separate history lines and, thus, multiple root-commits, the
linear arrangement of `git log --graph --oneline` does not allow the user to
spot where the sequence ends, giving the impression that it's a contiguous
history. E.g.

History sequence A: a1 -- a2 -- a3 (root-commit)
History sequence B: b1 -- b2 -- b3 (root-commit)

    git log --graph --oneline
    * a1
    * a2
    * a3
    * b1
    * b2
    * b3

In a GUI tool, the root-commit of each series would stand out on the graph.

This modification changes the commit char to a different symbol ('o'), so users
of the command-line graph tool can easily identify root-commits and make sense
of where each series is limited to.

    git log --graph --oneline
    * a1
    * a2
    o a3
    * b1
    * b2
    o b3

The 'o' character was chosen because it is the same character used in rev-list
to mark root commits.

This patch is similar than the one provided by Milton Soares Filho in
1382734287.31768.1.git.send.email.milton.soares.filho@gmail.com but was
implemented independently and uses the 'o' character instead of 'x'.

Other solutions were discarded for those reasons:

 * line delimiters: we want to keep one commit per line
 * tree indentation: it makes little sense with commit trees without
   common history, and is more complicated to implement

Signed-off-by: Antoine Beaupré <anarcat@koumbit.org>
---
 revision.c                                 |  8 ++++++--
 t/t4202-log.sh                             | 10 +++++-----
 t/t6016-rev-list-graph-simplify-history.sh | 14 +++++++-------
 3 files changed, 18 insertions(+), 14 deletions(-)

diff --git a/revision.c b/revision.c
index 75dda92..5f21e24 100644
--- a/revision.c
+++ b/revision.c
@@ -3246,8 +3246,12 @@ char *get_revision_mark(const struct rev_info *revs, const struct commit *commit
 			return "<";
 		else
 			return ">";
-	} else if (revs->graph)
-		return "*";
+	} else if (revs->graph) {
+		if (commit->parents)
+			return "*";
+		else
+			return "o";
+	}
 	else if (revs->cherry_mark)
 		return "+";
 	return "";
diff --git a/t/t4202-log.sh b/t/t4202-log.sh
index 99ab7ca..d11876e 100755
--- a/t/t4202-log.sh
+++ b/t/t4202-log.sh
@@ -244,7 +244,7 @@ cat > expect <<EOF
 * fourth
 * third
 * second
-* initial
+o initial
 EOF
 
 test_expect_success 'simple log --graph' '
@@ -272,7 +272,7 @@ cat > expect <<\EOF
 |/
 * third
 * second
-* initial
+o initial
 EOF
 
 test_expect_success 'log --graph with merge' '
@@ -338,7 +338,7 @@ cat > expect <<\EOF
 |
 |     second
 |
-* commit tags/side-1~3
+o commit tags/side-1~3
   Author: A U Thor <author@example.com>
 
       initial
@@ -410,7 +410,7 @@ cat > expect <<\EOF
 * | third
 |/
 * second
-* initial
+o initial
 EOF
 
 test_expect_success 'log --graph with merge' '
@@ -799,7 +799,7 @@ cat >expect <<\EOF
 | -one
 | +ichi
 |
-* commit COMMIT_OBJECT_NAME
+o commit COMMIT_OBJECT_NAME
   Author: A U Thor <author@example.com>
 
       initial
diff --git a/t/t6016-rev-list-graph-simplify-history.sh b/t/t6016-rev-list-graph-simplify-history.sh
index f7181d1..74b6fc3 100755
--- a/t/t6016-rev-list-graph-simplify-history.sh
+++ b/t/t6016-rev-list-graph-simplify-history.sh
@@ -81,7 +81,7 @@ test_expect_success '--graph --all' '
 	echo "|/|   " >> expected &&
 	echo "* | $A2" >> expected &&
 	echo "|/  " >> expected &&
-	echo "* $A1" >> expected &&
+	echo "o $A1" >> expected &&
 	git rev-list --graph --all > actual &&
 	test_cmp expected actual
 	'
@@ -111,7 +111,7 @@ test_expect_success '--graph --simplify-by-decoration' '
 	echo "|/|   " >> expected &&
 	echo "* | $A2" >> expected &&
 	echo "|/  " >> expected &&
-	echo "* $A1" >> expected &&
+	echo "o $A1" >> expected &&
 	git rev-list --graph --all --simplify-by-decoration > actual &&
 	test_cmp expected actual
 	'
@@ -139,7 +139,7 @@ test_expect_success '--graph --simplify-by-decoration prune branch B' '
 	echo "* | $A3" >> expected &&
 	echo "|/  " >> expected &&
 	echo "* $A2" >> expected &&
-	echo "* $A1" >> expected &&
+	echo "o $A1" >> expected &&
 	git rev-list --graph --simplify-by-decoration --all > actual &&
 	test_cmp expected actual
 	'
@@ -156,7 +156,7 @@ test_expect_success '--graph --full-history -- bar.txt' '
 	echo "| |/  " >> expected &&
 	echo "* | $A3" >> expected &&
 	echo "|/  " >> expected &&
-	echo "* $A2" >> expected &&
+	echo "o $A2" >> expected &&
 	git rev-list --graph --full-history --all -- bar.txt > actual &&
 	test_cmp expected actual
 	'
@@ -170,7 +170,7 @@ test_expect_success '--graph --full-history --simplify-merges -- bar.txt' '
 	echo "* | $A5" >> expected &&
 	echo "* | $A3" >> expected &&
 	echo "|/  " >> expected &&
-	echo "* $A2" >> expected &&
+	echo "o $A2" >> expected &&
 	git rev-list --graph --full-history --simplify-merges --all \
 		-- bar.txt > actual &&
 	test_cmp expected actual
@@ -183,7 +183,7 @@ test_expect_success '--graph -- bar.txt' '
 	echo "* $A3" >> expected &&
 	echo "| * $C4" >> expected &&
 	echo "|/  " >> expected &&
-	echo "* $A2" >> expected &&
+	echo "o $A2" >> expected &&
 	git rev-list --graph --all -- bar.txt > actual &&
 	test_cmp expected actual
 	'
@@ -201,7 +201,7 @@ test_expect_success '--graph --sparse -- bar.txt' '
 	echo "| * $C1" >> expected &&
 	echo "|/  " >> expected &&
 	echo "* $A2" >> expected &&
-	echo "* $A1" >> expected &&
+	echo "o $A1" >> expected &&
 	git rev-list --graph --sparse --all -- bar.txt > actual &&
 	test_cmp expected actual
 	'
-- 
2.1.1

             reply	other threads:[~2014-11-10 13:39 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-11-10 13:33 Antoine Beaupré [this message]
2015-07-27 19:37 ` [PATCH] graph.c: visual difference on subsequent series Antoine Beaupré
2015-07-27 20:17   ` Junio C Hamano
2015-09-03  8:04     ` Michael J Gruber
2015-09-03 17:13       ` Junio C Hamano
2015-09-04 14:07         ` Michael J Gruber
2015-09-04 16:08           ` Junio C Hamano
  -- strict thread matches above, loose matches on Subject: below --
2013-10-25 20:51 Milton Soares Filho
2013-10-25 16:07 Milton Soares Filho
2013-10-25 17:13 ` Junio C Hamano
2013-10-25 20:49   ` Milton Soares Filho
2013-10-26  2:37     ` Keshav Kini
2013-10-28 15:41       ` Junio C Hamano
2013-10-28 16:59         ` Keshav Kini
2013-10-28 17:18         ` Milton Soares Filho
2013-10-28 17:39           ` Junio C Hamano

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1415626412-573-1-git-send-email-anarcat@koumbit.org \
    --to=anarcat@koumbit.org \
    --cc=git@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).