Skip to content

Commit 785b0ce

Browse files
committed
Merge branch 'jk/graph-padding-fix' into pu
* jk/graph-padding-fix: graph: fix extra spaces in graph_padding_line
2 parents 0fbd36e + 1647793 commit 785b0ce

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

graph.c

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1175,6 +1175,7 @@ int graph_next_line(struct git_graph *graph, struct strbuf *sb)
11751175
static void graph_padding_line(struct git_graph *graph, struct strbuf *sb)
11761176
{
11771177
int i;
1178+
int chars_written = 0;
11781179

11791180
if (graph->state != GRAPH_COMMIT) {
11801181
graph_next_line(graph, sb);
@@ -1190,14 +1191,21 @@ static void graph_padding_line(struct git_graph *graph, struct strbuf *sb)
11901191
*/
11911192
for (i = 0; i < graph->num_columns; i++) {
11921193
struct column *col = &graph->columns[i];
1194+
11931195
strbuf_write_column(sb, col, '|');
1194-
if (col->commit == graph->commit && graph->num_parents > 2)
1195-
strbuf_addchars(sb, ' ', (graph->num_parents - 2) * 2);
1196-
else
1196+
chars_written++;
1197+
1198+
if (col->commit == graph->commit && graph->num_parents > 2) {
1199+
int len = (graph->num_parents - 2) * 2;
1200+
strbuf_addchars(sb, ' ', len);
1201+
chars_written += len;
1202+
} else {
11971203
strbuf_addch(sb, ' ');
1204+
chars_written++;
1205+
}
11981206
}
11991207

1200-
graph_pad_horizontally(graph, sb, graph->num_columns);
1208+
graph_pad_horizontally(graph, sb, chars_written);
12011209

12021210
/*
12031211
* Update graph->prev_state since we have output a padding line

0 commit comments

Comments
 (0)