Merge branch 'jc/exclude-first-parent-seen' into jch

Traversals with '--exclude-first-parent-only' have been corrected to
properly stop after the first parent even when it has already been
marked as SEEN.

* jc/exclude-first-parent-seen:
  revision: honor --exclude-first-parent-only with SEEN first parent
jch
Junio C Hamano 2026-07-24 14:40:40 -07:00
commit 9aed6b0292
2 changed files with 26 additions and 2 deletions

View File

@ -1153,12 +1153,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 (queue)
prio_queue_put(queue, p);

View File

@ -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