git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH 1/2] graph: simplify graph_padding_line()

From
René Scharfe <l.s.r@web.de>
Date
Sep 20, 2014, 18:29 UTC
Message-ID
<541DC7A1.1000509@web.de>
Deduplicate code common to both branches of if statements.
Signed-off-by: Rene Scharfe <l.s.r@web.de>
---
 graph.c | 17 ++++-------------
 1 file changed, 4 insertions(+), 13 deletions(-)
diff --git a/graph.c b/graph.c
index dfb99f6..52605e4 100644
--- a/graph.c
+++ b/graph.c
@@ -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);
-- 
2.1.1
Next: René Scharfe
Message 1 of 2 in “graph: simplify graph_padding_line()”
  1. 1/2 graph: simplify graph_padding_line()René Scharfe, Sep 20, 2014
  2. René ScharfeSep 20, 2014

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.