Skip to content

Commit 7645e7c

Browse files
committed
revision: fix --no-walk path filtering regression
Since dd4bc01 (revision: use priority queue for non-limited streaming walks, 2026-05-27), "git rev-list --no-walk <commit> -- <path>" ignores the path arguments and outputs all commits regardless of whether they touch the given paths. That commit introduced a REV_WALK_NO_WALK enum value to separate --no-walk from the streaming walk in get_revision_1(). The new case skips process_parents(), which is correct for not enqueuing parents, but also skips try_to_simplify_commit() which process_parents() calls to evaluate whether each commit touches the given paths. Add a call to try_to_simplify_commit() for the REV_WALK_NO_WALK case, folding it into the existing REV_WALK_REFLOG case which already does the same. Add tests for --no-walk path filtering to t6017. The "single commit, match" test is defensive and passes without the fix, while the other two fail without it. Reported-by: Peter Colberg <pcolberg@redhat.com> Signed-off-by: Kristofer Karlsson <krka@spotify.com>
1 parent d35c539 commit 7645e7c

2 files changed

Lines changed: 17 additions & 1 deletion

File tree

revision.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4419,6 +4419,7 @@ static struct commit *get_revision_1(struct rev_info *revs)
44194419

44204420
switch (mode) {
44214421
case REV_WALK_REFLOG:
4422+
case REV_WALK_NO_WALK:
44224423
try_to_simplify_commit(revs, commit);
44234424
break;
44244425
case REV_WALK_TOPO:
@@ -4432,7 +4433,6 @@ static struct commit *get_revision_1(struct rev_info *revs)
44324433
oid_to_hex(&commit->object.oid));
44334434
}
44344435
break;
4435-
case REV_WALK_NO_WALK:
44364436
case REV_WALK_LIMITED:
44374437
break;
44384438
}

t/t6017-rev-list-stdin.sh

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,4 +148,20 @@ test_expect_success '--not via stdin does not influence revisions from command l
148148
test_cmp expect actual
149149
'
150150

151+
test_expect_success '--no-walk filters by path (single commit, match)' '
152+
git rev-list --no-walk side-1 -- file-1 >actual &&
153+
test_line_count = 1 actual
154+
'
155+
156+
test_expect_success '--no-walk filters by path (single commit, no match)' '
157+
git rev-list --no-walk side-2 -- file-1 >actual &&
158+
test_line_count = 0 actual
159+
'
160+
161+
test_expect_success '--no-walk with pathspec exclusion' '
162+
printf "%s\n" $(git rev-parse side-1 side-2 side-3) |
163+
git rev-list --stdin --no-walk -- ":!file-1" >actual &&
164+
test_line_count = 2 actual
165+
'
166+
151167
test_done

0 commit comments

Comments
 (0)