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

[PATCH] revision: honor --exclude-first-parent-only with SEEN first parent

From
Junio C Hamano <gitster@pobox.com>
Date
Jul 22, 2026, 17:03 UTC
Message-ID
<xmqqbjbzq7n2.fsf@gitster.g>

The '--exclude-first-parent-only' option instructs the revision walker to follow only the first parent of a merge commit to propagate down the UNINTERESTING bit.

However, if the first parent has already been marked SEEN (for example, because it was explicitly specified on the command line), process_parents() skips it with a 'continue' statement. But the loop then continues on to process the second parent, because the check for the '--exclude-first-parent-only' option is near the end of the loop, which the 'continue' statement skips. Consequently, we end up marking the second parent as UNINTERESTING.

Break out of the loop instead of continuing when the first parent is already SEEN or fails to parse. This ensures that we do not process subsequent parents and mark them as UNINTERESTING.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
Reviewed-by: Jerry Zhang <jerry@skydio.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
 * This time with a commit log message.
 revision.c                   | 10 ++++++++--
 t/t6012-rev-list-simplify.sh | 18 ++++++++++++++++++
 2 files changed, 26 insertions(+), 2 deletions(-)
diff --git a/revision.c b/revision.c
index 599b3a66c3..9b30663669 100644
--- a/revision.c
+++ b/revision.c
@@ -1152,12 +1152,18 @@ static int process_parents(struct rev_info *revs, struct commit *commit,
 			if (p)
 				p->object.flags |= UNINTERESTING |
 						   CHILD_VISITED;
-			if (repo_parse_commit_gently(revs->repo, p, 1) < 0)
+			if (repo_parse_commit_gently(revs->repo, p, 1) < 0) {
+				if (revs->exclude_first_parent_only)
+					break;
 				continue;
+			}
 			if (p->parents)
 				mark_parents_uninteresting(revs, p);
-			if (p->object.flags & SEEN)
+			if (p->object.flags & SEEN) {
+				if (revs->exclude_first_parent_only)
+					break;
 				continue;
+			}
 			p->object.flags |= (SEEN | NOT_USER_GIVEN);
 			if (list)
 				commit_list_insert_by_date(p, list);
diff --git a/t/t6012-rev-list-simplify.sh b/t/t6012-rev-list-simplify.sh
index 4cecb6224c..2284bbba12 100755
--- a/t/t6012-rev-list-simplify.sh
+++ b/t/t6012-rev-list-simplify.sh
@@ -285,4 +285,22 @@ test_expect_success 'log --graph --simplify-merges --show-pulls' '
 	test_cmp expect actual
 '
 
+test_expect_success 'exclude-first-parent-only with parent already seen' '
+	git checkout --orphan test-seen &&
+	git rm -rf . &&
+	test_commit r1 &&
+	git checkout -b branch-f &&
+	test_commit f &&
+	git checkout test-seen &&
+	git merge --no-ff --no-edit -m r2 branch-f &&
+	git tag r2 &&
+
+	git rev-list --exclude-first-parent-only f ^r2 >actual &&
+	git rev-parse f >expect &&
+	test_cmp expect actual &&
+
+	git rev-list --exclude-first-parent-only f r1 ^r2 >actual2 &&
+	test_cmp expect actual2
+'
+
 test_done
-- 
2.55.0-496-g61638ae030
Message 1 of 1 in “revision: honor --exclude-first-parent-only with SEEN first parent”
  1. revision: honor --exclude-first-parent-only with SEEN first parentJunio C Hamano, Jul 22, 2026

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.