Skip to content

Commit e8e3034

Browse files
committed
log --graph: denote root commits by o
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.
1 parent b0e5a59 commit e8e3034

9 files changed

+54
-52
lines changed

revision.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4541,7 +4541,9 @@ const char *get_revision_mark(const struct rev_info *revs, const struct commit *
45414541
return "<";
45424542
else
45434543
return ">";
4544-
} else if (revs->graph)
4544+
} else if (!commit->parents && revs->graph)
4545+
return "o";
4546+
else if (revs->graph)
45454547
return "*";
45464548
else if (revs->cherry_mark)
45474549
return "+";

t/t3430-rebase-merges.sh

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ test_expect_success 'create completely different structure' '
9797
|/|
9898
| * B
9999
|/
100-
* A
100+
o A
101101
EOF
102102
103103
head="$(git show-ref --verify -s --abbrev HEAD)" &&
@@ -419,8 +419,8 @@ test_expect_success 'root commits' '
419419
test_cmp_graph HEAD <<-\EOF &&
420420
* Merge the 3rd root
421421
|\
422-
| * third-root
423-
* second-root
422+
| o third-root
423+
o second-root
424424
EOF
425425
426426
: fast forward if possible &&
@@ -455,7 +455,7 @@ test_expect_success 'A root commit can be a cousin, treat it that way' '
455455
test_cmp_graph HEAD^.. <<-\EOF &&
456456
* Merge branch '\''khnum'\'' into asherah
457457
|\
458-
| * yama
458+
| o yama
459459
^ shamkat
460460
EOF
461461
test_tick &&
@@ -596,7 +596,7 @@ test_expect_success '--rebase-merges with message matched with onto label' '
596596
|/|
597597
* | C
598598
|/
599-
* A
599+
o A
600600
EOF
601601
'
602602

t/t4202-log.sh

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -579,7 +579,7 @@ cat > expect <<EOF
579579
* fourth
580580
* third
581581
* second
582-
* initial
582+
o initial
583583
EOF
584584

585585
test_expect_success 'simple log --graph' '
@@ -593,7 +593,7 @@ cat > expect <<EOF
593593
123 * fourth
594594
123 * third
595595
123 * second
596-
123 * initial
596+
123 o initial
597597
EOF
598598

599599
test_expect_success 'simple log --graph --line-prefix="123 "' '
@@ -620,7 +620,7 @@ cat > expect <<\EOF
620620
|/
621621
* third
622622
* second
623-
* initial
623+
o initial
624624
EOF
625625

626626
test_expect_success 'log --graph with merge' '
@@ -639,7 +639,7 @@ cat > expect <<\EOF
639639
| | | |/
640640
| | | * third
641641
| | | * second
642-
| | | * initial
642+
| | | o initial
643643
EOF
644644

645645
test_expect_success 'log --graph --line-prefix="| | | " with merge' '
@@ -658,7 +658,7 @@ cat > expect.colors <<\EOF
658658
<CYAN>|<RESET><CYAN>/<RESET>
659659
* third
660660
* second
661-
* initial
661+
o initial
662662
EOF
663663

664664
test_expect_success 'log --graph with merge with log.graphColors' '
@@ -723,7 +723,7 @@ cat > expect <<\EOF
723723
|
724724
| second
725725
|
726-
* commit tags/side-1~3
726+
o commit tags/side-1~3
727727
Author: A U Thor <[email protected]>
728728
729729
initial
@@ -798,7 +798,7 @@ cat > expect <<\EOF
798798
* / third
799799
|/
800800
* second
801-
* initial
801+
o initial
802802
EOF
803803

804804
test_expect_success 'log --graph with merge' '
@@ -1564,7 +1564,7 @@ cat >expect <<\EOF
15641564
| -one
15651565
| +ichi
15661566
|
1567-
* commit COMMIT_OBJECT_NAME
1567+
o commit COMMIT_OBJECT_NAME
15681568
Author: A U Thor <[email protected]>
15691569
15701570
initial
@@ -1839,7 +1839,7 @@ cat >expect <<\EOF
18391839
*** | -one
18401840
*** | +ichi
18411841
*** |
1842-
*** * commit COMMIT_OBJECT_NAME
1842+
*** o commit COMMIT_OBJECT_NAME
18431843
*** Author: A U Thor <[email protected]>
18441844
***
18451845
*** initial

t/t4205-log-pretty-formats.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -386,7 +386,7 @@ test_expect_success ICONV 'right alignment formatting at the nth column with --g
386386
* $head1 message two
387387
* $head2 message one
388388
* $head3 add bar
389-
* $head4 $(commit_msg)
389+
o $head4 $(commit_msg)
390390
EOF
391391
test_cmp expected actual
392392
'
@@ -408,7 +408,7 @@ test_expect_success ICONV 'right alignment formatting with no padding and with -
408408
* message two
409409
* message one
410410
* add bar
411-
* $(commit_msg)
411+
o $(commit_msg)
412412
EOF
413413
test_cmp expected actual
414414
'

t/t4211-line-log.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -352,7 +352,7 @@ test_expect_success 'show line-log with graph' '
352352
| - return F2;
353353
| + return F2 + 2;
354354
| }
355-
* $root_oid Add func1() and func2() in file.c
355+
o $root_oid Add func1() and func2() in file.c
356356
ZZ
357357
diff --git a/file.c b/file.c
358358
--- /dev/null

t/t4214-log-graph-octopus.sh

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ test_expect_success 'log --graph with tricky octopus merge, no color' '
4848
| |/
4949
* / 1
5050
|/
51-
* initial
51+
o initial
5252
EOF
5353
'
5454

@@ -65,7 +65,7 @@ test_expect_success 'log --graph with tricky octopus merge with colors' '
6565
<RED>|<RESET> <MAGENTA>|<RESET><MAGENTA>/<RESET>
6666
* <MAGENTA>/<RESET> 1
6767
<MAGENTA>|<RESET><MAGENTA>/<RESET>
68-
* initial
68+
o initial
6969
EOF
7070
test_cmp_colored_graph left octopus-merge
7171
'
@@ -84,7 +84,7 @@ test_expect_success 'log --graph with normal octopus merge, no color' '
8484
| |/
8585
* / 1
8686
|/
87-
* initial
87+
o initial
8888
EOF
8989
'
9090

@@ -99,7 +99,7 @@ test_expect_success 'log --graph with normal octopus merge with colors' '
9999
<RED>|<RESET> <BLUE>|<RESET><BLUE>/<RESET>
100100
* <BLUE>/<RESET> 1
101101
<BLUE>|<RESET><BLUE>/<RESET>
102-
* initial
102+
o initial
103103
EOF
104104
test_config log.graphColors red,green,yellow,blue,magenta,cyan &&
105105
test_cmp_colored_graph octopus-merge
@@ -117,7 +117,7 @@ test_expect_success 'log --graph with normal octopus merge and child, no color'
117117
| |/
118118
* / 1
119119
|/
120-
* initial
120+
o initial
121121
EOF
122122
'
123123

@@ -133,7 +133,7 @@ test_expect_success 'log --graph with normal octopus and child merge with colors
133133
<GREEN>|<RESET> <MAGENTA>|<RESET><MAGENTA>/<RESET>
134134
* <MAGENTA>/<RESET> 1
135135
<MAGENTA>|<RESET><MAGENTA>/<RESET>
136-
* initial
136+
o initial
137137
EOF
138138
test_config log.graphColors red,green,yellow,blue,magenta,cyan &&
139139
test_cmp_colored_graph after-merge
@@ -152,7 +152,7 @@ test_expect_success 'log --graph with tricky octopus merge and its child, no col
152152
| |/
153153
* / 1
154154
|/
155-
* initial
155+
o initial
156156
EOF
157157
'
158158

@@ -170,7 +170,7 @@ test_expect_success 'log --graph with tricky octopus merge and its child with co
170170
<RED>|<RESET> <CYAN>|<RESET><CYAN>/<RESET>
171171
* <CYAN>/<RESET> 1
172172
<CYAN>|<RESET><CYAN>/<RESET>
173-
* initial
173+
o initial
174174
EOF
175175
test_cmp_colored_graph left after-merge
176176
'
@@ -191,7 +191,7 @@ test_expect_success 'log --graph with crossover in octopus merge, no color' '
191191
|/|
192192
| * 1
193193
|/
194-
* initial
194+
o initial
195195
EOF
196196
'
197197

@@ -212,7 +212,7 @@ test_expect_success 'log --graph with crossover in octopus merge with colors' '
212212
<MAGENTA>|<RESET><MAGENTA>/<RESET><GREEN>|<RESET>
213213
<MAGENTA>|<RESET> * 1
214214
<MAGENTA>|<RESET><MAGENTA>/<RESET>
215-
* initial
215+
o initial
216216
EOF
217217
test_cmp_colored_graph after-4 octopus-merge
218218
'
@@ -234,7 +234,7 @@ test_expect_success 'log --graph with crossover in octopus merge and its child,
234234
|/|
235235
| * 1
236236
|/
237-
* initial
237+
o initial
238238
EOF
239239
'
240240

@@ -256,7 +256,7 @@ test_expect_success 'log --graph with crossover in octopus merge and its child w
256256
<CYAN>|<RESET><CYAN>/<RESET><YELLOW>|<RESET>
257257
<CYAN>|<RESET> * 1
258258
<CYAN>|<RESET><CYAN>/<RESET>
259-
* initial
259+
o initial
260260
EOF
261261
test_cmp_colored_graph after-4 after-merge
262262
'
@@ -277,7 +277,7 @@ test_expect_success 'log --graph with unrelated commit and octopus tip, no color
277277
|/|
278278
| * 1
279279
|/
280-
* initial
280+
o initial
281281
EOF
282282
'
283283

@@ -298,7 +298,7 @@ test_expect_success 'log --graph with unrelated commit and octopus tip with colo
298298
<RED>|<RESET><RED>/<RESET><GREEN>|<RESET>
299299
<RED>|<RESET> * 1
300300
<RED>|<RESET><RED>/<RESET>
301-
* initial
301+
o initial
302302
EOF
303303
test_cmp_colored_graph after-initial octopus-merge
304304
'
@@ -320,7 +320,7 @@ test_expect_success 'log --graph with unrelated commit and octopus child, no col
320320
|/|
321321
| * 1
322322
|/
323-
* initial
323+
o initial
324324
EOF
325325
'
326326

@@ -342,7 +342,7 @@ test_expect_success 'log --graph with unrelated commit and octopus child with co
342342
<RED>|<RESET><RED>/<RESET><YELLOW>|<RESET>
343343
<RED>|<RESET> * 1
344344
<RED>|<RESET><RED>/<RESET>
345-
* initial
345+
o initial
346346
EOF
347347
test_cmp_colored_graph after-initial after-merge
348348
'

t/t4215-log-skewed-merges.sh

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ test_expect_success 'log --graph with merge fusing with its left and right neigh
3434
| |/
3535
* / B
3636
|/
37-
* A
37+
o A
3838
EOF
3939
'
4040

@@ -68,7 +68,7 @@ test_expect_success 'log --graph with left-skewed merge' '
6868
|/|
6969
| * 0_B
7070
|/
71-
* 0_A
71+
o 0_A
7272
EOF
7373
'
7474

@@ -96,7 +96,7 @@ test_expect_success 'log --graph with nested left-skewed merge' '
9696
|/ /
9797
* / 1_B
9898
|/
99-
* 1_A
99+
o 1_A
100100
EOF
101101
'
102102

@@ -133,7 +133,7 @@ test_expect_success 'log --graph with nested left-skewed merge following normal
133133
|/|
134134
* | 2_B
135135
|/
136-
* 2_A
136+
o 2_A
137137
EOF
138138
'
139139

@@ -166,7 +166,7 @@ test_expect_success 'log --graph with nested right-skewed merge following left-s
166166
| |/
167167
| * 3_B
168168
|/
169-
* 3_A
169+
o 3_A
170170
EOF
171171
'
172172

@@ -198,7 +198,7 @@ test_expect_success 'log --graph with right-skewed merge following a left-skewed
198198
| |/
199199
| * 4_B
200200
|/
201-
* 4_A
201+
o 4_A
202202
EOF
203203
'
204204

@@ -235,7 +235,7 @@ test_expect_success 'log --graph with octopus merge with column joining its penu
235235
|/|
236236
| * 5_B
237237
|/
238-
* 5_A
238+
o 5_A
239239
EOF
240240
'
241241

@@ -277,7 +277,7 @@ test_expect_success 'log --graph with multiple tips' '
277277
|/|
278278
* | 6_B
279279
|/
280-
* 6_A
280+
o 6_A
281281
EOF
282282
'
283283

@@ -303,7 +303,7 @@ test_expect_success 'log --graph with multiple tips and colors' '
303303
<CYAN>|<RESET><CYAN>/<RESET><BLUE>|<RESET>
304304
* <BLUE>|<RESET> 6_B
305305
<BLUE>|<RESET><BLUE>/<RESET>
306-
* 6_A
306+
o 6_A
307307
EOF
308308
lib_test_cmp_colored_graph --date-order --pretty=tformat:%s 6_1 6_3 6_5
309309
'
@@ -366,7 +366,7 @@ test_expect_success 'log --graph with multiple tips' '
366366
|/|
367367
* | 7_B
368368
|/
369-
* 7_A
369+
o 7_A
370370
EOF
371371
'
372372

t/t6012-rev-list-simplify.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,7 @@ test_expect_success 'log --graph --simplify-merges --show-pulls' '
277277
| |/
278278
* / A
279279
|/
280-
* I
280+
o I
281281
EOF
282282
git log --graph --pretty="%s" \
283283
--simplify-merges --show-pulls \

0 commit comments

Comments
 (0)