graph: smooth appearance of collapsing edges on commit lines
[git] / t / t4215-log-skewed-merges.sh
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         | * |   E
15         |/|\ \
16         | | |/
17         | | * D
18         | * | C
19         | |/
20         * / B
21         |/
22         * A
23         EOF
24
25         git checkout --orphan _p &&
26         test_commit A &&
27         test_commit B &&
28         git checkout -b _q @^ && test_commit C &&
29         git checkout -b _r @^ && test_commit D &&
30         git checkout _p && git merge --no-ff _q _r -m E &&
31         git checkout _r && test_commit F &&
32         git checkout _p && git merge --no-ff _r -m G &&
33         git checkout @^^ && git merge --no-ff _p -m H &&
34
35         git log --graph --pretty=tformat:%s | sed "s/ *$//" >actual &&
36         test_cmp expect actual
37 '
38
39 test_expect_success 'log --graph with left-skewed merge' '
40         cat >expect <<-\EOF &&
41         *-----.   0_H
42         |\ \ \ \
43         | | | | * 0_G
44         | |_|_|/|
45         |/| | | |
46         | | | * |   0_F
47         | |_|/|\ \
48         |/| | | |/
49         | | | | * 0_E
50         | |_|_|/
51         |/| | |
52         | | * | 0_D
53         | | |/
54         | | * 0_C
55         | |/
56         |/|
57         | * 0_B
58         |/
59         * 0_A
60         EOF
61
62         git checkout --orphan 0_p && test_commit 0_A &&
63         git checkout -b 0_q 0_p && test_commit 0_B &&
64         git checkout -b 0_r 0_p &&
65         test_commit 0_C &&
66         test_commit 0_D &&
67         git checkout -b 0_s 0_p && test_commit 0_E &&
68         git checkout -b 0_t 0_p && git merge --no-ff 0_r^ 0_s -m 0_F &&
69         git checkout 0_p && git merge --no-ff 0_s -m 0_G &&
70         git checkout @^ && git merge --no-ff 0_q 0_r 0_t 0_p -m 0_H &&
71
72         git log --graph --pretty=tformat:%s | sed "s/ *$//" >actual &&
73         test_cmp expect actual
74 '
75
76 test_expect_success 'log --graph with nested left-skewed merge' '
77         cat >expect <<-\EOF &&
78         *   1_H
79         |\
80         | *   1_G
81         | |\
82         | | * 1_F
83         | * | 1_E
84         |/| |
85         | * | 1_D
86         * | | 1_C
87         |/ /
88         * / 1_B
89         |/
90         * 1_A
91         EOF
92
93         git checkout --orphan 1_p &&
94         test_commit 1_A &&
95         test_commit 1_B &&
96         test_commit 1_C &&
97         git checkout -b 1_q @^ && test_commit 1_D &&
98         git checkout 1_p && git merge --no-ff 1_q -m 1_E &&
99         git checkout -b 1_r @~3 && test_commit 1_F &&
100         git checkout 1_p && git merge --no-ff 1_r -m 1_G &&
101         git checkout @^^ && git merge --no-ff 1_p -m 1_H &&
102
103         git log --graph --pretty=tformat:%s | sed "s/ *$//" >actual &&
104         test_cmp expect actual
105 '
106
107 test_expect_success 'log --graph with nested left-skewed merge following normal merge' '
108         cat >expect <<-\EOF &&
109         *   2_K
110         |\
111         | *   2_J
112         | |\
113         | | *   2_H
114         | | |\
115         | | * | 2_G
116         | |/| |
117         | | * | 2_F
118         | * | | 2_E
119         | |/ /
120         | * | 2_D
121         * | | 2_C
122         | |/
123         |/|
124         * | 2_B
125         |/
126         * 2_A
127         EOF
128
129         git checkout --orphan 2_p &&
130         test_commit 2_A &&
131         test_commit 2_B &&
132         test_commit 2_C &&
133         git checkout -b 2_q @^^ &&
134         test_commit 2_D &&
135         test_commit 2_E &&
136         git checkout -b 2_r @^ && test_commit 2_F &&
137         git checkout 2_q &&
138         git merge --no-ff 2_r -m 2_G &&
139         git merge --no-ff 2_p^ -m 2_H &&
140         git checkout -b 2_s @^^ && git merge --no-ff 2_q -m 2_J &&
141         git checkout 2_p && git merge --no-ff 2_s -m 2_K &&
142
143         git log --graph --pretty=tformat:%s | sed "s/ *$//" >actual &&
144         test_cmp expect actual
145 '
146
147 test_expect_success 'log --graph with nested right-skewed merge following left-skewed merge' '
148         cat >expect <<-\EOF &&
149         *   3_J
150         |\
151         | *   3_H
152         | |\
153         | | * 3_G
154         | * | 3_F
155         |/| |
156         | * |   3_E
157         | |\ \
158         | | |/
159         | | * 3_D
160         | * | 3_C
161         | |/
162         | * 3_B
163         |/
164         * 3_A
165         EOF
166
167         git checkout --orphan 3_p &&
168         test_commit 3_A &&
169         git checkout -b 3_q &&
170         test_commit 3_B &&
171         test_commit 3_C &&
172         git checkout -b 3_r @^ &&
173         test_commit 3_D &&
174         git checkout 3_q && git merge --no-ff 3_r -m 3_E &&
175         git checkout 3_p && git merge --no-ff 3_q -m 3_F &&
176         git checkout 3_r && test_commit 3_G &&
177         git checkout 3_p && git merge --no-ff 3_r -m 3_H &&
178         git checkout @^^ && git merge --no-ff 3_p -m 3_J &&
179
180         git log --graph --pretty=tformat:%s | sed "s/ *$//" >actual &&
181         test_cmp expect actual
182 '
183
184 test_expect_success 'log --graph with right-skewed merge following a left-skewed one' '
185         cat >expect <<-\EOF &&
186         *   4_H
187         |\
188         | *   4_G
189         | |\
190         | * | 4_F
191         |/| |
192         | * |   4_E
193         | |\ \
194         | | * | 4_D
195         | |/ /
196         |/| |
197         | | * 4_C
198         | |/
199         | * 4_B
200         |/
201         * 4_A
202         EOF
203
204         git checkout --orphan 4_p &&
205         test_commit 4_A &&
206         test_commit 4_B &&
207         test_commit 4_C &&
208         git checkout -b 4_q @^^ && test_commit 4_D &&
209         git checkout -b 4_r 4_p^ && git merge --no-ff 4_q -m 4_E &&
210         git checkout -b 4_s 4_p^^ &&
211         git merge --no-ff 4_r -m 4_F &&
212         git merge --no-ff 4_p -m 4_G &&
213         git checkout @^^ && git merge --no-ff 4_s -m 4_H &&
214
215         git log --graph --date-order --pretty=tformat:%s | sed "s/ *$//" >actual &&
216         test_cmp expect actual
217 '
218
219 test_done