blob: f70c46bbbfa2c8fc9cc5ca1b620c9a80f29e382e [file] [log] [blame]
Noam Postavsky04005832018-09-01 20:07:16 -04001#!/bin/sh
2
3test_description='git log --graph of skewed left octopus merge.'
4
Johannes Schindelin8f378542020-11-18 23:44:27 +00005GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
Johannes Schindelin334afbc2020-11-18 23:44:19 +00006export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
7
Noam Postavsky04005832018-09-01 20:07:16 -04008. ./test-lib.sh
Abhishek Kumar989eea92020-02-24 19:08:13 +05309. "$TEST_DIRECTORY"/lib-log-graph.sh
10
11test_cmp_graph () {
12 cat >expect &&
13 lib_test_cmp_graph --color=never --date-order --format=%s "$@"
14}
Noam Postavsky04005832018-09-01 20:07:16 -040015
Abhishek Kumarffe00552020-02-24 19:08:14 +053016test_cmp_colored_graph () {
17 lib_test_cmp_colored_graph --date-order --format=%s "$@"
18}
19
Noam Postavsky04005832018-09-01 20:07:16 -040020test_expect_success 'set up merge history' '
Denton Liu63be8c82019-10-03 17:23:17 -070021 test_commit initial &&
22 for i in 1 2 3 4 ; do
Johannes Schindelin8f378542020-11-18 23:44:27 +000023 git checkout main -b $i || return $?
Denton Liu63be8c82019-10-03 17:23:17 -070024 # Make tag name different from branch name, to avoid
25 # ambiguity error when calling checkout.
26 test_commit $i $i $i tag$i || return $?
27 done &&
28 git checkout 1 -b merge &&
29 test_merge octopus-merge 1 2 3 4 &&
Denton Liu11c21f22019-10-03 17:23:22 -070030 test_commit after-merge &&
Denton Liu63be8c82019-10-03 17:23:17 -070031 git checkout 1 -b L &&
Denton Liu11c21f22019-10-03 17:23:22 -070032 test_commit left &&
33 git checkout 4 -b crossover &&
34 test_commit after-4 &&
35 git checkout initial -b more-L &&
36 test_commit after-initial
Denton Liu63be8c82019-10-03 17:23:17 -070037'
38
39test_expect_success 'log --graph with tricky octopus merge, no color' '
Abhishek Kumar989eea92020-02-24 19:08:13 +053040 test_cmp_graph left octopus-merge <<-\EOF
Noam Postavsky04005832018-09-01 20:07:16 -040041 * left
James Coglan0f0f3892019-10-15 23:47:54 +000042 | *-. octopus-merge
43 |/|\ \
Noam Postavsky04005832018-09-01 20:07:16 -040044 | | | * 4
45 | | * | 3
46 | | |/
James Coglan479db182019-10-15 23:47:57 +000047 | * / 2
Noam Postavsky04005832018-09-01 20:07:16 -040048 | |/
James Coglan479db182019-10-15 23:47:57 +000049 * / 1
Noam Postavsky04005832018-09-01 20:07:16 -040050 |/
51 * initial
52 EOF
Denton Liu63be8c82019-10-03 17:23:17 -070053'
54
55test_expect_success 'log --graph with tricky octopus merge with colors' '
56 test_config log.graphColors red,green,yellow,blue,magenta,cyan &&
Noam Postavsky04005832018-09-01 20:07:16 -040057 cat >expect.colors <<-\EOF &&
58 * left
James Coglan0f0f3892019-10-15 23:47:54 +000059 <RED>|<RESET> *<MAGENTA>-<RESET><MAGENTA>.<RESET> octopus-merge
60 <RED>|<RESET><RED>/<RESET><YELLOW>|<RESET><BLUE>\<RESET> <MAGENTA>\<RESET>
Noam Postavsky04005832018-09-01 20:07:16 -040061 <RED>|<RESET> <YELLOW>|<RESET> <BLUE>|<RESET> * 4
62 <RED>|<RESET> <YELLOW>|<RESET> * <MAGENTA>|<RESET> 3
63 <RED>|<RESET> <YELLOW>|<RESET> <MAGENTA>|<RESET><MAGENTA>/<RESET>
James Coglan479db182019-10-15 23:47:57 +000064 <RED>|<RESET> * <MAGENTA>/<RESET> 2
Noam Postavsky04005832018-09-01 20:07:16 -040065 <RED>|<RESET> <MAGENTA>|<RESET><MAGENTA>/<RESET>
James Coglan479db182019-10-15 23:47:57 +000066 * <MAGENTA>/<RESET> 1
Noam Postavsky04005832018-09-01 20:07:16 -040067 <MAGENTA>|<RESET><MAGENTA>/<RESET>
68 * initial
69 EOF
Abhishek Kumarffe00552020-02-24 19:08:14 +053070 test_cmp_colored_graph left octopus-merge
Noam Postavsky04005832018-09-01 20:07:16 -040071'
72
Noam Postavsky04005832018-09-01 20:07:16 -040073# Repeat the previous two tests with "normal" octopus merge (i.e.,
74# without the first parent skewing to the "left" branch column).
75
76test_expect_success 'log --graph with normal octopus merge, no color' '
Abhishek Kumar989eea92020-02-24 19:08:13 +053077 test_cmp_graph octopus-merge <<-\EOF
Noam Postavsky04005832018-09-01 20:07:16 -040078 *---. octopus-merge
79 |\ \ \
80 | | | * 4
81 | | * | 3
82 | | |/
James Coglan479db182019-10-15 23:47:57 +000083 | * / 2
Noam Postavsky04005832018-09-01 20:07:16 -040084 | |/
James Coglan479db182019-10-15 23:47:57 +000085 * / 1
Noam Postavsky04005832018-09-01 20:07:16 -040086 |/
87 * initial
88 EOF
Noam Postavsky04005832018-09-01 20:07:16 -040089'
90
91test_expect_success 'log --graph with normal octopus merge with colors' '
92 cat >expect.colors <<-\EOF &&
93 *<YELLOW>-<RESET><YELLOW>-<RESET><BLUE>-<RESET><BLUE>.<RESET> octopus-merge
94 <RED>|<RESET><GREEN>\<RESET> <YELLOW>\<RESET> <BLUE>\<RESET>
95 <RED>|<RESET> <GREEN>|<RESET> <YELLOW>|<RESET> * 4
96 <RED>|<RESET> <GREEN>|<RESET> * <BLUE>|<RESET> 3
97 <RED>|<RESET> <GREEN>|<RESET> <BLUE>|<RESET><BLUE>/<RESET>
James Coglan479db182019-10-15 23:47:57 +000098 <RED>|<RESET> * <BLUE>/<RESET> 2
Noam Postavsky04005832018-09-01 20:07:16 -040099 <RED>|<RESET> <BLUE>|<RESET><BLUE>/<RESET>
James Coglan479db182019-10-15 23:47:57 +0000100 * <BLUE>/<RESET> 1
Noam Postavsky04005832018-09-01 20:07:16 -0400101 <BLUE>|<RESET><BLUE>/<RESET>
102 * initial
103 EOF
104 test_config log.graphColors red,green,yellow,blue,magenta,cyan &&
Abhishek Kumarffe00552020-02-24 19:08:14 +0530105 test_cmp_colored_graph octopus-merge
Noam Postavsky04005832018-09-01 20:07:16 -0400106'
Denton Liu11c21f22019-10-03 17:23:22 -0700107
108test_expect_success 'log --graph with normal octopus merge and child, no color' '
Abhishek Kumar989eea92020-02-24 19:08:13 +0530109 test_cmp_graph after-merge <<-\EOF
Denton Liu11c21f22019-10-03 17:23:22 -0700110 * after-merge
111 *---. octopus-merge
112 |\ \ \
113 | | | * 4
114 | | * | 3
115 | | |/
James Coglan479db182019-10-15 23:47:57 +0000116 | * / 2
Denton Liu11c21f22019-10-03 17:23:22 -0700117 | |/
James Coglan479db182019-10-15 23:47:57 +0000118 * / 1
Denton Liu11c21f22019-10-03 17:23:22 -0700119 |/
120 * initial
121 EOF
Denton Liu11c21f22019-10-03 17:23:22 -0700122'
123
James Coglanbbb13e82019-10-15 23:47:59 +0000124test_expect_success 'log --graph with normal octopus and child merge with colors' '
Denton Liu11c21f22019-10-03 17:23:22 -0700125 cat >expect.colors <<-\EOF &&
126 * after-merge
127 *<BLUE>-<RESET><BLUE>-<RESET><MAGENTA>-<RESET><MAGENTA>.<RESET> octopus-merge
128 <GREEN>|<RESET><YELLOW>\<RESET> <BLUE>\<RESET> <MAGENTA>\<RESET>
129 <GREEN>|<RESET> <YELLOW>|<RESET> <BLUE>|<RESET> * 4
130 <GREEN>|<RESET> <YELLOW>|<RESET> * <MAGENTA>|<RESET> 3
131 <GREEN>|<RESET> <YELLOW>|<RESET> <MAGENTA>|<RESET><MAGENTA>/<RESET>
James Coglan479db182019-10-15 23:47:57 +0000132 <GREEN>|<RESET> * <MAGENTA>/<RESET> 2
Denton Liu11c21f22019-10-03 17:23:22 -0700133 <GREEN>|<RESET> <MAGENTA>|<RESET><MAGENTA>/<RESET>
James Coglan479db182019-10-15 23:47:57 +0000134 * <MAGENTA>/<RESET> 1
Denton Liu11c21f22019-10-03 17:23:22 -0700135 <MAGENTA>|<RESET><MAGENTA>/<RESET>
136 * initial
137 EOF
138 test_config log.graphColors red,green,yellow,blue,magenta,cyan &&
Abhishek Kumarffe00552020-02-24 19:08:14 +0530139 test_cmp_colored_graph after-merge
Denton Liu11c21f22019-10-03 17:23:22 -0700140'
141
142test_expect_success 'log --graph with tricky octopus merge and its child, no color' '
Abhishek Kumar989eea92020-02-24 19:08:13 +0530143 test_cmp_graph left after-merge <<-\EOF
Denton Liu11c21f22019-10-03 17:23:22 -0700144 * left
145 | * after-merge
James Coglan0f0f3892019-10-15 23:47:54 +0000146 | *-. octopus-merge
147 |/|\ \
Denton Liu11c21f22019-10-03 17:23:22 -0700148 | | | * 4
149 | | * | 3
150 | | |/
James Coglan479db182019-10-15 23:47:57 +0000151 | * / 2
Denton Liu11c21f22019-10-03 17:23:22 -0700152 | |/
James Coglan479db182019-10-15 23:47:57 +0000153 * / 1
Denton Liu11c21f22019-10-03 17:23:22 -0700154 |/
155 * initial
156 EOF
Denton Liu11c21f22019-10-03 17:23:22 -0700157'
158
James Coglanbbb13e82019-10-15 23:47:59 +0000159test_expect_success 'log --graph with tricky octopus merge and its child with colors' '
Denton Liu11c21f22019-10-03 17:23:22 -0700160 test_config log.graphColors red,green,yellow,blue,magenta,cyan &&
161 cat >expect.colors <<-\EOF &&
162 * left
163 <RED>|<RESET> * after-merge
James Coglan0f0f3892019-10-15 23:47:54 +0000164 <RED>|<RESET> *<CYAN>-<RESET><CYAN>.<RESET> octopus-merge
165 <RED>|<RESET><RED>/<RESET><BLUE>|<RESET><MAGENTA>\<RESET> <CYAN>\<RESET>
Denton Liu11c21f22019-10-03 17:23:22 -0700166 <RED>|<RESET> <BLUE>|<RESET> <MAGENTA>|<RESET> * 4
167 <RED>|<RESET> <BLUE>|<RESET> * <CYAN>|<RESET> 3
168 <RED>|<RESET> <BLUE>|<RESET> <CYAN>|<RESET><CYAN>/<RESET>
James Coglan479db182019-10-15 23:47:57 +0000169 <RED>|<RESET> * <CYAN>/<RESET> 2
Denton Liu11c21f22019-10-03 17:23:22 -0700170 <RED>|<RESET> <CYAN>|<RESET><CYAN>/<RESET>
James Coglan479db182019-10-15 23:47:57 +0000171 * <CYAN>/<RESET> 1
Denton Liu11c21f22019-10-03 17:23:22 -0700172 <CYAN>|<RESET><CYAN>/<RESET>
173 * initial
174 EOF
Abhishek Kumarffe00552020-02-24 19:08:14 +0530175 test_cmp_colored_graph left after-merge
Denton Liu11c21f22019-10-03 17:23:22 -0700176'
177
178test_expect_success 'log --graph with crossover in octopus merge, no color' '
Abhishek Kumar989eea92020-02-24 19:08:13 +0530179 test_cmp_graph after-4 octopus-merge <<-\EOF
Denton Liu11c21f22019-10-03 17:23:22 -0700180 * after-4
181 | *---. octopus-merge
182 | |\ \ \
183 | |_|_|/
184 |/| | |
185 * | | | 4
186 | | | * 3
187 | |_|/
188 |/| |
189 | | * 2
190 | |/
191 |/|
192 | * 1
193 |/
194 * initial
195 EOF
Denton Liu11c21f22019-10-03 17:23:22 -0700196'
197
James Coglanbbb13e82019-10-15 23:47:59 +0000198test_expect_success 'log --graph with crossover in octopus merge with colors' '
Denton Liu11c21f22019-10-03 17:23:22 -0700199 test_config log.graphColors red,green,yellow,blue,magenta,cyan &&
200 cat >expect.colors <<-\EOF &&
201 * after-4
202 <RED>|<RESET> *<BLUE>-<RESET><BLUE>-<RESET><RED>-<RESET><RED>.<RESET> octopus-merge
203 <RED>|<RESET> <GREEN>|<RESET><YELLOW>\<RESET> <BLUE>\<RESET> <RED>\<RESET>
204 <RED>|<RESET> <GREEN>|<RESET><RED>_<RESET><YELLOW>|<RESET><RED>_<RESET><BLUE>|<RESET><RED>/<RESET>
205 <RED>|<RESET><RED>/<RESET><GREEN>|<RESET> <YELLOW>|<RESET> <BLUE>|<RESET>
206 * <GREEN>|<RESET> <YELLOW>|<RESET> <BLUE>|<RESET> 4
207 <MAGENTA>|<RESET> <GREEN>|<RESET> <YELLOW>|<RESET> * 3
208 <MAGENTA>|<RESET> <GREEN>|<RESET><MAGENTA>_<RESET><YELLOW>|<RESET><MAGENTA>/<RESET>
209 <MAGENTA>|<RESET><MAGENTA>/<RESET><GREEN>|<RESET> <YELLOW>|<RESET>
210 <MAGENTA>|<RESET> <GREEN>|<RESET> * 2
211 <MAGENTA>|<RESET> <GREEN>|<RESET><MAGENTA>/<RESET>
212 <MAGENTA>|<RESET><MAGENTA>/<RESET><GREEN>|<RESET>
213 <MAGENTA>|<RESET> * 1
214 <MAGENTA>|<RESET><MAGENTA>/<RESET>
215 * initial
216 EOF
Abhishek Kumarffe00552020-02-24 19:08:14 +0530217 test_cmp_colored_graph after-4 octopus-merge
Denton Liu11c21f22019-10-03 17:23:22 -0700218'
219
220test_expect_success 'log --graph with crossover in octopus merge and its child, no color' '
Abhishek Kumar989eea92020-02-24 19:08:13 +0530221 test_cmp_graph after-4 after-merge <<-\EOF
Denton Liu11c21f22019-10-03 17:23:22 -0700222 * after-4
223 | * after-merge
224 | *---. octopus-merge
225 | |\ \ \
226 | |_|_|/
227 |/| | |
228 * | | | 4
229 | | | * 3
230 | |_|/
231 |/| |
232 | | * 2
233 | |/
234 |/|
235 | * 1
236 |/
237 * initial
238 EOF
Denton Liu11c21f22019-10-03 17:23:22 -0700239'
240
James Coglanbbb13e82019-10-15 23:47:59 +0000241test_expect_success 'log --graph with crossover in octopus merge and its child with colors' '
Denton Liu11c21f22019-10-03 17:23:22 -0700242 test_config log.graphColors red,green,yellow,blue,magenta,cyan &&
243 cat >expect.colors <<-\EOF &&
244 * after-4
245 <RED>|<RESET> * after-merge
246 <RED>|<RESET> *<MAGENTA>-<RESET><MAGENTA>-<RESET><RED>-<RESET><RED>.<RESET> octopus-merge
247 <RED>|<RESET> <YELLOW>|<RESET><BLUE>\<RESET> <MAGENTA>\<RESET> <RED>\<RESET>
248 <RED>|<RESET> <YELLOW>|<RESET><RED>_<RESET><BLUE>|<RESET><RED>_<RESET><MAGENTA>|<RESET><RED>/<RESET>
249 <RED>|<RESET><RED>/<RESET><YELLOW>|<RESET> <BLUE>|<RESET> <MAGENTA>|<RESET>
250 * <YELLOW>|<RESET> <BLUE>|<RESET> <MAGENTA>|<RESET> 4
251 <CYAN>|<RESET> <YELLOW>|<RESET> <BLUE>|<RESET> * 3
252 <CYAN>|<RESET> <YELLOW>|<RESET><CYAN>_<RESET><BLUE>|<RESET><CYAN>/<RESET>
253 <CYAN>|<RESET><CYAN>/<RESET><YELLOW>|<RESET> <BLUE>|<RESET>
254 <CYAN>|<RESET> <YELLOW>|<RESET> * 2
255 <CYAN>|<RESET> <YELLOW>|<RESET><CYAN>/<RESET>
256 <CYAN>|<RESET><CYAN>/<RESET><YELLOW>|<RESET>
257 <CYAN>|<RESET> * 1
258 <CYAN>|<RESET><CYAN>/<RESET>
259 * initial
260 EOF
Abhishek Kumarffe00552020-02-24 19:08:14 +0530261 test_cmp_colored_graph after-4 after-merge
Denton Liu11c21f22019-10-03 17:23:22 -0700262'
263
264test_expect_success 'log --graph with unrelated commit and octopus tip, no color' '
Abhishek Kumar989eea92020-02-24 19:08:13 +0530265 test_cmp_graph after-initial octopus-merge <<-\EOF
Denton Liu11c21f22019-10-03 17:23:22 -0700266 * after-initial
267 | *---. octopus-merge
268 | |\ \ \
269 | | | | * 4
270 | |_|_|/
271 |/| | |
272 | | | * 3
273 | |_|/
274 |/| |
275 | | * 2
276 | |/
277 |/|
278 | * 1
279 |/
280 * initial
281 EOF
Denton Liu11c21f22019-10-03 17:23:22 -0700282'
283
284test_expect_success 'log --graph with unrelated commit and octopus tip with colors' '
285 test_config log.graphColors red,green,yellow,blue,magenta,cyan &&
286 cat >expect.colors <<-\EOF &&
287 * after-initial
288 <RED>|<RESET> *<BLUE>-<RESET><BLUE>-<RESET><MAGENTA>-<RESET><MAGENTA>.<RESET> octopus-merge
289 <RED>|<RESET> <GREEN>|<RESET><YELLOW>\<RESET> <BLUE>\<RESET> <MAGENTA>\<RESET>
290 <RED>|<RESET> <GREEN>|<RESET> <YELLOW>|<RESET> <BLUE>|<RESET> * 4
291 <RED>|<RESET> <GREEN>|<RESET><RED>_<RESET><YELLOW>|<RESET><RED>_<RESET><BLUE>|<RESET><RED>/<RESET>
292 <RED>|<RESET><RED>/<RESET><GREEN>|<RESET> <YELLOW>|<RESET> <BLUE>|<RESET>
293 <RED>|<RESET> <GREEN>|<RESET> <YELLOW>|<RESET> * 3
294 <RED>|<RESET> <GREEN>|<RESET><RED>_<RESET><YELLOW>|<RESET><RED>/<RESET>
295 <RED>|<RESET><RED>/<RESET><GREEN>|<RESET> <YELLOW>|<RESET>
296 <RED>|<RESET> <GREEN>|<RESET> * 2
297 <RED>|<RESET> <GREEN>|<RESET><RED>/<RESET>
298 <RED>|<RESET><RED>/<RESET><GREEN>|<RESET>
299 <RED>|<RESET> * 1
300 <RED>|<RESET><RED>/<RESET>
301 * initial
302 EOF
Abhishek Kumarffe00552020-02-24 19:08:14 +0530303 test_cmp_colored_graph after-initial octopus-merge
Denton Liu11c21f22019-10-03 17:23:22 -0700304'
305
306test_expect_success 'log --graph with unrelated commit and octopus child, no color' '
Abhishek Kumar989eea92020-02-24 19:08:13 +0530307 test_cmp_graph after-initial after-merge <<-\EOF
Denton Liu11c21f22019-10-03 17:23:22 -0700308 * after-initial
309 | * after-merge
310 | *---. octopus-merge
311 | |\ \ \
312 | | | | * 4
313 | |_|_|/
314 |/| | |
315 | | | * 3
316 | |_|/
317 |/| |
318 | | * 2
319 | |/
320 |/|
321 | * 1
322 |/
323 * initial
324 EOF
Denton Liu11c21f22019-10-03 17:23:22 -0700325'
326
James Coglanbbb13e82019-10-15 23:47:59 +0000327test_expect_success 'log --graph with unrelated commit and octopus child with colors' '
Denton Liu11c21f22019-10-03 17:23:22 -0700328 test_config log.graphColors red,green,yellow,blue,magenta,cyan &&
329 cat >expect.colors <<-\EOF &&
330 * after-initial
331 <RED>|<RESET> * after-merge
332 <RED>|<RESET> *<MAGENTA>-<RESET><MAGENTA>-<RESET><CYAN>-<RESET><CYAN>.<RESET> octopus-merge
333 <RED>|<RESET> <YELLOW>|<RESET><BLUE>\<RESET> <MAGENTA>\<RESET> <CYAN>\<RESET>
334 <RED>|<RESET> <YELLOW>|<RESET> <BLUE>|<RESET> <MAGENTA>|<RESET> * 4
335 <RED>|<RESET> <YELLOW>|<RESET><RED>_<RESET><BLUE>|<RESET><RED>_<RESET><MAGENTA>|<RESET><RED>/<RESET>
336 <RED>|<RESET><RED>/<RESET><YELLOW>|<RESET> <BLUE>|<RESET> <MAGENTA>|<RESET>
337 <RED>|<RESET> <YELLOW>|<RESET> <BLUE>|<RESET> * 3
338 <RED>|<RESET> <YELLOW>|<RESET><RED>_<RESET><BLUE>|<RESET><RED>/<RESET>
339 <RED>|<RESET><RED>/<RESET><YELLOW>|<RESET> <BLUE>|<RESET>
340 <RED>|<RESET> <YELLOW>|<RESET> * 2
341 <RED>|<RESET> <YELLOW>|<RESET><RED>/<RESET>
342 <RED>|<RESET><RED>/<RESET><YELLOW>|<RESET>
343 <RED>|<RESET> * 1
344 <RED>|<RESET><RED>/<RESET>
345 * initial
346 EOF
Abhishek Kumarffe00552020-02-24 19:08:14 +0530347 test_cmp_colored_graph after-initial after-merge
Denton Liu11c21f22019-10-03 17:23:22 -0700348'
349
Noam Postavsky04005832018-09-01 20:07:16 -0400350test_done