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

[PATCH 1/6] graph: output padding for merge subsequent parents

From
John Keeping <john@keeping.me.uk>
Date
Feb 7, 2013, 20:15 UTC
Message-ID
<b98eb2bfe2b022ddf1afbe9f7123accfe068e8c9.1360267849.git.john@keeping.me.uk>
In-Reply-To
<cover.1360267849.git.john@keeping.me.uk>

When showing merges in git-log, the same commit is shown once for each parent. Combined with "--graph" this results in graph_show_commit() being called once for each parent without graph_update() being called.

Currently graph_show_commit() does not print anything on subsequent invocations for the same commit (this was changed by commit 656197a - "graph.c: infinite loop in git whatchanged --graph -m" from the previous behaviour of looping infinitely).

Change this so that if the graph code believes it has already shown the commit it prints a single padding line.

Signed-off-by: John Keeping <john@keeping.me.uk>
---
 graph.c | 10 ++++++++++
 1 file changed, 10 insertions(+)
diff --git a/graph.c b/graph.c
index 391a712..2a3fc5c 100644
--- a/graph.c
+++ b/graph.c
@@ -1227,6 +1227,16 @@ void graph_show_commit(struct git_graph *graph)
 	if (!graph)
 		return;
 
+	/*
+	 * When showing a diff of a merge against each of its parents, we
+	 * are called once for each parent without graph_update having been
+	 * called.  In this case, simply output a single padding line.
+	 */
+	if (graph_is_commit_finished(graph)) {
+		graph_show_padding(graph);
+		shown_commit_line = 1;
+	}
+
 	while (!shown_commit_line && !graph_is_commit_finished(graph)) {
 		shown_commit_line = graph_next_line(graph, &msgbuf);
 		fwrite(msgbuf.buf, sizeof(char), msgbuf.len, stdout);
-- 
1.8.1.2
Previous: John KeepingNext: John Keeping
Message 2 of 9 in “Improve "git log --graph" output of merges”
  1. 0/6 Improve "git log --graph" output of mergesJohn Keeping, Feb 7, 2013
  2. 1/6 graph: output padding for merge subsequent parentsJohn Keeping, Feb 7, 2013
  3. John KeepingFeb 8, 2013
  4. 2/6 diff: write prefix to the correct fileJohn Keeping, Feb 7, 2013
  5. 3/6 diff.c: make constant string arguments constJohn Keeping, Feb 7, 2013
  6. 4/6 diff: add diff_line_prefix functionJohn Keeping, Feb 7, 2013
  7. 5/6 diff.c: use diff_line_prefix() where applicableJohn Keeping, Feb 7, 2013
  8. 6/6 combine-diff.c: teach combined diffs about line prefixJohn Keeping, Feb 7, 2013
  9. Junio C HamanoFeb 7, 2013

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.