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
[email protected] 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é <[email protected]>
---
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 <[email protected]>
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 <[email protected]>
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
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html