Skip to content

Commit 1f5f3ff

Browse files
committed
Merge branch 'ds/graph-assert-fix'
Since recent updates to the log graph rendering code, drawing certain merges started triggering an assert on a condition that would no longer hold true, which has been corrected. * ds/graph-assert-fix: graph: fix lack of color in horizontal lines graph: drop assert() for merge with two collapsing parents
2 parents a4e4140 + a1087c9 commit 1f5f3ff

File tree

2 files changed

+80
-8
lines changed

2 files changed

+80
-8
lines changed

graph.c

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1063,7 +1063,7 @@ static void graph_output_post_merge_line(struct git_graph *graph, struct graph_l
10631063
int i, j;
10641064

10651065
struct commit_list *first_parent = first_interesting_parent(graph);
1066-
int seen_parent = 0;
1066+
struct column *parent_col = NULL;
10671067

10681068
/*
10691069
* Output the post-merge row
@@ -1117,12 +1117,17 @@ static void graph_output_post_merge_line(struct git_graph *graph, struct graph_l
11171117
graph_line_addch(line, ' ');
11181118
} else {
11191119
graph_line_write_column(line, col, '|');
1120-
if (graph->merge_layout != 0 || i != graph->commit_index - 1)
1121-
graph_line_addch(line, seen_parent ? '_' : ' ');
1120+
if (graph->merge_layout != 0 || i != graph->commit_index - 1) {
1121+
if (parent_col)
1122+
graph_line_write_column(
1123+
line, parent_col, '_');
1124+
else
1125+
graph_line_addch(line, ' ');
1126+
}
11221127
}
11231128

11241129
if (col_commit == first_parent->item)
1125-
seen_parent = 1;
1130+
parent_col = col;
11261131
}
11271132

11281133
/*
@@ -1219,13 +1224,9 @@ static void graph_output_collapsing_line(struct git_graph *graph, struct graph_l
12191224
*
12201225
* The space just to the left of this
12211226
* branch should always be empty.
1222-
*
1223-
* The branch to the left of that space
1224-
* should be our eventual target.
12251227
*/
12261228
assert(graph->mapping[i - 1] > target);
12271229
assert(graph->mapping[i - 2] < 0);
1228-
assert(graph->mapping[i - 3] == target);
12291230
graph->mapping[i - 2] = target;
12301231
/*
12311232
* Mark this branch as the horizontal edge to

t/t4215-log-skewed-merges.sh

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -240,4 +240,75 @@ test_expect_success 'log --graph with octopus merge with column joining its penu
240240
EOF
241241
'
242242

243+
test_expect_success 'log --graph with multiple tips' '
244+
git checkout --orphan 6_1 &&
245+
test_commit 6_A &&
246+
git branch 6_2 &&
247+
git branch 6_4 &&
248+
test_commit 6_B &&
249+
git branch 6_3 &&
250+
test_commit 6_C &&
251+
git checkout 6_2 && test_commit 6_D &&
252+
git checkout 6_3 && test_commit 6_E &&
253+
git checkout -b 6_5 6_1 &&
254+
git merge --no-ff 6_2 -m 6_F &&
255+
git checkout 6_4 && test_commit 6_G &&
256+
git checkout 6_3 &&
257+
git merge --no-ff 6_4 -m 6_H &&
258+
git checkout 6_1 &&
259+
git merge --no-ff 6_2 -m 6_I &&
260+
261+
check_graph 6_1 6_3 6_5 <<-\EOF
262+
* 6_I
263+
|\
264+
| | * 6_H
265+
| | |\
266+
| | | * 6_G
267+
| | * | 6_E
268+
| | | | * 6_F
269+
| |_|_|/|
270+
|/| | |/
271+
| | |/|
272+
| |/| |
273+
| * | | 6_D
274+
| | |/
275+
| |/|
276+
* | | 6_C
277+
| |/
278+
|/|
279+
* | 6_B
280+
|/
281+
* 6_A
282+
EOF
283+
'
284+
285+
test_expect_success 'log --graph with multiple tips and colors' '
286+
test_config log.graphColors red,green,yellow,blue,magenta,cyan &&
287+
cat >expect.colors <<-\EOF &&
288+
* 6_I
289+
<RED>|<RESET><GREEN>\<RESET>
290+
<RED>|<RESET> <GREEN>|<RESET> * 6_H
291+
<RED>|<RESET> <GREEN>|<RESET> <YELLOW>|<RESET><BLUE>\<RESET>
292+
<RED>|<RESET> <GREEN>|<RESET> <YELLOW>|<RESET> * 6_G
293+
<RED>|<RESET> <GREEN>|<RESET> <YELLOW>|<RESET> <BLUE>|<RESET> * 6_F
294+
<RED>|<RESET> <GREEN>|<RESET><RED>_<RESET><YELLOW>|<RESET><RED>_<RESET><BLUE>|<RESET><RED>/<RESET><GREEN>|<RESET>
295+
<RED>|<RESET><RED>/<RESET><GREEN>|<RESET> <YELLOW>|<RESET> <BLUE>|<RESET><GREEN>/<RESET>
296+
<RED>|<RESET> <GREEN>|<RESET> <YELLOW>|<RESET><GREEN>/<RESET><BLUE>|<RESET>
297+
<RED>|<RESET> <GREEN>|<RESET><GREEN>/<RESET><YELLOW>|<RESET> <BLUE>|<RESET>
298+
<RED>|<RESET> <GREEN>|<RESET> * <BLUE>|<RESET> 6_E
299+
<RED>|<RESET> * <CYAN>|<RESET> <BLUE>|<RESET> 6_D
300+
<RED>|<RESET> <BLUE>|<RESET> <CYAN>|<RESET><BLUE>/<RESET>
301+
<RED>|<RESET> <BLUE>|<RESET><BLUE>/<RESET><CYAN>|<RESET>
302+
* <BLUE>|<RESET> <CYAN>|<RESET> 6_C
303+
<CYAN>|<RESET> <BLUE>|<RESET><CYAN>/<RESET>
304+
<CYAN>|<RESET><CYAN>/<RESET><BLUE>|<RESET>
305+
* <BLUE>|<RESET> 6_B
306+
<BLUE>|<RESET><BLUE>/<RESET>
307+
* 6_A
308+
EOF
309+
git log --color=always --graph --date-order --pretty=tformat:%s 6_1 6_3 6_5 >actual.colors.raw &&
310+
test_decode_color <actual.colors.raw | sed "s/ *\$//" >actual.colors &&
311+
test_cmp expect.colors actual.colors
312+
'
313+
243314
test_done

0 commit comments

Comments
 (0)