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