diff options
author | Junio C Hamano <gitster@pobox.com> | 2016-10-06 14:53:11 -0700 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2016-10-06 14:53:11 -0700 |
commit | cb52426d9af9129c052529c5207fc014c38bd46f (patch) | |
tree | dadac26cbb78c099d68b4b4a39103e9f4f5cb0ed | |
parent | 3b01d9aee0d2a54f0dd4704e22dfb49ae08203d5 (diff) | |
parent | 16477935245a522d99d0dd7e346638c02542f1d0 (diff) | |
download | git-cb52426d9af9129c052529c5207fc014c38bd46f.tar.gz |
Merge branch 'jk/graph-padding-fix'
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
-rw-r--r-- | graph.c | 16 |
1 files changed, 12 insertions, 4 deletions
@@ -1175,6 +1175,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); @@ -1190,14 +1191,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 |