From: Junio C Hamano Date: Tue, 11 Oct 2016 21:19:03 +0000 (-0700) Subject: Merge branch 'jk/graph-padding-fix' into maint X-Git-Tag: v2.10.2~35 X-Git-Url: https://git.lorimer.id.au/gitweb.git/diff_plain/18fd96f1d706357704c8d51f12b9412cd424ac49?hp=1f253d88face02b68a86fae36e6722c9ebc73856 Merge branch 'jk/graph-padding-fix' into maint The "graph" API used in "git log --graph" miscounted the number of output columns consumed so far when drawing a padding line, which has been fixed; this did not affect any existing code as nobody tried to write anything after the padding on such a line, though. * jk/graph-padding-fix: graph: fix extra spaces in graph_padding_line --- diff --git a/graph.c b/graph.c index dd1720148d..4200f747e7 100644 --- a/graph.c +++ b/graph.c @@ -1145,6 +1145,7 @@ int graph_next_line(struct git_graph *graph, struct strbuf *sb) static void graph_padding_line(struct git_graph *graph, struct strbuf *sb) { int i; + int chars_written = 0; if (graph->state != GRAPH_COMMIT) { graph_next_line(graph, sb); @@ -1160,14 +1161,21 @@ static void graph_padding_line(struct git_graph *graph, struct strbuf *sb) */ for (i = 0; i < graph->num_columns; i++) { struct column *col = &graph->columns[i]; + strbuf_write_column(sb, col, '|'); - if (col->commit == graph->commit && graph->num_parents > 2) - strbuf_addchars(sb, ' ', (graph->num_parents - 2) * 2); - else + chars_written++; + + if (col->commit == graph->commit && graph->num_parents > 2) { + int len = (graph->num_parents - 2) * 2; + strbuf_addchars(sb, ' ', len); + chars_written += len; + } else { strbuf_addch(sb, ' '); + chars_written++; + } } - graph_pad_horizontally(graph, sb, graph->num_columns); + graph_pad_horizontally(graph, sb, chars_written); /* * Update graph->prev_state since we have output a padding line