Skip to content

Commit 5b900fb

Browse files
committed
Merge branch 'dl/octopus-graph-bug'
"git log --graph" for an octopus merge is sometimes colored incorrectly, which is demonstrated and documented but not yet fixed. * dl/octopus-graph-bug: t4214: demonstrate octopus graph coloring failure t4214: explicitly list tags in log t4214: generate expect in their own test cases t4214: use test_merge test-lib: let test_merge() perform octopus merges
2 parents 16d9d71 + 11c21f2 commit 5b900fb

File tree

2 files changed

+308
-27
lines changed

2 files changed

+308
-27
lines changed

t/t4214-log-graph-octopus.sh

Lines changed: 304 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,25 @@ test_description='git log --graph of skewed left octopus merge.'
55
. ./test-lib.sh
66

77
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' '
827
cat >expect.uncolored <<-\EOF &&
928
* left
1029
| *---. octopus-merge
@@ -19,6 +38,13 @@ test_expect_success 'set up merge history' '
1938
|/
2039
* initial
2140
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 &&
2248
cat >expect.colors <<-\EOF &&
2349
* left
2450
<RED>|<RESET> *<BLUE>-<RESET><BLUE>-<RESET><MAGENTA>-<RESET><MAGENTA>.<RESET> octopus-merge
@@ -33,33 +59,11 @@ test_expect_success 'set up merge history' '
3359
<MAGENTA>|<RESET><MAGENTA>/<RESET>
3460
* initial
3561
EOF
36-
test_commit initial &&
37-
for i in 1 2 3 4 ; do
38-
git checkout master -b $i || return $?
39-
# Make tag name different from branch name, to avoid
40-
# ambiguity error when calling checkout.
41-
test_commit $i $i $i tag$i || return $?
42-
done &&
43-
git checkout 1 -b merge &&
44-
test_tick &&
45-
git merge -m octopus-merge 1 2 3 4 &&
46-
git checkout 1 -b L &&
47-
test_commit left
48-
'
49-
50-
test_expect_success 'log --graph with tricky octopus merge with colors' '
51-
test_config log.graphColors red,green,yellow,blue,magenta,cyan &&
52-
git log --color=always --graph --date-order --pretty=tformat:%s --all >actual.colors.raw &&
62+
git log --color=always --graph --date-order --pretty=tformat:%s left octopus-merge >actual.colors.raw &&
5363
test_decode_color <actual.colors.raw | sed "s/ *\$//" >actual.colors &&
5464
test_cmp expect.colors actual.colors
5565
'
5666

57-
test_expect_success 'log --graph with tricky octopus merge, no color' '
58-
git log --color=never --graph --date-order --pretty=tformat:%s --all >actual.raw &&
59-
sed "s/ *\$//" actual.raw >actual &&
60-
test_cmp expect.uncolored actual
61-
'
62-
6367
# Repeat the previous two tests with "normal" octopus merge (i.e.,
6468
# without the first parent skewing to the "left" branch column).
6569

@@ -76,7 +80,7 @@ test_expect_success 'log --graph with normal octopus merge, no color' '
7680
|/
7781
* initial
7882
EOF
79-
git log --color=never --graph --date-order --pretty=tformat:%s merge >actual.raw &&
83+
git log --color=never --graph --date-order --pretty=tformat:%s octopus-merge >actual.raw &&
8084
sed "s/ *\$//" actual.raw >actual &&
8185
test_cmp expect.uncolored actual
8286
'
@@ -95,8 +99,283 @@ test_expect_success 'log --graph with normal octopus merge with colors' '
9599
* initial
96100
EOF
97101
test_config log.graphColors red,green,yellow,blue,magenta,cyan &&
98-
git log --color=always --graph --date-order --pretty=tformat:%s merge >actual.colors.raw &&
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 &&
99377
test_decode_color <actual.colors.raw | sed "s/ *\$//" >actual.colors &&
100378
test_cmp expect.colors actual.colors
101379
'
380+
102381
test_done

t/test-lib-functions.sh

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -228,9 +228,11 @@ test_commit () {
228228
# can be a tag pointing to the commit-to-merge.
229229

230230
test_merge () {
231+
label="$1" &&
232+
shift &&
231233
test_tick &&
232-
git merge -m "$1" "$2" &&
233-
git tag "$1"
234+
git merge -m "$label" "$@" &&
235+
git tag "$label"
234236
}
235237

236238
# Efficiently create <nr> commits, each with a unique number (from 1 to <nr>

0 commit comments

Comments
 (0)