Skip to content

Commit 0176e7a

Browse files
rscharfegitster
authored andcommitted
graph: simplify graph_padding_line()
Deduplicate code common to both branches of if statements. Signed-off-by: Rene Scharfe <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 97b8860 commit 0176e7a

File tree

1 file changed

+4
-13
lines changed

1 file changed

+4
-13
lines changed

graph.c

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1161,20 +1161,11 @@ static void graph_padding_line(struct git_graph *graph, struct strbuf *sb)
11611161
*/
11621162
for (i = 0; i < graph->num_columns; i++) {
11631163
struct column *col = &graph->columns[i];
1164-
struct commit *col_commit = col->commit;
1165-
if (col_commit == graph->commit) {
1166-
strbuf_write_column(sb, col, '|');
1167-
1168-
if (graph->num_parents < 3)
1169-
strbuf_addch(sb, ' ');
1170-
else {
1171-
int num_spaces = ((graph->num_parents - 2) * 2);
1172-
strbuf_addchars(sb, ' ', num_spaces);
1173-
}
1174-
} else {
1175-
strbuf_write_column(sb, col, '|');
1164+
strbuf_write_column(sb, col, '|');
1165+
if (col->commit == graph->commit && graph->num_parents > 2)
1166+
strbuf_addchars(sb, ' ', (graph->num_parents - 2) * 2);
1167+
else
11761168
strbuf_addch(sb, ' ');
1177-
}
11781169
}
11791170

11801171
graph_pad_horizontally(graph, sb, graph->num_columns);

0 commit comments

Comments
 (0)