summaryrefslogtreecommitdiff
path: root/graph.c
diff options
context:
space:
mode:
authorDerrick Stolee <dstolee@microsoft.com>2020-01-07 21:27:02 (GMT)
committerJunio C Hamano <gitster@pobox.com>2020-01-08 17:37:18 (GMT)
commita1087c93677bc0304c98f14915b1843e470e4a55 (patch)
treeb9c21c2068b0dd20c2068fc2bea15a39f4ca6c83 /graph.c
parent0d251c3291e4618325465a06186556b18be26adf (diff)
downloadgit-a1087c93677bc0304c98f14915b1843e470e4a55.zip
git-a1087c93677bc0304c98f14915b1843e470e4a55.tar.gz
git-a1087c93677bc0304c98f14915b1843e470e4a55.tar.bz2
graph: fix lack of color in horizontal lines
In some cases, horizontal lines in rendered graphs can lose their coloring. This is due to a use of graph_line_addch() instead of graph_line_write_column(). Using a ternary operator to pick the character is nice for compact code, but we actually need a column to provide the color. Add a test to t4215-log-skewed-merges.sh to prevent regression. Reported-by: Jeff King <peff@peff.net> Signed-off-by: Derrick Stolee <dstolee@microsoft.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'graph.c')
-rw-r--r--graph.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/graph.c b/graph.c
index f514ed3..aaf9706 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;
}
/*