Skip to contentSkip to conversation

graph: simplify graph_padding_line()

PATCH In review René Scharfe 1 participant 2 messages Jun 15, 2016

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 graph: simplify graph_padding_line()

Deduplicate code common to both branches of if statements.

---
 graph.c | 17 ++++-------------
 1 file changed, 4 insertions(+), 13 deletions(-)
graph.c +4 -13
index dfb99f6..52605e4 100644
@@ -1161,20 +1161,11 @@ 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];
-		struct commit *col_commit = col->commit;
-		if (col_commit == graph->commit) {
-			strbuf_write_column(sb, col, '|');
-
-			if (graph->num_parents < 3)
-				strbuf_addch(sb, ' ');
-			else {
-				int num_spaces = ((graph->num_parents - 2) * 2);
-				strbuf_addchars(sb, ' ', num_spaces);
-			}
-		} else {
-			strbuf_write_column(sb, col, '|');
+		strbuf_write_column(sb, col, '|');
+		if (col->commit == graph->commit && graph->num_parents > 2)
+			strbuf_addchars(sb, ' ', (graph->num_parents - 2) * 2);
+		else
 			strbuf_addch(sb, ' ');
-		}
 	}
 
 	graph_pad_horizontally(graph, sb, graph->num_columns);
Signature · 1 line
2.1.1
#1 lore raw

Am 20.09.2014 um 20:29 schrieb René Scharfe:

Quoted 1 line

Deduplicate code common to both branches of if statements.

There is no 2/2, this patch is the only one at this time.

René