Raw
1 #!/bin/sh
2
3 test_description='git log --graph of skewed merges'
4
5 . ./test-lib.sh
6 . "$TEST_DIRECTORY"/lib-log-graph.sh
7
8 test_expect_success 'log --graph with merge fusing with its left and right neighbors' '
9 git checkout --orphan _p &&
10 test_commit A &&
11 test_commit B &&
12 git checkout -b _q @^ && test_commit C &&
13 git checkout -b _r @^ && test_commit D &&
14 git checkout _p && git merge --no-ff _q _r -m E &&
15 git checkout _r && test_commit F &&
16 git checkout _p && git merge --no-ff _r -m G &&
17 git checkout @^^ && git merge --no-ff _p -m H &&
18
19 lib_test_check_graph <<-\EOF
20 * H
21 |\
22 | * G
23 | |\
24 | | * F
25 | * | E
26 |/|\|
27 | | * D
28 | * | C
29 | |/
30 * / B
31 |/
32 * A
33 EOF
34 '
35
36 test_expect_success 'log --graph with left-skewed merge' '
37 git checkout --orphan 0_p && test_commit 0_A &&
38 git checkout -b 0_q 0_p && test_commit 0_B &&
39 git checkout -b 0_r 0_p &&
40 test_commit 0_C &&
41 test_commit 0_D &&
42 git checkout -b 0_s 0_p && test_commit 0_E &&
43 git checkout -b 0_t 0_p && git merge --no-ff 0_r^ 0_s -m 0_F &&
44 git checkout 0_p && git merge --no-ff 0_s -m 0_G &&
45 git checkout @^ && git merge --no-ff 0_q 0_r 0_t 0_p -m 0_H &&
46
47 lib_test_check_graph <<-\EOF
48 *-----. 0_H
49 |\ \ \ \
50 | | | | * 0_G
51 | |_|_|/|
52 |/| | | |
53 | | | * | 0_F
54 | |_|/|\|
55 |/| | | |
56 | | | | * 0_E
57 | |_|_|/
58 |/| | |
59 | | * | 0_D
60 | | |/
61 | | * 0_C
62 | |/
63 |/|
64 | * 0_B
65 |/
66 * 0_A
67 EOF
68 '
69
70 test_expect_success 'log --graph with nested left-skewed merge' '
71 git checkout --orphan 1_p &&
72 test_commit 1_A &&
73 test_commit 1_B &&
74 test_commit 1_C &&
75 git checkout -b 1_q @^ && test_commit 1_D &&
76 git checkout 1_p && git merge --no-ff 1_q -m 1_E &&
77 git checkout -b 1_r @~3 && test_commit 1_F &&
78 git checkout 1_p && git merge --no-ff 1_r -m 1_G &&
79 git checkout @^^ && git merge --no-ff 1_p -m 1_H &&
80
81 lib_test_check_graph <<-\EOF
82 * 1_H
83 |\
84 | * 1_G
85 | |\
86 | | * 1_F
87 | * | 1_E
88 |/| |
89 | * | 1_D
90 * | | 1_C
91 |/ /
92 * / 1_B
93 |/
94 * 1_A
95 EOF
96 '
97
98 test_expect_success 'log --graph with nested left-skewed merge following normal merge' '
99 git checkout --orphan 2_p &&
100 test_commit 2_A &&
101 test_commit 2_B &&
102 test_commit 2_C &&
103 git checkout -b 2_q @^^ &&
104 test_commit 2_D &&
105 test_commit 2_E &&
106 git checkout -b 2_r @^ && test_commit 2_F &&
107 git checkout 2_q &&
108 git merge --no-ff 2_r -m 2_G &&
109 git merge --no-ff 2_p^ -m 2_H &&
110 git checkout -b 2_s @^^ && git merge --no-ff 2_q -m 2_J &&
111 git checkout 2_p && git merge --no-ff 2_s -m 2_K &&
112
113 lib_test_check_graph <<-\EOF
114 * 2_K
115 |\
116 | * 2_J
117 | |\
118 | | * 2_H
119 | | |\
120 | | * | 2_G
121 | |/| |
122 | | * | 2_F
123 | * | | 2_E
124 | |/ /
125 | * | 2_D
126 * | | 2_C
127 | |/
128 |/|
129 * | 2_B
130 |/
131 * 2_A
132 EOF
133 '
134
135 test_expect_success 'log --graph with nested right-skewed merge following left-skewed merge' '
136 git checkout --orphan 3_p &&
137 test_commit 3_A &&
138 git checkout -b 3_q &&
139 test_commit 3_B &&
140 test_commit 3_C &&
141 git checkout -b 3_r @^ &&
142 test_commit 3_D &&
143 git checkout 3_q && git merge --no-ff 3_r -m 3_E &&
144 git checkout 3_p && git merge --no-ff 3_q -m 3_F &&
145 git checkout 3_r && test_commit 3_G &&
146 git checkout 3_p && git merge --no-ff 3_r -m 3_H &&
147 git checkout @^^ && git merge --no-ff 3_p -m 3_J &&
148
149 lib_test_check_graph <<-\EOF
150 * 3_J
151 |\
152 | * 3_H
153 | |\
154 | | * 3_G
155 | * | 3_F
156 |/| |
157 | * | 3_E
158 | |\|
159 | | * 3_D
160 | * | 3_C
161 | |/
162 | * 3_B
163 |/
164 * 3_A
165 EOF
166 '
167
168 test_expect_success 'log --graph with right-skewed merge following a left-skewed one' '
169 git checkout --orphan 4_p &&
170 test_commit 4_A &&
171 test_commit 4_B &&
172 test_commit 4_C &&
173 git checkout -b 4_q @^^ && test_commit 4_D &&
174 git checkout -b 4_r 4_p^ && git merge --no-ff 4_q -m 4_E &&
175 git checkout -b 4_s 4_p^^ &&
176 git merge --no-ff 4_r -m 4_F &&
177 git merge --no-ff 4_p -m 4_G &&
178 git checkout @^^ && git merge --no-ff 4_s -m 4_H &&
179
180 lib_test_check_graph --date-order <<-\EOF
181 * 4_H
182 |\
183 | * 4_G
184 | |\
185 | * | 4_F
186 |/| |
187 | * | 4_E
188 | |\ \
189 | | * | 4_D
190 | |/ /
191 |/| |
192 | | * 4_C
193 | |/
194 | * 4_B
195 |/
196 * 4_A
197 EOF
198 '
199
200 test_expect_success 'log --graph with octopus merge with column joining its penultimate parent' '
201 git checkout --orphan 5_p &&
202 test_commit 5_A &&
203 git branch 5_q &&
204 git branch 5_r &&
205 test_commit 5_B &&
206 git checkout 5_q && test_commit 5_C &&
207 git checkout 5_r && test_commit 5_D &&
208 git checkout 5_p &&
209 git merge --no-ff 5_q 5_r -m 5_E &&
210 git checkout 5_q && test_commit 5_F &&
211 git checkout -b 5_s 5_p^ &&
212 git merge --no-ff 5_p 5_q -m 5_G &&
213 git checkout 5_r &&
214 git merge --no-ff 5_s -m 5_H &&
215
216 lib_test_check_graph <<-\EOF
217 * 5_H
218 |\
219 | *-. 5_G
220 | |\ \
221 | | | * 5_F
222 | | * | 5_E
223 | |/|\ \
224 | |_|/ /
225 |/| | /
226 | | |/
227 * | | 5_D
228 | | * 5_C
229 | |/
230 |/|
231 | * 5_B
232 |/
233 * 5_A
234 EOF
235 '
236
237 test_expect_success 'log --graph with multiple tips' '
238 git checkout --orphan 6_1 &&
239 test_commit 6_A &&
240 git branch 6_2 &&
241 git branch 6_4 &&
242 test_commit 6_B &&
243 git branch 6_3 &&
244 test_commit 6_C &&
245 git checkout 6_2 && test_commit 6_D &&
246 git checkout 6_3 && test_commit 6_E &&
247 git checkout -b 6_5 6_1 &&
248 git merge --no-ff 6_2 -m 6_F &&
249 git checkout 6_4 && test_commit 6_G &&
250 git checkout 6_3 &&
251 git merge --no-ff 6_4 -m 6_H &&
252 git checkout 6_1 &&
253 git merge --no-ff 6_2 -m 6_I &&
254
255 lib_test_check_graph 6_1 6_3 6_5 <<-\EOF
256 * 6_I
257 |\
258 | | * 6_H
259 | | |\
260 | | | * 6_G
261 | | * | 6_E
262 | | | | * 6_F
263 | |_|_|/|
264 |/| | |/
265 | | |/|
266 | |/| |
267 | * | | 6_D
268 | | |/
269 | |/|
270 * | | 6_C
271 | |/
272 |/|
273 * | 6_B
274 |/
275 * 6_A
276 EOF
277 '
278
279 test_expect_success 'log --graph with multiple tips and colors' '
280 test_config log.graphColors red,green,yellow,blue,magenta,cyan &&
281 cat >expect.colors <<-\EOF &&
282 * 6_I
283 <RED>|<RESET><GREEN>\<RESET>
284 <RED>|<RESET> <GREEN>|<RESET> * 6_H
285 <RED>|<RESET> <GREEN>|<RESET> <YELLOW>|<RESET><BLUE>\<RESET>
286 <RED>|<RESET> <GREEN>|<RESET> <YELLOW>|<RESET> * 6_G
287 <RED>|<RESET> <GREEN>|<RESET> <YELLOW>|<RESET> <BLUE>|<RESET> * 6_F
288 <RED>|<RESET> <GREEN>|<RESET><RED>_<RESET><YELLOW>|<RESET><RED>_<RESET><BLUE>|<RESET><RED>/<RESET><GREEN>|<RESET>
289 <RED>|<RESET><RED>/<RESET><GREEN>|<RESET> <YELLOW>|<RESET> <BLUE>|<RESET><GREEN>/<RESET>
290 <RED>|<RESET> <GREEN>|<RESET> <YELLOW>|<RESET><GREEN>/<RESET><BLUE>|<RESET>
291 <RED>|<RESET> <GREEN>|<RESET><GREEN>/<RESET><YELLOW>|<RESET> <BLUE>|<RESET>
292 <RED>|<RESET> <GREEN>|<RESET> * <BLUE>|<RESET> 6_E
293 <RED>|<RESET> * <CYAN>|<RESET> <BLUE>|<RESET> 6_D
294 <RED>|<RESET> <BLUE>|<RESET> <CYAN>|<RESET><BLUE>/<RESET>
295 <RED>|<RESET> <BLUE>|<RESET><BLUE>/<RESET><CYAN>|<RESET>
296 * <BLUE>|<RESET> <CYAN>|<RESET> 6_C
297 <CYAN>|<RESET> <BLUE>|<RESET><CYAN>/<RESET>
298 <CYAN>|<RESET><CYAN>/<RESET><BLUE>|<RESET>
299 * <BLUE>|<RESET> 6_B
300 <BLUE>|<RESET><BLUE>/<RESET>
301 * 6_A
302 EOF
303 lib_test_cmp_colored_graph --date-order --pretty=tformat:%s 6_1 6_3 6_5
304 '
305
306 test_expect_success 'log --graph with multiple tips' '
307 git checkout --orphan 7_1 &&
308 test_commit 7_A &&
309 test_commit 7_B &&
310 test_commit 7_C &&
311 git checkout -b 7_2 7_1~2 &&
312 test_commit 7_D &&
313 test_commit 7_E &&
314 git checkout -b 7_3 7_1~1 &&
315 test_commit 7_F &&
316 test_commit 7_G &&
317 git checkout -b 7_4 7_2~1 &&
318 test_commit 7_H &&
319 git checkout -b 7_5 7_1~2 &&
320 test_commit 7_I &&
321 git checkout -b 7_6 7_3~1 &&
322 test_commit 7_J &&
323 git checkout -b M_1 7_1 &&
324 git merge --no-ff 7_2 -m 7_M1 &&
325 git checkout -b M_3 7_3 &&
326 git merge --no-ff 7_4 -m 7_M2 &&
327 git checkout -b M_5 7_5 &&
328 git merge --no-ff 7_6 -m 7_M3 &&
329 git checkout -b M_7 7_1 &&
330 git merge --no-ff 7_2 7_3 -m 7_M4 &&
331
332 lib_test_check_graph M_1 M_3 M_5 M_7 <<-\EOF
333 * 7_M1
334 |\
335 | | * 7_M2
336 | | |\
337 | | | * 7_H
338 | | | | * 7_M3
339 | | | | |\
340 | | | | | * 7_J
341 | | | | * | 7_I
342 | | | | | | * 7_M4
343 | |_|_|_|_|/|\
344 |/| | | | |/ /
345 | | |_|_|/| /
346 | |/| | | |/
347 | | | |_|/|
348 | | |/| | |
349 | | * | | | 7_G
350 | | | |_|/
351 | | |/| |
352 | | * | | 7_F
353 | * | | | 7_E
354 | | |/ /
355 | |/| |
356 | * | | 7_D
357 | | |/
358 | |/|
359 * | | 7_C
360 | |/
361 |/|
362 * | 7_B
363 |/
364 * 7_A
365 EOF
366 '
367
368 test_expect_success 'log --graph --graph-lane-limit=2 limited to two lanes' '
369 lib_test_check_graph --graph-lane-limit=2 M_7 <<-\EOF
370 *-. 7_M4
371 |\ \
372 | | * 7_G
373 | | * 7_F
374 | * ~ 7_E
375 | * ~ 7_D
376 * | ~ 7_C
377 | |/
378 |/|
379 * | 7_B
380 |/
381 * 7_A
382 EOF
383 '
384
385 test_expect_success 'log --graph --graph-lane-limit=1 truncate mid octopus merge' '
386 lib_test_check_graph --graph-lane-limit=1 M_7 <<-\EOF
387 *-~ 7_M4
388 |\~
389 | ~ 7_G
390 | ~ 7_F
391 | * 7_E
392 | * 7_D
393 * ~ 7_C
394 | ~
395 |/~
396 * ~ 7_B
397 |/
398 * 7_A
399 EOF
400 '
401
402 test_expect_success 'log --graph --graph-lane-limit=3 limited to three lanes' '
403 lib_test_check_graph --graph-lane-limit=3 M_1 M_3 M_5 M_7 <<-\EOF
404 * 7_M1
405 |\
406 | | * 7_M2
407 | | |\
408 | | | * 7_H
409 | | | ~ 7_M3
410 | | | ~ 7_J
411 | | | ~ 7_I
412 | | | ~ 7_M4
413 | |_|_~
414 |/| | ~
415 | | |_~
416 | |/| ~
417 | | | ~
418 | | |/~
419 | | * ~ 7_G
420 | | | ~
421 | | |/~
422 | | * ~ 7_F
423 | * | ~ 7_E
424 | | |/~
425 | |/| ~
426 | * | ~ 7_D
427 | | |/
428 | |/|
429 * | | 7_C
430 | |/
431 |/|
432 * | 7_B
433 |/
434 * 7_A
435 EOF
436 '
437
438 test_expect_success 'log --graph --graph-lane-limit=6 check if it only shows first of 3 parent merge' '
439 lib_test_check_graph --graph-lane-limit=6 M_1 M_3 M_5 M_7 <<-\EOF
440 * 7_M1
441 |\
442 | | * 7_M2
443 | | |\
444 | | | * 7_H
445 | | | | * 7_M3
446 | | | | |\
447 | | | | | * 7_J
448 | | | | * | 7_I
449 | | | | | | * 7_M4
450 | |_|_|_|_|/~
451 |/| | | | |/~
452 | | |_|_|/| ~
453 | |/| | | |/
454 | | | |_|/|
455 | | |/| | |
456 | | * | | | 7_G
457 | | | |_|/
458 | | |/| |
459 | | * | | 7_F
460 | * | | | 7_E
461 | | |/ /
462 | |/| |
463 | * | | 7_D
464 | | |/
465 | |/|
466 * | | 7_C
467 | |/
468 |/|
469 * | 7_B
470 |/
471 * 7_A
472 EOF
473 '
474
475 test_expect_success 'log --graph --graph-lane-limit=7 check if it shows all 3 parent merge' '
476 lib_test_check_graph --graph-lane-limit=7 M_1 M_3 M_5 M_7 <<-\EOF
477 * 7_M1
478 |\
479 | | * 7_M2
480 | | |\
481 | | | * 7_H
482 | | | | * 7_M3
483 | | | | |\
484 | | | | | * 7_J
485 | | | | * | 7_I
486 | | | | | | * 7_M4
487 | |_|_|_|_|/|\
488 |/| | | | |/ /
489 | | |_|_|/| /
490 | |/| | | |/
491 | | | |_|/|
492 | | |/| | |
493 | | * | | | 7_G
494 | | | |_|/
495 | | |/| |
496 | | * | | 7_F
497 | * | | | 7_E
498 | | |/ /
499 | |/| |
500 | * | | 7_D
501 | | |/
502 | |/|
503 * | | 7_C
504 | |/
505 |/|
506 * | 7_B
507 |/
508 * 7_A
509 EOF
510 '
511
512 test_done