From d0c4f19ff162e63d5d23d456d0fc4fe9a32029ee Mon Sep 17 00:00:00 2001 From: Noam Postavsky Date: Sat, 23 Jun 2018 16:56:43 -0400 Subject: [PATCH v1] log: Fix coloring of certain octupus merge shapes For octopus merges where the first parent edge immediately merges into the next column to the left: | | *-. | | |\ \ | |/ / / then the number of columns should be one less than the usual case: | *-. | |\ \ | | | * Signed-off-by: Noam Postavsky --- graph.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/graph.c b/graph.c index e1f6d3bdd..c919c86e8 100644 --- a/graph.c +++ b/graph.c @@ -856,12 +856,16 @@ static int graph_draw_octopus_merge(struct git_graph *graph, int col_num, i; int num_dashes = ((graph->num_parents - dashless_commits) * 2) - 1; - for (i = 0; i < num_dashes; i++) { - col_num = (i / 2) + dashless_commits + graph->commit_index; + int first_col = dashless_commits + graph->commit_index; + int last_col = first_col + (num_dashes / 2); + if (last_col >= graph->num_new_columns) { + first_col--; + last_col--; + } + for (i = 0, col_num = first_col; i < num_dashes; i++, col_num++) { strbuf_write_column(sb, &graph->new_columns[col_num], '-'); } - col_num = (i / 2) + dashless_commits + graph->commit_index; - strbuf_write_column(sb, &graph->new_columns[col_num], '.'); + strbuf_write_column(sb, &graph->new_columns[last_col], '.'); return num_dashes + 1; } -- 2.11.0