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
10 .
"$TEST_DIRECTORY"/lib-log-graph.sh
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 &&
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 $?
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 &&
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
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 &&
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>
68 <MAGENTA>|<RESET><MAGENTA>/<RESET>
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
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>
102 <BLUE>|<RESET><BLUE>/<RESET>
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
125 test_expect_success
'log --graph with normal octopus and child merge with colors' '
126 cat >expect.colors <<-\EOF &&
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>
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
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 &&
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>
173 <CYAN>|<RESET><CYAN>/<RESET>
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
182 | *---. octopus-merge
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 &&
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>
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
225 | *---. octopus-merge
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 &&
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>
259 <CYAN>|<RESET><CYAN>/<RESET>
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
268 | *---. octopus-merge
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 &&
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>
301 <RED>|<RESET><RED>/<RESET>
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
311 | *---. octopus-merge
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 &&
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>
345 <RED>|<RESET><RED>/<RESET>
348 test_cmp_colored_graph after-initial after-merge