Git 2.45
[git/gitster.git] / t / t4214-log-graph-octopus.sh
blob79055978690962fc3b58cd754a9383a88148f0f9
1 #!/bin/sh
3 test_description='git log --graph of skewed left octopus merge.'
5 GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
6 export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
8 TEST_PASSES_SANITIZE_LEAK=true
9 . ./test-lib.sh
10 . "$TEST_DIRECTORY"/lib-log-graph.sh
12 test_cmp_graph () {
13 cat >expect &&
14 lib_test_cmp_graph --color=never --date-order --format=%s "$@"
17 test_cmp_colored_graph () {
18 lib_test_cmp_colored_graph --date-order --format=%s "$@"
21 test_expect_success 'set up merge history' '
22 test_commit initial &&
23 for i in 1 2 3 4 ; do
24 git checkout main -b $i || return $?
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 &&
31 test_commit after-merge &&
32 git checkout 1 -b L &&
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
40 test_expect_success 'log --graph with tricky octopus merge, no color' '
41 test_cmp_graph left octopus-merge <<-\EOF
42 * left
43 | *-. octopus-merge
44 |/|\ \
45 | | | * 4
46 | | * | 3
47 | | |/
48 | * / 2
49 | |/
50 * / 1
52 * initial
53 EOF
56 test_expect_success 'log --graph with tricky octopus merge with colors' '
57 test_config log.graphColors red,green,yellow,blue,magenta,cyan &&
58 cat >expect.colors <<-\EOF &&
59 * left
60 <RED>|<RESET> *<MAGENTA>-<RESET><MAGENTA>.<RESET> octopus-merge
61 <RED>|<RESET><RED>/<RESET><YELLOW>|<RESET><BLUE>\<RESET> <MAGENTA>\<RESET>
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>
65 <RED>|<RESET> * <MAGENTA>/<RESET> 2
66 <RED>|<RESET> <MAGENTA>|<RESET><MAGENTA>/<RESET>
67 * <MAGENTA>/<RESET> 1
68 <MAGENTA>|<RESET><MAGENTA>/<RESET>
69 * initial
70 EOF
71 test_cmp_colored_graph left octopus-merge
74 # Repeat the previous two tests with "normal" octopus merge (i.e.,
75 # without the first parent skewing to the "left" branch column).
77 test_expect_success 'log --graph with normal octopus merge, no color' '
78 test_cmp_graph octopus-merge <<-\EOF
79 *---. octopus-merge
80 |\ \ \
81 | | | * 4
82 | | * | 3
83 | | |/
84 | * / 2
85 | |/
86 * / 1
88 * initial
89 EOF
92 test_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>
99 <RED>|<RESET> * <BLUE>/<RESET> 2
100 <RED>|<RESET> <BLUE>|<RESET><BLUE>/<RESET>
101 * <BLUE>/<RESET> 1
102 <BLUE>|<RESET><BLUE>/<RESET>
103 * initial
105 test_config log.graphColors red,green,yellow,blue,magenta,cyan &&
106 test_cmp_colored_graph octopus-merge
109 test_expect_success 'log --graph with normal octopus merge and child, no color' '
110 test_cmp_graph after-merge <<-\EOF
111 * after-merge
112 *---. octopus-merge
113 |\ \ \
114 | | | * 4
115 | | * | 3
116 | | |/
117 | * / 2
118 | |/
119 * / 1
121 * initial
125 test_expect_success 'log --graph with normal octopus and child merge with colors' '
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>
133 <GREEN>|<RESET> * <MAGENTA>/<RESET> 2
134 <GREEN>|<RESET> <MAGENTA>|<RESET><MAGENTA>/<RESET>
135 * <MAGENTA>/<RESET> 1
136 <MAGENTA>|<RESET><MAGENTA>/<RESET>
137 * initial
139 test_config log.graphColors red,green,yellow,blue,magenta,cyan &&
140 test_cmp_colored_graph after-merge
143 test_expect_success 'log --graph with tricky octopus merge and its child, no color' '
144 test_cmp_graph left after-merge <<-\EOF
145 * left
146 | * after-merge
147 | *-. octopus-merge
148 |/|\ \
149 | | | * 4
150 | | * | 3
151 | | |/
152 | * / 2
153 | |/
154 * / 1
156 * initial
160 test_expect_success 'log --graph with tricky octopus merge and its child with colors' '
161 test_config log.graphColors red,green,yellow,blue,magenta,cyan &&
162 cat >expect.colors <<-\EOF &&
163 * left
164 <RED>|<RESET> * after-merge
165 <RED>|<RESET> *<CYAN>-<RESET><CYAN>.<RESET> octopus-merge
166 <RED>|<RESET><RED>/<RESET><BLUE>|<RESET><MAGENTA>\<RESET> <CYAN>\<RESET>
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>
170 <RED>|<RESET> * <CYAN>/<RESET> 2
171 <RED>|<RESET> <CYAN>|<RESET><CYAN>/<RESET>
172 * <CYAN>/<RESET> 1
173 <CYAN>|<RESET><CYAN>/<RESET>
174 * initial
176 test_cmp_colored_graph left after-merge
179 test_expect_success 'log --graph with crossover in octopus merge, no color' '
180 test_cmp_graph after-4 octopus-merge <<-\EOF
181 * after-4
182 | *---. octopus-merge
183 | |\ \ \
184 | |_|_|/
185 |/| | |
186 * | | | 4
187 | | | * 3
188 | |_|/
189 |/| |
190 | | * 2
191 | |/
193 | * 1
195 * initial
199 test_expect_success 'log --graph with crossover in octopus merge with colors' '
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
218 test_cmp_colored_graph after-4 octopus-merge
221 test_expect_success 'log --graph with crossover in octopus merge and its child, no color' '
222 test_cmp_graph after-4 after-merge <<-\EOF
223 * after-4
224 | * after-merge
225 | *---. octopus-merge
226 | |\ \ \
227 | |_|_|/
228 |/| | |
229 * | | | 4
230 | | | * 3
231 | |_|/
232 |/| |
233 | | * 2
234 | |/
236 | * 1
238 * initial
242 test_expect_success 'log --graph with crossover in octopus merge and its child with colors' '
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
262 test_cmp_colored_graph after-4 after-merge
265 test_expect_success 'log --graph with unrelated commit and octopus tip, no color' '
266 test_cmp_graph after-initial octopus-merge <<-\EOF
267 * after-initial
268 | *---. octopus-merge
269 | |\ \ \
270 | | | | * 4
271 | |_|_|/
272 |/| | |
273 | | | * 3
274 | |_|/
275 |/| |
276 | | * 2
277 | |/
279 | * 1
281 * initial
285 test_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
304 test_cmp_colored_graph after-initial octopus-merge
307 test_expect_success 'log --graph with unrelated commit and octopus child, no color' '
308 test_cmp_graph after-initial after-merge <<-\EOF
309 * after-initial
310 | * after-merge
311 | *---. octopus-merge
312 | |\ \ \
313 | | | | * 4
314 | |_|_|/
315 |/| | |
316 | | | * 3
317 | |_|/
318 |/| |
319 | | * 2
320 | |/
322 | * 1
324 * initial
328 test_expect_success 'log --graph with unrelated commit and octopus child with colors' '
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
348 test_cmp_colored_graph after-initial after-merge
351 test_done