Sync with 2.38.4
[git.git] / t / t4215-log-skewed-merges.sh
blob28d0779a8c599ee9eab9b0b31afe1a57bb558c28
1 #!/bin/sh
3 test_description='git log --graph of skewed merges'
5 . ./test-lib.sh
6 . "$TEST_DIRECTORY"/lib-log-graph.sh
8 check_graph () {
9 cat >expect &&
10 lib_test_cmp_graph --format=%s "$@"
13 test_expect_success 'log --graph with merge fusing with its left and right neighbors' '
14 git checkout --orphan _p &&
15 test_commit A &&
16 test_commit B &&
17 git checkout -b _q @^ && test_commit C &&
18 git checkout -b _r @^ && test_commit D &&
19 git checkout _p && git merge --no-ff _q _r -m E &&
20 git checkout _r && test_commit F &&
21 git checkout _p && git merge --no-ff _r -m G &&
22 git checkout @^^ && git merge --no-ff _p -m H &&
24 check_graph <<-\EOF
25 * H
27 | * G
28 | |\
29 | | * F
30 | * | E
31 |/|\|
32 | | * D
33 | * | C
34 | |/
35 * / B
37 * A
38 EOF
41 test_expect_success 'log --graph with left-skewed merge' '
42 git checkout --orphan 0_p && test_commit 0_A &&
43 git checkout -b 0_q 0_p && test_commit 0_B &&
44 git checkout -b 0_r 0_p &&
45 test_commit 0_C &&
46 test_commit 0_D &&
47 git checkout -b 0_s 0_p && test_commit 0_E &&
48 git checkout -b 0_t 0_p && git merge --no-ff 0_r^ 0_s -m 0_F &&
49 git checkout 0_p && git merge --no-ff 0_s -m 0_G &&
50 git checkout @^ && git merge --no-ff 0_q 0_r 0_t 0_p -m 0_H &&
52 check_graph <<-\EOF
53 *-----. 0_H
54 |\ \ \ \
55 | | | | * 0_G
56 | |_|_|/|
57 |/| | | |
58 | | | * | 0_F
59 | |_|/|\|
60 |/| | | |
61 | | | | * 0_E
62 | |_|_|/
63 |/| | |
64 | | * | 0_D
65 | | |/
66 | | * 0_C
67 | |/
68 |/|
69 | * 0_B
71 * 0_A
72 EOF
75 test_expect_success 'log --graph with nested left-skewed merge' '
76 git checkout --orphan 1_p &&
77 test_commit 1_A &&
78 test_commit 1_B &&
79 test_commit 1_C &&
80 git checkout -b 1_q @^ && test_commit 1_D &&
81 git checkout 1_p && git merge --no-ff 1_q -m 1_E &&
82 git checkout -b 1_r @~3 && test_commit 1_F &&
83 git checkout 1_p && git merge --no-ff 1_r -m 1_G &&
84 git checkout @^^ && git merge --no-ff 1_p -m 1_H &&
86 check_graph <<-\EOF
87 * 1_H
89 | * 1_G
90 | |\
91 | | * 1_F
92 | * | 1_E
93 |/| |
94 | * | 1_D
95 * | | 1_C
96 |/ /
97 * / 1_B
99 * 1_A
103 test_expect_success 'log --graph with nested left-skewed merge following normal merge' '
104 git checkout --orphan 2_p &&
105 test_commit 2_A &&
106 test_commit 2_B &&
107 test_commit 2_C &&
108 git checkout -b 2_q @^^ &&
109 test_commit 2_D &&
110 test_commit 2_E &&
111 git checkout -b 2_r @^ && test_commit 2_F &&
112 git checkout 2_q &&
113 git merge --no-ff 2_r -m 2_G &&
114 git merge --no-ff 2_p^ -m 2_H &&
115 git checkout -b 2_s @^^ && git merge --no-ff 2_q -m 2_J &&
116 git checkout 2_p && git merge --no-ff 2_s -m 2_K &&
118 check_graph <<-\EOF
119 * 2_K
121 | * 2_J
122 | |\
123 | | * 2_H
124 | | |\
125 | | * | 2_G
126 | |/| |
127 | | * | 2_F
128 | * | | 2_E
129 | |/ /
130 | * | 2_D
131 * | | 2_C
132 | |/
134 * | 2_B
136 * 2_A
140 test_expect_success 'log --graph with nested right-skewed merge following left-skewed merge' '
141 git checkout --orphan 3_p &&
142 test_commit 3_A &&
143 git checkout -b 3_q &&
144 test_commit 3_B &&
145 test_commit 3_C &&
146 git checkout -b 3_r @^ &&
147 test_commit 3_D &&
148 git checkout 3_q && git merge --no-ff 3_r -m 3_E &&
149 git checkout 3_p && git merge --no-ff 3_q -m 3_F &&
150 git checkout 3_r && test_commit 3_G &&
151 git checkout 3_p && git merge --no-ff 3_r -m 3_H &&
152 git checkout @^^ && git merge --no-ff 3_p -m 3_J &&
154 check_graph <<-\EOF
155 * 3_J
157 | * 3_H
158 | |\
159 | | * 3_G
160 | * | 3_F
161 |/| |
162 | * | 3_E
163 | |\|
164 | | * 3_D
165 | * | 3_C
166 | |/
167 | * 3_B
169 * 3_A
173 test_expect_success 'log --graph with right-skewed merge following a left-skewed one' '
174 git checkout --orphan 4_p &&
175 test_commit 4_A &&
176 test_commit 4_B &&
177 test_commit 4_C &&
178 git checkout -b 4_q @^^ && test_commit 4_D &&
179 git checkout -b 4_r 4_p^ && git merge --no-ff 4_q -m 4_E &&
180 git checkout -b 4_s 4_p^^ &&
181 git merge --no-ff 4_r -m 4_F &&
182 git merge --no-ff 4_p -m 4_G &&
183 git checkout @^^ && git merge --no-ff 4_s -m 4_H &&
185 check_graph --date-order <<-\EOF
186 * 4_H
188 | * 4_G
189 | |\
190 | * | 4_F
191 |/| |
192 | * | 4_E
193 | |\ \
194 | | * | 4_D
195 | |/ /
196 |/| |
197 | | * 4_C
198 | |/
199 | * 4_B
201 * 4_A
205 test_expect_success 'log --graph with octopus merge with column joining its penultimate parent' '
206 git checkout --orphan 5_p &&
207 test_commit 5_A &&
208 git branch 5_q &&
209 git branch 5_r &&
210 test_commit 5_B &&
211 git checkout 5_q && test_commit 5_C &&
212 git checkout 5_r && test_commit 5_D &&
213 git checkout 5_p &&
214 git merge --no-ff 5_q 5_r -m 5_E &&
215 git checkout 5_q && test_commit 5_F &&
216 git checkout -b 5_s 5_p^ &&
217 git merge --no-ff 5_p 5_q -m 5_G &&
218 git checkout 5_r &&
219 git merge --no-ff 5_s -m 5_H &&
221 check_graph <<-\EOF
222 * 5_H
224 | *-. 5_G
225 | |\ \
226 | | | * 5_F
227 | | * | 5_E
228 | |/|\ \
229 | |_|/ /
230 |/| | /
231 | | |/
232 * | | 5_D
233 | | * 5_C
234 | |/
236 | * 5_B
238 * 5_A
242 test_expect_success 'log --graph with multiple tips' '
243 git checkout --orphan 6_1 &&
244 test_commit 6_A &&
245 git branch 6_2 &&
246 git branch 6_4 &&
247 test_commit 6_B &&
248 git branch 6_3 &&
249 test_commit 6_C &&
250 git checkout 6_2 && test_commit 6_D &&
251 git checkout 6_3 && test_commit 6_E &&
252 git checkout -b 6_5 6_1 &&
253 git merge --no-ff 6_2 -m 6_F &&
254 git checkout 6_4 && test_commit 6_G &&
255 git checkout 6_3 &&
256 git merge --no-ff 6_4 -m 6_H &&
257 git checkout 6_1 &&
258 git merge --no-ff 6_2 -m 6_I &&
260 check_graph 6_1 6_3 6_5 <<-\EOF
261 * 6_I
263 | | * 6_H
264 | | |\
265 | | | * 6_G
266 | | * | 6_E
267 | | | | * 6_F
268 | |_|_|/|
269 |/| | |/
270 | | |/|
271 | |/| |
272 | * | | 6_D
273 | | |/
274 | |/|
275 * | | 6_C
276 | |/
278 * | 6_B
280 * 6_A
284 test_expect_success 'log --graph with multiple tips and colors' '
285 test_config log.graphColors red,green,yellow,blue,magenta,cyan &&
286 cat >expect.colors <<-\EOF &&
287 * 6_I
288 <RED>|<RESET><GREEN>\<RESET>
289 <RED>|<RESET> <GREEN>|<RESET> * 6_H
290 <RED>|<RESET> <GREEN>|<RESET> <YELLOW>|<RESET><BLUE>\<RESET>
291 <RED>|<RESET> <GREEN>|<RESET> <YELLOW>|<RESET> * 6_G
292 <RED>|<RESET> <GREEN>|<RESET> <YELLOW>|<RESET> <BLUE>|<RESET> * 6_F
293 <RED>|<RESET> <GREEN>|<RESET><RED>_<RESET><YELLOW>|<RESET><RED>_<RESET><BLUE>|<RESET><RED>/<RESET><GREEN>|<RESET>
294 <RED>|<RESET><RED>/<RESET><GREEN>|<RESET> <YELLOW>|<RESET> <BLUE>|<RESET><GREEN>/<RESET>
295 <RED>|<RESET> <GREEN>|<RESET> <YELLOW>|<RESET><GREEN>/<RESET><BLUE>|<RESET>
296 <RED>|<RESET> <GREEN>|<RESET><GREEN>/<RESET><YELLOW>|<RESET> <BLUE>|<RESET>
297 <RED>|<RESET> <GREEN>|<RESET> * <BLUE>|<RESET> 6_E
298 <RED>|<RESET> * <CYAN>|<RESET> <BLUE>|<RESET> 6_D
299 <RED>|<RESET> <BLUE>|<RESET> <CYAN>|<RESET><BLUE>/<RESET>
300 <RED>|<RESET> <BLUE>|<RESET><BLUE>/<RESET><CYAN>|<RESET>
301 * <BLUE>|<RESET> <CYAN>|<RESET> 6_C
302 <CYAN>|<RESET> <BLUE>|<RESET><CYAN>/<RESET>
303 <CYAN>|<RESET><CYAN>/<RESET><BLUE>|<RESET>
304 * <BLUE>|<RESET> 6_B
305 <BLUE>|<RESET><BLUE>/<RESET>
306 * 6_A
308 lib_test_cmp_colored_graph --date-order --pretty=tformat:%s 6_1 6_3 6_5
311 test_expect_success 'log --graph with multiple tips' '
312 git checkout --orphan 7_1 &&
313 test_commit 7_A &&
314 test_commit 7_B &&
315 test_commit 7_C &&
316 git checkout -b 7_2 7_1~2 &&
317 test_commit 7_D &&
318 test_commit 7_E &&
319 git checkout -b 7_3 7_1~1 &&
320 test_commit 7_F &&
321 test_commit 7_G &&
322 git checkout -b 7_4 7_2~1 &&
323 test_commit 7_H &&
324 git checkout -b 7_5 7_1~2 &&
325 test_commit 7_I &&
326 git checkout -b 7_6 7_3~1 &&
327 test_commit 7_J &&
328 git checkout -b M_1 7_1 &&
329 git merge --no-ff 7_2 -m 7_M1 &&
330 git checkout -b M_3 7_3 &&
331 git merge --no-ff 7_4 -m 7_M2 &&
332 git checkout -b M_5 7_5 &&
333 git merge --no-ff 7_6 -m 7_M3 &&
334 git checkout -b M_7 7_1 &&
335 git merge --no-ff 7_2 7_3 -m 7_M4 &&
337 check_graph M_1 M_3 M_5 M_7 <<-\EOF
338 * 7_M1
340 | | * 7_M2
341 | | |\
342 | | | * 7_H
343 | | | | * 7_M3
344 | | | | |\
345 | | | | | * 7_J
346 | | | | * | 7_I
347 | | | | | | * 7_M4
348 | |_|_|_|_|/|\
349 |/| | | | |/ /
350 | | |_|_|/| /
351 | |/| | | |/
352 | | | |_|/|
353 | | |/| | |
354 | | * | | | 7_G
355 | | | |_|/
356 | | |/| |
357 | | * | | 7_F
358 | * | | | 7_E
359 | | |/ /
360 | |/| |
361 | * | | 7_D
362 | | |/
363 | |/|
364 * | | 7_C
365 | |/
367 * | 7_B
369 * 7_A
373 test_done