From: Kristofer Karlsson Date: Thu, 16 Jul 2026 10:47:58 +0000 (+0000) Subject: revision: fix --no-walk path filtering regression X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=32c4ed70e28f299bec9097db0609a1d954ffac54;p=thirdparty%2Fgit.git revision: fix --no-walk path filtering regression Since dd4bc01c0a (revision: use priority queue for non-limited streaming walks, 2026-05-27), "git rev-list --no-walk -- " 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 Signed-off-by: Kristofer Karlsson Signed-off-by: Junio C Hamano --- diff --git a/revision.c b/revision.c index 4bb3b16e43..57e0e23e7e 100644 --- a/revision.c +++ b/revision.c @@ -4387,6 +4387,7 @@ static struct commit *get_revision_1(struct rev_info *revs) switch (mode) { case REV_WALK_REFLOG: + case REV_WALK_NO_WALK: try_to_simplify_commit(revs, commit); break; case REV_WALK_TOPO: @@ -4400,7 +4401,6 @@ static struct commit *get_revision_1(struct rev_info *revs) oid_to_hex(&commit->object.oid)); } break; - case REV_WALK_NO_WALK: case REV_WALK_LIMITED: break; } diff --git a/t/t6017-rev-list-stdin.sh b/t/t6017-rev-list-stdin.sh index 4821b90e74..32284f1831 100755 --- a/t/t6017-rev-list-stdin.sh +++ b/t/t6017-rev-list-stdin.sh @@ -148,4 +148,22 @@ test_expect_success '--not via stdin does not influence revisions from command l test_cmp expect actual ' +test_expect_success '--no-walk filters by path (single commit, match)' ' + git rev-parse side-1 >expect && + git rev-list --no-walk side-1 -- file-1 >actual && + test_cmp expect actual +' + +test_expect_success '--no-walk filters by path (single commit, no match)' ' + git rev-list --no-walk side-2 -- file-1 >actual && + test_must_be_empty actual +' + +test_expect_success '--no-walk with pathspec exclusion' ' + git rev-parse side-3 side-2 >expect && + git rev-parse side-1 side-2 side-3 >input && + git rev-list --stdin --no-walk -- ":!file-1" actual && + test_cmp expect actual +' + test_done