Skip to content

Commit a34e661

Browse files
committed
Merge branch 'jc/exclude-first-parent-seen' into seen
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
2 parents 46ce81e + 47382f7 commit a34e661

2 files changed

Lines changed: 26 additions & 2 deletions

File tree

revision.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1167,12 +1167,18 @@ static int process_parents(struct rev_info *revs, struct commit *commit,
11671167
if (p)
11681168
p->object.flags |= UNINTERESTING |
11691169
CHILD_VISITED;
1170-
if (repo_parse_commit_gently(revs->repo, p, 1) < 0)
1170+
if (repo_parse_commit_gently(revs->repo, p, 1) < 0) {
1171+
if (revs->exclude_first_parent_only)
1172+
break;
11711173
continue;
1174+
}
11721175
if (p->parents)
11731176
mark_parents_uninteresting(revs, p);
1174-
if (p->object.flags & SEEN)
1177+
if (p->object.flags & SEEN) {
1178+
if (revs->exclude_first_parent_only)
1179+
break;
11751180
continue;
1181+
}
11761182
p->object.flags |= (SEEN | NOT_USER_GIVEN);
11771183
if (queue)
11781184
prio_queue_put(queue, p);

t/t6012-rev-list-simplify.sh

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -285,4 +285,22 @@ test_expect_success 'log --graph --simplify-merges --show-pulls' '
285285
test_cmp expect actual
286286
'
287287

288+
test_expect_success 'exclude-first-parent-only with parent already seen' '
289+
git checkout --orphan test-seen &&
290+
git rm -rf . &&
291+
test_commit r1 &&
292+
git checkout -b branch-f &&
293+
test_commit f &&
294+
git checkout test-seen &&
295+
git merge --no-ff --no-edit -m r2 branch-f &&
296+
git tag r2 &&
297+
298+
git rev-list --exclude-first-parent-only f ^r2 >actual &&
299+
git rev-parse f >expect &&
300+
test_cmp expect actual &&
301+
302+
git rev-list --exclude-first-parent-only f r1 ^r2 >actual2 &&
303+
test_cmp expect actual2
304+
'
305+
288306
test_done

0 commit comments

Comments
 (0)