Git 2.24.3
[git] / t / t4214-log-graph-octopus.sh
1 #!/bin/sh
2
3 test_description='git log --graph of skewed left octopus merge.'
4
5 . ./test-lib.sh
6
7 test_expect_success 'set up merge history' '
8         test_commit initial &&
9         for i in 1 2 3 4 ; do
10                 git checkout master -b $i || return $?
11                 # Make tag name different from branch name, to avoid
12                 # ambiguity error when calling checkout.
13                 test_commit $i $i $i tag$i || return $?
14         done &&
15         git checkout 1 -b merge &&
16         test_merge octopus-merge 1 2 3 4 &&
17         test_commit after-merge &&
18         git checkout 1 -b L &&
19         test_commit left &&
20         git checkout 4 -b crossover &&
21         test_commit after-4 &&
22         git checkout initial -b more-L &&
23         test_commit after-initial
24 '
25
26 test_expect_success 'log --graph with tricky octopus merge, no color' '
27         cat >expect.uncolored <<-\EOF &&
28         * left
29         | *---.   octopus-merge
30         | |\ \ \
31         |/ / / /
32         | | | * 4
33         | | * | 3
34         | | |/
35         | * | 2
36         | |/
37         * | 1
38         |/
39         * initial
40         EOF
41         git log --color=never --graph --date-order --pretty=tformat:%s left octopus-merge >actual.raw &&
42         sed "s/ *\$//" actual.raw >actual &&
43         test_cmp expect.uncolored actual
44 '
45
46 test_expect_success 'log --graph with tricky octopus merge with colors' '
47         test_config log.graphColors red,green,yellow,blue,magenta,cyan &&
48         cat >expect.colors <<-\EOF &&
49         * left
50         <RED>|<RESET> *<BLUE>-<RESET><BLUE>-<RESET><MAGENTA>-<RESET><MAGENTA>.<RESET>   octopus-merge
51         <RED>|<RESET> <RED>|<RESET><YELLOW>\<RESET> <BLUE>\<RESET> <MAGENTA>\<RESET>
52         <RED>|<RESET><RED>/<RESET> <YELLOW>/<RESET> <BLUE>/<RESET> <MAGENTA>/<RESET>
53         <RED>|<RESET> <YELLOW>|<RESET> <BLUE>|<RESET> * 4
54         <RED>|<RESET> <YELLOW>|<RESET> * <MAGENTA>|<RESET> 3
55         <RED>|<RESET> <YELLOW>|<RESET> <MAGENTA>|<RESET><MAGENTA>/<RESET>
56         <RED>|<RESET> * <MAGENTA>|<RESET> 2
57         <RED>|<RESET> <MAGENTA>|<RESET><MAGENTA>/<RESET>
58         * <MAGENTA>|<RESET> 1
59         <MAGENTA>|<RESET><MAGENTA>/<RESET>
60         * initial
61         EOF
62         git log --color=always --graph --date-order --pretty=tformat:%s left octopus-merge >actual.colors.raw &&
63         test_decode_color <actual.colors.raw | sed "s/ *\$//" >actual.colors &&
64         test_cmp expect.colors actual.colors
65 '
66
67 # Repeat the previous two tests with "normal" octopus merge (i.e.,
68 # without the first parent skewing to the "left" branch column).
69
70 test_expect_success 'log --graph with normal octopus merge, no color' '
71         cat >expect.uncolored <<-\EOF &&
72         *---.   octopus-merge
73         |\ \ \
74         | | | * 4
75         | | * | 3
76         | | |/
77         | * | 2
78         | |/
79         * | 1
80         |/
81         * initial
82         EOF
83         git log --color=never --graph --date-order --pretty=tformat:%s octopus-merge >actual.raw &&
84         sed "s/ *\$//" actual.raw >actual &&
85         test_cmp expect.uncolored actual
86 '
87
88 test_expect_success 'log --graph with normal octopus merge with colors' '
89         cat >expect.colors <<-\EOF &&
90         *<YELLOW>-<RESET><YELLOW>-<RESET><BLUE>-<RESET><BLUE>.<RESET>   octopus-merge
91         <RED>|<RESET><GREEN>\<RESET> <YELLOW>\<RESET> <BLUE>\<RESET>
92         <RED>|<RESET> <GREEN>|<RESET> <YELLOW>|<RESET> * 4
93         <RED>|<RESET> <GREEN>|<RESET> * <BLUE>|<RESET> 3
94         <RED>|<RESET> <GREEN>|<RESET> <BLUE>|<RESET><BLUE>/<RESET>
95         <RED>|<RESET> * <BLUE>|<RESET> 2
96         <RED>|<RESET> <BLUE>|<RESET><BLUE>/<RESET>
97         * <BLUE>|<RESET> 1
98         <BLUE>|<RESET><BLUE>/<RESET>
99         * initial
100         EOF
101         test_config log.graphColors red,green,yellow,blue,magenta,cyan &&
102         git log --color=always --graph --date-order --pretty=tformat:%s octopus-merge >actual.colors.raw &&
103         test_decode_color <actual.colors.raw | sed "s/ *\$//" >actual.colors &&
104         test_cmp expect.colors actual.colors
105 '
106
107 test_expect_success 'log --graph with normal octopus merge and child, no color' '
108         cat >expect.uncolored <<-\EOF &&
109         * after-merge
110         *---.   octopus-merge
111         |\ \ \
112         | | | * 4
113         | | * | 3
114         | | |/
115         | * | 2
116         | |/
117         * | 1
118         |/
119         * initial
120         EOF
121         git log --color=never --graph --date-order --pretty=tformat:%s after-merge >actual.raw &&
122         sed "s/ *\$//" actual.raw >actual &&
123         test_cmp expect.uncolored actual
124 '
125
126 test_expect_failure 'log --graph with normal octopus and child merge with colors' '
127         cat >expect.colors <<-\EOF &&
128         * after-merge
129         *<BLUE>-<RESET><BLUE>-<RESET><MAGENTA>-<RESET><MAGENTA>.<RESET>   octopus-merge
130         <GREEN>|<RESET><YELLOW>\<RESET> <BLUE>\<RESET> <MAGENTA>\<RESET>
131         <GREEN>|<RESET> <YELLOW>|<RESET> <BLUE>|<RESET> * 4
132         <GREEN>|<RESET> <YELLOW>|<RESET> * <MAGENTA>|<RESET> 3
133         <GREEN>|<RESET> <YELLOW>|<RESET> <MAGENTA>|<RESET><MAGENTA>/<RESET>
134         <GREEN>|<RESET> * <MAGENTA>|<RESET> 2
135         <GREEN>|<RESET> <MAGENTA>|<RESET><MAGENTA>/<RESET>
136         * <MAGENTA>|<RESET> 1
137         <MAGENTA>|<RESET><MAGENTA>/<RESET>
138         * initial
139         EOF
140         test_config log.graphColors red,green,yellow,blue,magenta,cyan &&
141         git log --color=always --graph --date-order --pretty=tformat:%s after-merge >actual.colors.raw &&
142         test_decode_color <actual.colors.raw | sed "s/ *\$//" >actual.colors &&
143         test_cmp expect.colors actual.colors
144 '
145
146 test_expect_success 'log --graph with tricky octopus merge and its child, no color' '
147         cat >expect.uncolored <<-\EOF &&
148         * left
149         | * after-merge
150         | *---.   octopus-merge
151         | |\ \ \
152         |/ / / /
153         | | | * 4
154         | | * | 3
155         | | |/
156         | * | 2
157         | |/
158         * | 1
159         |/
160         * initial
161         EOF
162         git log --color=never --graph --date-order --pretty=tformat:%s left after-merge >actual.raw &&
163         sed "s/ *\$//" actual.raw >actual &&
164         test_cmp expect.uncolored actual
165 '
166
167 test_expect_failure 'log --graph with tricky octopus merge and its child with colors' '
168         test_config log.graphColors red,green,yellow,blue,magenta,cyan &&
169         cat >expect.colors <<-\EOF &&
170         * left
171         <RED>|<RESET> * after-merge
172         <RED>|<RESET> *<MAGENTA>-<RESET><MAGENTA>-<RESET><CYAN>-<RESET><CYAN>.<RESET>   octopus-merge
173         <RED>|<RESET> <RED>|<RESET><BLUE>\<RESET> <MAGENTA>\<RESET> <CYAN>\<RESET>
174         <RED>|<RESET><RED>/<RESET> <BLUE>/<RESET> <MAGENTA>/<RESET> <CYAN>/<RESET>
175         <RED>|<RESET> <BLUE>|<RESET> <MAGENTA>|<RESET> * 4
176         <RED>|<RESET> <BLUE>|<RESET> * <CYAN>|<RESET> 3
177         <RED>|<RESET> <BLUE>|<RESET> <CYAN>|<RESET><CYAN>/<RESET>
178         <RED>|<RESET> * <CYAN>|<RESET> 2
179         <RED>|<RESET> <CYAN>|<RESET><CYAN>/<RESET>
180         * <CYAN>|<RESET> 1
181         <CYAN>|<RESET><CYAN>/<RESET>
182         * initial
183         EOF
184         git log --color=always --graph --date-order --pretty=tformat:%s left after-merge >actual.colors.raw &&
185         test_decode_color <actual.colors.raw | sed "s/ *\$//" >actual.colors &&
186         test_cmp expect.colors actual.colors
187 '
188
189 test_expect_success 'log --graph with crossover in octopus merge, no color' '
190         cat >expect.uncolored <<-\EOF &&
191         * after-4
192         | *---.   octopus-merge
193         | |\ \ \
194         | |_|_|/
195         |/| | |
196         * | | | 4
197         | | | * 3
198         | |_|/
199         |/| |
200         | | * 2
201         | |/
202         |/|
203         | * 1
204         |/
205         * initial
206         EOF
207         git log --color=never --graph --date-order --pretty=tformat:%s after-4 octopus-merge >actual.raw &&
208         sed "s/ *\$//" actual.raw >actual &&
209         test_cmp expect.uncolored actual
210 '
211
212 test_expect_failure 'log --graph with crossover in octopus merge with colors' '
213         test_config log.graphColors red,green,yellow,blue,magenta,cyan &&
214         cat >expect.colors <<-\EOF &&
215         * after-4
216         <RED>|<RESET> *<BLUE>-<RESET><BLUE>-<RESET><RED>-<RESET><RED>.<RESET>   octopus-merge
217         <RED>|<RESET> <GREEN>|<RESET><YELLOW>\<RESET> <BLUE>\<RESET> <RED>\<RESET>
218         <RED>|<RESET> <GREEN>|<RESET><RED>_<RESET><YELLOW>|<RESET><RED>_<RESET><BLUE>|<RESET><RED>/<RESET>
219         <RED>|<RESET><RED>/<RESET><GREEN>|<RESET> <YELLOW>|<RESET> <BLUE>|<RESET>
220         * <GREEN>|<RESET> <YELLOW>|<RESET> <BLUE>|<RESET> 4
221         <MAGENTA>|<RESET> <GREEN>|<RESET> <YELLOW>|<RESET> * 3
222         <MAGENTA>|<RESET> <GREEN>|<RESET><MAGENTA>_<RESET><YELLOW>|<RESET><MAGENTA>/<RESET>
223         <MAGENTA>|<RESET><MAGENTA>/<RESET><GREEN>|<RESET> <YELLOW>|<RESET>
224         <MAGENTA>|<RESET> <GREEN>|<RESET> * 2
225         <MAGENTA>|<RESET> <GREEN>|<RESET><MAGENTA>/<RESET>
226         <MAGENTA>|<RESET><MAGENTA>/<RESET><GREEN>|<RESET>
227         <MAGENTA>|<RESET> * 1
228         <MAGENTA>|<RESET><MAGENTA>/<RESET>
229         * initial
230         EOF
231         git log --color=always --graph --date-order --pretty=tformat:%s after-4 octopus-merge >actual.colors.raw &&
232         test_decode_color <actual.colors.raw | sed "s/ *\$//" >actual.colors &&
233         test_cmp expect.colors actual.colors
234 '
235
236 test_expect_success 'log --graph with crossover in octopus merge and its child, no color' '
237         cat >expect.uncolored <<-\EOF &&
238         * after-4
239         | * after-merge
240         | *---.   octopus-merge
241         | |\ \ \
242         | |_|_|/
243         |/| | |
244         * | | | 4
245         | | | * 3
246         | |_|/
247         |/| |
248         | | * 2
249         | |/
250         |/|
251         | * 1
252         |/
253         * initial
254         EOF
255         git log --color=never --graph --date-order --pretty=tformat:%s after-4 after-merge >actual.raw &&
256         sed "s/ *\$//" actual.raw >actual &&
257         test_cmp expect.uncolored actual
258 '
259
260 test_expect_failure 'log --graph with crossover in octopus merge and its child with colors' '
261         test_config log.graphColors red,green,yellow,blue,magenta,cyan &&
262         cat >expect.colors <<-\EOF &&
263         * after-4
264         <RED>|<RESET> * after-merge
265         <RED>|<RESET> *<MAGENTA>-<RESET><MAGENTA>-<RESET><RED>-<RESET><RED>.<RESET>   octopus-merge
266         <RED>|<RESET> <YELLOW>|<RESET><BLUE>\<RESET> <MAGENTA>\<RESET> <RED>\<RESET>
267         <RED>|<RESET> <YELLOW>|<RESET><RED>_<RESET><BLUE>|<RESET><RED>_<RESET><MAGENTA>|<RESET><RED>/<RESET>
268         <RED>|<RESET><RED>/<RESET><YELLOW>|<RESET> <BLUE>|<RESET> <MAGENTA>|<RESET>
269         * <YELLOW>|<RESET> <BLUE>|<RESET> <MAGENTA>|<RESET> 4
270         <CYAN>|<RESET> <YELLOW>|<RESET> <BLUE>|<RESET> * 3
271         <CYAN>|<RESET> <YELLOW>|<RESET><CYAN>_<RESET><BLUE>|<RESET><CYAN>/<RESET>
272         <CYAN>|<RESET><CYAN>/<RESET><YELLOW>|<RESET> <BLUE>|<RESET>
273         <CYAN>|<RESET> <YELLOW>|<RESET> * 2
274         <CYAN>|<RESET> <YELLOW>|<RESET><CYAN>/<RESET>
275         <CYAN>|<RESET><CYAN>/<RESET><YELLOW>|<RESET>
276         <CYAN>|<RESET> * 1
277         <CYAN>|<RESET><CYAN>/<RESET>
278         * initial
279         EOF
280         git log --color=always --graph --date-order --pretty=tformat:%s after-4 after-merge >actual.colors.raw &&
281         test_decode_color <actual.colors.raw | sed "s/ *\$//" >actual.colors &&
282         test_cmp expect.colors actual.colors
283 '
284
285 test_expect_success 'log --graph with unrelated commit and octopus tip, no color' '
286         cat >expect.uncolored <<-\EOF &&
287         * after-initial
288         | *---.   octopus-merge
289         | |\ \ \
290         | | | | * 4
291         | |_|_|/
292         |/| | |
293         | | | * 3
294         | |_|/
295         |/| |
296         | | * 2
297         | |/
298         |/|
299         | * 1
300         |/
301         * initial
302         EOF
303         git log --color=never --graph --date-order --pretty=tformat:%s after-initial octopus-merge >actual.raw &&
304         sed "s/ *\$//" actual.raw >actual &&
305         test_cmp expect.uncolored actual
306 '
307
308 test_expect_success 'log --graph with unrelated commit and octopus tip with colors' '
309         test_config log.graphColors red,green,yellow,blue,magenta,cyan &&
310         cat >expect.colors <<-\EOF &&
311         * after-initial
312         <RED>|<RESET> *<BLUE>-<RESET><BLUE>-<RESET><MAGENTA>-<RESET><MAGENTA>.<RESET>   octopus-merge
313         <RED>|<RESET> <GREEN>|<RESET><YELLOW>\<RESET> <BLUE>\<RESET> <MAGENTA>\<RESET>
314         <RED>|<RESET> <GREEN>|<RESET> <YELLOW>|<RESET> <BLUE>|<RESET> * 4
315         <RED>|<RESET> <GREEN>|<RESET><RED>_<RESET><YELLOW>|<RESET><RED>_<RESET><BLUE>|<RESET><RED>/<RESET>
316         <RED>|<RESET><RED>/<RESET><GREEN>|<RESET> <YELLOW>|<RESET> <BLUE>|<RESET>
317         <RED>|<RESET> <GREEN>|<RESET> <YELLOW>|<RESET> * 3
318         <RED>|<RESET> <GREEN>|<RESET><RED>_<RESET><YELLOW>|<RESET><RED>/<RESET>
319         <RED>|<RESET><RED>/<RESET><GREEN>|<RESET> <YELLOW>|<RESET>
320         <RED>|<RESET> <GREEN>|<RESET> * 2
321         <RED>|<RESET> <GREEN>|<RESET><RED>/<RESET>
322         <RED>|<RESET><RED>/<RESET><GREEN>|<RESET>
323         <RED>|<RESET> * 1
324         <RED>|<RESET><RED>/<RESET>
325         * initial
326         EOF
327         git log --color=always --graph --date-order --pretty=tformat:%s after-initial octopus-merge >actual.colors.raw &&
328         test_decode_color <actual.colors.raw | sed "s/ *\$//" >actual.colors &&
329         test_cmp expect.colors actual.colors
330 '
331
332 test_expect_success 'log --graph with unrelated commit and octopus child, no color' '
333         cat >expect.uncolored <<-\EOF &&
334         * after-initial
335         | * after-merge
336         | *---.   octopus-merge
337         | |\ \ \
338         | | | | * 4
339         | |_|_|/
340         |/| | |
341         | | | * 3
342         | |_|/
343         |/| |
344         | | * 2
345         | |/
346         |/|
347         | * 1
348         |/
349         * initial
350         EOF
351         git log --color=never --graph --date-order --pretty=tformat:%s after-initial after-merge >actual.raw &&
352         sed "s/ *\$//" actual.raw >actual &&
353         test_cmp expect.uncolored actual
354 '
355
356 test_expect_failure 'log --graph with unrelated commit and octopus child with colors' '
357         test_config log.graphColors red,green,yellow,blue,magenta,cyan &&
358         cat >expect.colors <<-\EOF &&
359         * after-initial
360         <RED>|<RESET> * after-merge
361         <RED>|<RESET> *<MAGENTA>-<RESET><MAGENTA>-<RESET><CYAN>-<RESET><CYAN>.<RESET>   octopus-merge
362         <RED>|<RESET> <YELLOW>|<RESET><BLUE>\<RESET> <MAGENTA>\<RESET> <CYAN>\<RESET>
363         <RED>|<RESET> <YELLOW>|<RESET> <BLUE>|<RESET> <MAGENTA>|<RESET> * 4
364         <RED>|<RESET> <YELLOW>|<RESET><RED>_<RESET><BLUE>|<RESET><RED>_<RESET><MAGENTA>|<RESET><RED>/<RESET>
365         <RED>|<RESET><RED>/<RESET><YELLOW>|<RESET> <BLUE>|<RESET> <MAGENTA>|<RESET>
366         <RED>|<RESET> <YELLOW>|<RESET> <BLUE>|<RESET> * 3
367         <RED>|<RESET> <YELLOW>|<RESET><RED>_<RESET><BLUE>|<RESET><RED>/<RESET>
368         <RED>|<RESET><RED>/<RESET><YELLOW>|<RESET> <BLUE>|<RESET>
369         <RED>|<RESET> <YELLOW>|<RESET> * 2
370         <RED>|<RESET> <YELLOW>|<RESET><RED>/<RESET>
371         <RED>|<RESET><RED>/<RESET><YELLOW>|<RESET>
372         <RED>|<RESET> * 1
373         <RED>|<RESET><RED>/<RESET>
374         * initial
375         EOF
376         git log --color=always --graph --date-order --pretty=tformat:%s after-initial after-merge >actual.colors.raw &&
377         test_decode_color <actual.colors.raw | sed "s/ *\$//" >actual.colors &&
378         test_cmp expect.colors actual.colors
379 '
380
381 test_done