Skip to content

Commit 11c21f2

Browse files
Denton-Lgitster
authored andcommitted
t4214: demonstrate octopus graph coloring failure
The graph coloring logic for octopus merges currently has a bug. This can be seen git.git with 74c7cfa (Merge of http://members.cox.net/junkio/git-jc.git, 2005-05-05), whose second child is 211232b (Octopus merge of the following five patches., 2005-05-05). If one runs git log --graph 74c7cfa one can see that the octopus merge is colored incorrectly. In particular, the horizontal dashes are off by one color. Each horizontal dash should be the color of the line to their bottom-right. Instead, they are currently the color of the line to their bottom. Demonstrate this breakage with a few sets of test cases. These test cases should show not only simple cases of the bug occuring but trickier situations that may not be handled properly in any attempt to fix the bug. While we're at it, include a passing test case as a canary in case an attempt to fix the bug breaks existing operation. Signed-off-by: Denton Liu <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 25eb905 commit 11c21f2

File tree

1 file changed

+281
-1
lines changed

1 file changed

+281
-1
lines changed

t/t4214-log-graph-octopus.sh

Lines changed: 281 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,13 @@ test_expect_success 'set up merge history' '
1414
done &&
1515
git checkout 1 -b merge &&
1616
test_merge octopus-merge 1 2 3 4 &&
17+
test_commit after-merge &&
1718
git checkout 1 -b L &&
18-
test_commit left
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
1924
'
2025

2126
test_expect_success 'log --graph with tricky octopus merge, no color' '
@@ -98,4 +103,279 @@ test_expect_success 'log --graph with normal octopus merge with colors' '
98103
test_decode_color <actual.colors.raw | sed "s/ *\$//" >actual.colors &&
99104
test_cmp expect.colors actual.colors
100105
'
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 &&
377+
test_decode_color <actual.colors.raw | sed "s/ *\$//" >actual.colors &&
378+
test_cmp expect.colors actual.colors
379+
'
380+
101381
test_done

0 commit comments

Comments
 (0)