diff --git a/graph.c b/graph.c index 66ae18add8..aaf97069bd 100644 --- a/graph.c +++ b/graph.c @@ -1063,7 +1063,7 @@ static void graph_output_post_merge_line(struct git_graph *graph, struct graph_l int i, j; struct commit_list *first_parent = first_interesting_parent(graph); - int seen_parent = 0; + struct column *parent_col = NULL; /* * Output the post-merge row @@ -1117,12 +1117,17 @@ static void graph_output_post_merge_line(struct git_graph *graph, struct graph_l graph_line_addch(line, ' '); } else { graph_line_write_column(line, col, '|'); - if (graph->merge_layout != 0 || i != graph->commit_index - 1) - graph_line_addch(line, seen_parent ? '_' : ' '); + if (graph->merge_layout != 0 || i != graph->commit_index - 1) { + if (parent_col) + graph_line_write_column( + line, parent_col, '_'); + else + graph_line_addch(line, ' '); + } } if (col_commit == first_parent->item) - seen_parent = 1; + parent_col = col; } /* @@ -1219,13 +1224,9 @@ static void graph_output_collapsing_line(struct git_graph *graph, struct graph_l * * The space just to the left of this * branch should always be empty. - * - * The branch to the left of that space - * should be our eventual target. */ assert(graph->mapping[i - 1] > target); assert(graph->mapping[i - 2] < 0); - assert(graph->mapping[i - 3] == target); graph->mapping[i - 2] = target; /* * Mark this branch as the horizontal edge to diff --git a/t/t4215-log-skewed-merges.sh b/t/t4215-log-skewed-merges.sh index 18709a723e..5661ed5881 100755 --- a/t/t4215-log-skewed-merges.sh +++ b/t/t4215-log-skewed-merges.sh @@ -240,4 +240,75 @@ test_expect_success 'log --graph with octopus merge with column joining its penu EOF ' +test_expect_success 'log --graph with multiple tips' ' + git checkout --orphan 6_1 && + test_commit 6_A && + git branch 6_2 && + git branch 6_4 && + test_commit 6_B && + git branch 6_3 && + test_commit 6_C && + git checkout 6_2 && test_commit 6_D && + git checkout 6_3 && test_commit 6_E && + git checkout -b 6_5 6_1 && + git merge --no-ff 6_2 -m 6_F && + git checkout 6_4 && test_commit 6_G && + git checkout 6_3 && + git merge --no-ff 6_4 -m 6_H && + git checkout 6_1 && + git merge --no-ff 6_2 -m 6_I && + + check_graph 6_1 6_3 6_5 <<-\EOF + * 6_I + |\ + | | * 6_H + | | |\ + | | | * 6_G + | | * | 6_E + | | | | * 6_F + | |_|_|/| + |/| | |/ + | | |/| + | |/| | + | * | | 6_D + | | |/ + | |/| + * | | 6_C + | |/ + |/| + * | 6_B + |/ + * 6_A + EOF +' + +test_expect_success 'log --graph with multiple tips and colors' ' + test_config log.graphColors red,green,yellow,blue,magenta,cyan && + cat >expect.colors <<-\EOF && + * 6_I + |\ + | | * 6_H + | | |\ + | | | * 6_G + | | | | * 6_F + | |_|_|/| + |/| | |/ + | | |/| + | |/| | + | | * | 6_E + | * | | 6_D + | | |/ + | |/| + * | | 6_C + | |/ + |/| + * | 6_B + |/ + * 6_A + EOF + git log --color=always --graph --date-order --pretty=tformat:%s 6_1 6_3 6_5 >actual.colors.raw && + test_decode_color actual.colors && + test_cmp expect.colors actual.colors +' + test_done