Skip to content

Commit

Permalink
log --graph: denote root commits by o
Browse files Browse the repository at this point in the history
So far, root commits are not distinguished in log output at all. As a
consequence, you cannot tell apart one linearly connected history from
two disconnect linear histories at all.

Change this so that root commits (i.e. those with 0 parents) are denoted
by `o` for "origo/origin" (or, if you like, a small zero). As a first
step, we do this for `log --graph` only.
  • Loading branch information
mjg committed Jun 8, 2024
1 parent 490db4e commit 7bc182d
Show file tree
Hide file tree
Showing 8 changed files with 53 additions and 51 deletions.
4 changes: 3 additions & 1 deletion revision.c
Original file line number Diff line number Diff line change
Expand Up @@ -4466,7 +4466,9 @@ const char *get_revision_mark(const struct rev_info *revs, const struct commit *
return "<";
else
return ">";
} else if (revs->graph)
} else if (!commit->parents && revs->graph)
return "o";
else if (revs->graph)
return "*";
else if (revs->cherry_mark)
return "+";
Expand Down
10 changes: 5 additions & 5 deletions t/t3430-rebase-merges.sh
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ test_expect_success 'create completely different structure' '
|/|
| * B
|/
* A
o A
EOF
'

Expand Down Expand Up @@ -411,8 +411,8 @@ test_expect_success 'root commits' '
test_cmp_graph HEAD <<-\EOF &&
* Merge the 3rd root
|\
| * third-root
* second-root
| o third-root
o second-root
EOF
: fast forward if possible &&
Expand Down Expand Up @@ -447,7 +447,7 @@ test_expect_success 'A root commit can be a cousin, treat it that way' '
test_cmp_graph HEAD^.. <<-\EOF &&
* Merge branch '\''khnum'\'' into asherah
|\
| * yama
| o yama
^ shamkat
EOF
test_tick &&
Expand Down Expand Up @@ -588,7 +588,7 @@ test_expect_success '--rebase-merges with message matched with onto label' '
|/|
* | C
|/
* A
o A
EOF
'

Expand Down
18 changes: 9 additions & 9 deletions t/t4202-log.sh
Original file line number Diff line number Diff line change
Expand Up @@ -567,7 +567,7 @@ cat > expect <<EOF
* fourth
* third
* second
* initial
o initial
EOF

test_expect_success 'simple log --graph' '
Expand All @@ -581,7 +581,7 @@ cat > expect <<EOF
123 * fourth
123 * third
123 * second
123 * initial
123 o initial
EOF

test_expect_success 'simple log --graph --line-prefix="123 "' '
Expand All @@ -608,7 +608,7 @@ cat > expect <<\EOF
|/
* third
* second
* initial
o initial
EOF

test_expect_success 'log --graph with merge' '
Expand All @@ -627,7 +627,7 @@ cat > expect <<\EOF
| | | |/
| | | * third
| | | * second
| | | * initial
| | | o initial
EOF

test_expect_success 'log --graph --line-prefix="| | | " with merge' '
Expand All @@ -646,7 +646,7 @@ cat > expect.colors <<\EOF
<CYAN>|<RESET><CYAN>/<RESET>
* third
* second
* initial
o initial
EOF

test_expect_success 'log --graph with merge with log.graphColors' '
Expand Down Expand Up @@ -711,7 +711,7 @@ cat > expect <<\EOF
|
| second
|
* commit tags/side-1~3
o commit tags/side-1~3
Author: A U Thor <author@example.com>
initial
Expand Down Expand Up @@ -786,7 +786,7 @@ cat > expect <<\EOF
* / third
|/
* second
* initial
o initial
EOF

test_expect_success 'log --graph with merge' '
Expand Down Expand Up @@ -1518,7 +1518,7 @@ cat >expect <<\EOF
| -one
| +ichi
|
* commit COMMIT_OBJECT_NAME
o commit COMMIT_OBJECT_NAME
Author: A U Thor <author@example.com>
initial
Expand Down Expand Up @@ -1793,7 +1793,7 @@ cat >expect <<\EOF
*** | -one
*** | +ichi
*** |
*** * commit COMMIT_OBJECT_NAME
*** o commit COMMIT_OBJECT_NAME
*** Author: A U Thor <author@example.com>
***
*** initial
Expand Down
4 changes: 2 additions & 2 deletions t/t4205-log-pretty-formats.sh
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,7 @@ test_expect_success 'right alignment formatting at the nth column with --graph.
* $head1 message two
* $head2 message one
* $head3 add bar
* $head4 $(commit_msg)
o $head4 $(commit_msg)
EOF
test_cmp expected actual
'
Expand All @@ -407,7 +407,7 @@ test_expect_success 'right alignment formatting with no padding and with --graph
* message two
* message one
* add bar
* $(commit_msg)
o $(commit_msg)
EOF
test_cmp expected actual
'
Expand Down
32 changes: 16 additions & 16 deletions t/t4214-log-graph-octopus.sh
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ test_expect_success 'log --graph with tricky octopus merge, no color' '
| |/
* / 1
|/
* initial
o initial
EOF
'

Expand All @@ -66,7 +66,7 @@ test_expect_success 'log --graph with tricky octopus merge with colors' '
<RED>|<RESET> <MAGENTA>|<RESET><MAGENTA>/<RESET>
* <MAGENTA>/<RESET> 1
<MAGENTA>|<RESET><MAGENTA>/<RESET>
* initial
o initial
EOF
test_cmp_colored_graph left octopus-merge
'
Expand All @@ -85,7 +85,7 @@ test_expect_success 'log --graph with normal octopus merge, no color' '
| |/
* / 1
|/
* initial
o initial
EOF
'

Expand All @@ -100,7 +100,7 @@ test_expect_success 'log --graph with normal octopus merge with colors' '
<RED>|<RESET> <BLUE>|<RESET><BLUE>/<RESET>
* <BLUE>/<RESET> 1
<BLUE>|<RESET><BLUE>/<RESET>
* initial
o initial
EOF
test_config log.graphColors red,green,yellow,blue,magenta,cyan &&
test_cmp_colored_graph octopus-merge
Expand All @@ -118,7 +118,7 @@ test_expect_success 'log --graph with normal octopus merge and child, no color'
| |/
* / 1
|/
* initial
o initial
EOF
'

Expand All @@ -134,7 +134,7 @@ test_expect_success 'log --graph with normal octopus and child merge with colors
<GREEN>|<RESET> <MAGENTA>|<RESET><MAGENTA>/<RESET>
* <MAGENTA>/<RESET> 1
<MAGENTA>|<RESET><MAGENTA>/<RESET>
* initial
o initial
EOF
test_config log.graphColors red,green,yellow,blue,magenta,cyan &&
test_cmp_colored_graph after-merge
Expand All @@ -153,7 +153,7 @@ test_expect_success 'log --graph with tricky octopus merge and its child, no col
| |/
* / 1
|/
* initial
o initial
EOF
'

Expand All @@ -171,7 +171,7 @@ test_expect_success 'log --graph with tricky octopus merge and its child with co
<RED>|<RESET> <CYAN>|<RESET><CYAN>/<RESET>
* <CYAN>/<RESET> 1
<CYAN>|<RESET><CYAN>/<RESET>
* initial
o initial
EOF
test_cmp_colored_graph left after-merge
'
Expand All @@ -192,7 +192,7 @@ test_expect_success 'log --graph with crossover in octopus merge, no color' '
|/|
| * 1
|/
* initial
o initial
EOF
'

Expand All @@ -213,7 +213,7 @@ test_expect_success 'log --graph with crossover in octopus merge with colors' '
<MAGENTA>|<RESET><MAGENTA>/<RESET><GREEN>|<RESET>
<MAGENTA>|<RESET> * 1
<MAGENTA>|<RESET><MAGENTA>/<RESET>
* initial
o initial
EOF
test_cmp_colored_graph after-4 octopus-merge
'
Expand All @@ -235,7 +235,7 @@ test_expect_success 'log --graph with crossover in octopus merge and its child,
|/|
| * 1
|/
* initial
o initial
EOF
'

Expand All @@ -257,7 +257,7 @@ test_expect_success 'log --graph with crossover in octopus merge and its child w
<CYAN>|<RESET><CYAN>/<RESET><YELLOW>|<RESET>
<CYAN>|<RESET> * 1
<CYAN>|<RESET><CYAN>/<RESET>
* initial
o initial
EOF
test_cmp_colored_graph after-4 after-merge
'
Expand All @@ -278,7 +278,7 @@ test_expect_success 'log --graph with unrelated commit and octopus tip, no color
|/|
| * 1
|/
* initial
o initial
EOF
'

Expand All @@ -299,7 +299,7 @@ test_expect_success 'log --graph with unrelated commit and octopus tip with colo
<RED>|<RESET><RED>/<RESET><GREEN>|<RESET>
<RED>|<RESET> * 1
<RED>|<RESET><RED>/<RESET>
* initial
o initial
EOF
test_cmp_colored_graph after-initial octopus-merge
'
Expand All @@ -321,7 +321,7 @@ test_expect_success 'log --graph with unrelated commit and octopus child, no col
|/|
| * 1
|/
* initial
o initial
EOF
'

Expand All @@ -343,7 +343,7 @@ test_expect_success 'log --graph with unrelated commit and octopus child with co
<RED>|<RESET><RED>/<RESET><YELLOW>|<RESET>
<RED>|<RESET> * 1
<RED>|<RESET><RED>/<RESET>
* initial
o initial
EOF
test_cmp_colored_graph after-initial after-merge
'
Expand Down
20 changes: 10 additions & 10 deletions t/t4215-log-skewed-merges.sh
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ test_expect_success 'log --graph with merge fusing with its left and right neigh
| |/
* / B
|/
* A
o A
EOF
'

Expand Down Expand Up @@ -69,7 +69,7 @@ test_expect_success 'log --graph with left-skewed merge' '
|/|
| * 0_B
|/
* 0_A
o 0_A
EOF
'

Expand Down Expand Up @@ -97,7 +97,7 @@ test_expect_success 'log --graph with nested left-skewed merge' '
|/ /
* / 1_B
|/
* 1_A
o 1_A
EOF
'

Expand Down Expand Up @@ -134,7 +134,7 @@ test_expect_success 'log --graph with nested left-skewed merge following normal
|/|
* | 2_B
|/
* 2_A
o 2_A
EOF
'

Expand Down Expand Up @@ -167,7 +167,7 @@ test_expect_success 'log --graph with nested right-skewed merge following left-s
| |/
| * 3_B
|/
* 3_A
o 3_A
EOF
'

Expand Down Expand Up @@ -199,7 +199,7 @@ test_expect_success 'log --graph with right-skewed merge following a left-skewed
| |/
| * 4_B
|/
* 4_A
o 4_A
EOF
'

Expand Down Expand Up @@ -236,7 +236,7 @@ test_expect_success 'log --graph with octopus merge with column joining its penu
|/|
| * 5_B
|/
* 5_A
o 5_A
EOF
'

Expand Down Expand Up @@ -278,7 +278,7 @@ test_expect_success 'log --graph with multiple tips' '
|/|
* | 6_B
|/
* 6_A
o 6_A
EOF
'

Expand All @@ -304,7 +304,7 @@ test_expect_success 'log --graph with multiple tips and colors' '
<CYAN>|<RESET><CYAN>/<RESET><BLUE>|<RESET>
* <BLUE>|<RESET> 6_B
<BLUE>|<RESET><BLUE>/<RESET>
* 6_A
o 6_A
EOF
lib_test_cmp_colored_graph --date-order --pretty=tformat:%s 6_1 6_3 6_5
'
Expand Down Expand Up @@ -367,7 +367,7 @@ test_expect_success 'log --graph with multiple tips' '
|/|
* | 7_B
|/
* 7_A
o 7_A
EOF
'

Expand Down
2 changes: 1 addition & 1 deletion t/t6012-rev-list-simplify.sh
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ test_expect_success 'log --graph --simplify-merges --show-pulls' '
| |/
* / A
|/
* I
o I
EOF
git log --graph --pretty="%s" \
--simplify-merges --show-pulls \
Expand Down
Loading

0 comments on commit 7bc182d

Please sign in to comment.