Skip to content

Commit 458152c

Browse files
jcoglangitster
authored andcommitted
graph: example of graph output that can be simplified
The commits following this one introduce a series of improvements to the layout of graphs, tidying up a few edge cases, namely: - merge whose first parent fuses with an existing column to the left - merge whose last parent fuses with its immediate neighbor on the right - edges that collapse to the left above and below a commit line This test case exemplifies these cases and provides a motivating example of the kind of history I'm aiming to clear up. The first parent of merge E is the same as the parent of H, so those edges fuse together. * H | | *-. E | |\ \ |/ / / | * B We can "skew" the display of this merge so that it doesn't introduce additional columns that immediately collapse: * H | | * E |/|\ | * B The last parent of E is D, the same as the parent of F which is the edge to the right of the merge. * F | \ *-. \ E |\ \ \ / / / / | / |/ * D The two edges leading to D could be fused sooner: rather than expanding the F edge around the merge and then letting the edges collapse, the F edge could fuse with the E edge in the post-merge line: * F | \ *-. | E |\ \| / / / | * D If this is combined with the "skew" effect above, we get a much cleaner graph display for these edges: * F | * | E /|\| | * D Finally, the edge leading from C to A appears jagged as it passes through the commit line for B: | * | C | |/ * | B |/ * A This can be smoothed out so that such edges are easier to read: | * | C | |/ * / B |/ * A Signed-off-by: James Coglan <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent ee7abb5 commit 458152c

File tree

1 file changed

+43
-0
lines changed

1 file changed

+43
-0
lines changed

t/t4215-log-skewed-merges.sh

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
#!/bin/sh
2+
3+
test_description='git log --graph of skewed merges'
4+
5+
. ./test-lib.sh
6+
7+
test_expect_success 'log --graph with merge fusing with its left and right neighbors' '
8+
cat >expect <<-\EOF &&
9+
* H
10+
|\
11+
| * G
12+
| |\
13+
| | * F
14+
| | |
15+
| | \
16+
| *-. \ E
17+
| |\ \ \
18+
|/ / / /
19+
| | | /
20+
| | |/
21+
| | * D
22+
| * | C
23+
| |/
24+
* | B
25+
|/
26+
* A
27+
EOF
28+
29+
git checkout --orphan _p &&
30+
test_commit A &&
31+
test_commit B &&
32+
git checkout -b _q @^ && test_commit C &&
33+
git checkout -b _r @^ && test_commit D &&
34+
git checkout _p && git merge --no-ff _q _r -m E &&
35+
git checkout _r && test_commit F &&
36+
git checkout _p && git merge --no-ff _r -m G &&
37+
git checkout @^^ && git merge --no-ff _p -m H &&
38+
39+
git log --graph --pretty=tformat:%s | sed "s/ *$//" >actual &&
40+
test_cmp expect actual
41+
'
42+
43+
test_done

0 commit comments

Comments
 (0)