From 78a5af38ba8e899c480ee53df41e4c0377e5cf9e Mon Sep 17 00:00:00 2001 From: Michael J Gruber Date: Thu, 30 Jun 2022 15:40:46 +0200 Subject: [PATCH] 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. --- revision.c | 4 ++- t/t3430-rebase-merges.sh | 10 +++---- t/t4202-log.sh | 18 ++++++------ t/t4205-log-pretty-formats.sh | 4 +-- t/t4214-log-graph-octopus.sh | 32 +++++++++++----------- t/t4215-log-skewed-merges.sh | 20 +++++++------- t/t6012-rev-list-simplify.sh | 2 +- t/t6016-rev-list-graph-simplify-history.sh | 14 +++++----- 8 files changed, 53 insertions(+), 51 deletions(-) diff --git a/revision.c b/revision.c index b69c1f813311f4..17691f9aedcaa7 100644 --- a/revision.c +++ b/revision.c @@ -4423,7 +4423,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 "+"; diff --git a/t/t3430-rebase-merges.sh b/t/t3430-rebase-merges.sh index d442537d3fba55..8d6d7d45096918 100755 --- a/t/t3430-rebase-merges.sh +++ b/t/t3430-rebase-merges.sh @@ -97,7 +97,7 @@ test_expect_success 'create completely different structure' ' |/| | * B |/ - * A + o A EOF ' @@ -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 && @@ -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 && @@ -588,7 +588,7 @@ test_expect_success '--rebase-merges with message matched with onto label' ' |/| * | C |/ - * A + o A EOF ' diff --git a/t/t4202-log.sh b/t/t4202-log.sh index ddd205f98abf7f..495896e1d484c3 100755 --- a/t/t4202-log.sh +++ b/t/t4202-log.sh @@ -567,7 +567,7 @@ cat > expect < expect < expect <<\EOF |/ * third * second -* initial +o initial EOF test_expect_success 'log --graph with merge' ' @@ -627,7 +627,7 @@ cat > expect <<\EOF | | | |/ | | | * third | | | * second -| | | * initial +| | | o initial EOF test_expect_success 'log --graph --line-prefix="| | | " with merge' ' @@ -646,7 +646,7 @@ cat > expect.colors <<\EOF |/ * third * second -* initial +o initial EOF test_expect_success 'log --graph with merge with log.graphColors' ' @@ -711,7 +711,7 @@ cat > expect <<\EOF | | second | -* commit tags/side-1~3 +o commit tags/side-1~3 Author: A U Thor initial @@ -786,7 +786,7 @@ cat > expect <<\EOF * / third |/ * second -* initial +o initial EOF test_expect_success 'log --graph with merge' ' @@ -1518,7 +1518,7 @@ cat >expect <<\EOF | -one | +ichi | -* commit COMMIT_OBJECT_NAME +o commit COMMIT_OBJECT_NAME Author: A U Thor initial @@ -1793,7 +1793,7 @@ cat >expect <<\EOF *** | -one *** | +ichi *** | -*** * commit COMMIT_OBJECT_NAME +*** o commit COMMIT_OBJECT_NAME *** Author: A U Thor *** *** initial diff --git a/t/t4205-log-pretty-formats.sh b/t/t4205-log-pretty-formats.sh index e3d655e6b8b556..843ae90e164552 100755 --- a/t/t4205-log-pretty-formats.sh +++ b/t/t4205-log-pretty-formats.sh @@ -379,7 +379,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 ' @@ -401,7 +401,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 ' diff --git a/t/t4214-log-graph-octopus.sh b/t/t4214-log-graph-octopus.sh index 79055978690962..06d6924631341a 100755 --- a/t/t4214-log-graph-octopus.sh +++ b/t/t4214-log-graph-octopus.sh @@ -49,7 +49,7 @@ test_expect_success 'log --graph with tricky octopus merge, no color' ' | |/ * / 1 |/ - * initial + o initial EOF ' @@ -66,7 +66,7 @@ test_expect_success 'log --graph with tricky octopus merge with colors' ' | |/ * / 1 |/ - * initial + o initial EOF test_cmp_colored_graph left octopus-merge ' @@ -85,7 +85,7 @@ test_expect_success 'log --graph with normal octopus merge, no color' ' | |/ * / 1 |/ - * initial + o initial EOF ' @@ -100,7 +100,7 @@ test_expect_success 'log --graph with normal octopus merge with colors' ' | |/ * / 1 |/ - * initial + o initial EOF test_config log.graphColors red,green,yellow,blue,magenta,cyan && test_cmp_colored_graph octopus-merge @@ -118,7 +118,7 @@ test_expect_success 'log --graph with normal octopus merge and child, no color' | |/ * / 1 |/ - * initial + o initial EOF ' @@ -134,7 +134,7 @@ test_expect_success 'log --graph with normal octopus and child merge with colors | |/ * / 1 |/ - * initial + o initial EOF test_config log.graphColors red,green,yellow,blue,magenta,cyan && test_cmp_colored_graph after-merge @@ -153,7 +153,7 @@ test_expect_success 'log --graph with tricky octopus merge and its child, no col | |/ * / 1 |/ - * initial + o initial EOF ' @@ -171,7 +171,7 @@ test_expect_success 'log --graph with tricky octopus merge and its child with co | |/ * / 1 |/ - * initial + o initial EOF test_cmp_colored_graph left after-merge ' @@ -192,7 +192,7 @@ test_expect_success 'log --graph with crossover in octopus merge, no color' ' |/| | * 1 |/ - * initial + o initial EOF ' @@ -213,7 +213,7 @@ test_expect_success 'log --graph with crossover in octopus merge with colors' ' |/| | * 1 |/ - * initial + o initial EOF test_cmp_colored_graph after-4 octopus-merge ' @@ -235,7 +235,7 @@ test_expect_success 'log --graph with crossover in octopus merge and its child, |/| | * 1 |/ - * initial + o initial EOF ' @@ -257,7 +257,7 @@ test_expect_success 'log --graph with crossover in octopus merge and its child w |/| | * 1 |/ - * initial + o initial EOF test_cmp_colored_graph after-4 after-merge ' @@ -278,7 +278,7 @@ test_expect_success 'log --graph with unrelated commit and octopus tip, no color |/| | * 1 |/ - * initial + o initial EOF ' @@ -299,7 +299,7 @@ test_expect_success 'log --graph with unrelated commit and octopus tip with colo |/| | * 1 |/ - * initial + o initial EOF test_cmp_colored_graph after-initial octopus-merge ' @@ -321,7 +321,7 @@ test_expect_success 'log --graph with unrelated commit and octopus child, no col |/| | * 1 |/ - * initial + o initial EOF ' @@ -343,7 +343,7 @@ test_expect_success 'log --graph with unrelated commit and octopus child with co |/| | * 1 |/ - * initial + o initial EOF test_cmp_colored_graph after-initial after-merge ' diff --git a/t/t4215-log-skewed-merges.sh b/t/t4215-log-skewed-merges.sh index b877ac723516dc..2ce56880857742 100755 --- a/t/t4215-log-skewed-merges.sh +++ b/t/t4215-log-skewed-merges.sh @@ -35,7 +35,7 @@ test_expect_success 'log --graph with merge fusing with its left and right neigh | |/ * / B |/ - * A + o A EOF ' @@ -69,7 +69,7 @@ test_expect_success 'log --graph with left-skewed merge' ' |/| | * 0_B |/ - * 0_A + o 0_A EOF ' @@ -97,7 +97,7 @@ test_expect_success 'log --graph with nested left-skewed merge' ' |/ / * / 1_B |/ - * 1_A + o 1_A EOF ' @@ -134,7 +134,7 @@ test_expect_success 'log --graph with nested left-skewed merge following normal |/| * | 2_B |/ - * 2_A + o 2_A EOF ' @@ -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 ' @@ -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 ' @@ -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 ' @@ -278,7 +278,7 @@ test_expect_success 'log --graph with multiple tips' ' |/| * | 6_B |/ - * 6_A + o 6_A EOF ' @@ -304,7 +304,7 @@ test_expect_success 'log --graph with multiple tips and colors' ' |/| * | 6_B |/ - * 6_A + o 6_A EOF lib_test_cmp_colored_graph --date-order --pretty=tformat:%s 6_1 6_3 6_5 ' @@ -367,7 +367,7 @@ test_expect_success 'log --graph with multiple tips' ' |/| * | 7_B |/ - * 7_A + o 7_A EOF ' diff --git a/t/t6012-rev-list-simplify.sh b/t/t6012-rev-list-simplify.sh index de1e87f1621d5d..d1c7fca0a8cac7 100755 --- a/t/t6012-rev-list-simplify.sh +++ b/t/t6012-rev-list-simplify.sh @@ -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 \ diff --git a/t/t6016-rev-list-graph-simplify-history.sh b/t/t6016-rev-list-graph-simplify-history.sh index b971b3dc91bcc0..322e6c49d20d01 100755 --- a/t/t6016-rev-list-graph-simplify-history.sh +++ b/t/t6016-rev-list-graph-simplify-history.sh @@ -74,7 +74,7 @@ test_expect_success '--graph --all' ' |/| * | A2 |/ - * A1 + o A1 EOF ' @@ -102,7 +102,7 @@ test_expect_success '--graph --simplify-by-decoration' ' |/| * | A2 |/ - * A1 + o A1 EOF ' @@ -128,7 +128,7 @@ test_expect_success '--graph --simplify-by-decoration prune branch B' ' * | A3 |/ * A2 - * A1 + o A1 EOF ' @@ -143,7 +143,7 @@ test_expect_success '--graph --full-history -- bar.txt' ' |\| * | A3 |/ - * A2 + o A2 EOF ' @@ -156,7 +156,7 @@ test_expect_success '--graph --full-history --simplify-merges -- bar.txt' ' * | A5 * | A3 |/ - * A2 + o A2 EOF ' @@ -167,7 +167,7 @@ test_expect_success '--graph -- bar.txt' ' * A3 | * C4 |/ - * A2 + o A2 EOF ' @@ -184,7 +184,7 @@ test_expect_success '--graph --sparse -- bar.txt' ' | * C1 |/ * A2 - * A1 + o A1 EOF '