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 <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> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Kristofer Karlsson committed Jul 16, 2026 at 10:47 UTC 32c4ed70e28f299bec9097db0609a1d954ffac54
2 files changed +19 -1
revision.c
+1 -1
@@ -4387,6 +4387,7 @@ static struct commit *get_revision_1(struct rev_info *revs)
4387
4388 switch (mode) {
4389 case REV_WALK_REFLOG:
4390 + case REV_WALK_NO_WALK:
4391 try_to_simplify_commit(revs, commit);
4392 break;
4393 case REV_WALK_TOPO:
@@ -4400,7 +4401,6 @@ static struct commit *get_revision_1(struct rev_info *revs)
4401 oid_to_hex(&commit->object.oid));
4402 }
4403 break;
4403 - case REV_WALK_NO_WALK:
4404 case REV_WALK_LIMITED:
4405 break;
4406 }
t/t6017-rev-list-stdin.sh
+18
@@ -148,4 +148,22 @@ test_expect_success '--not via stdin does not influence revisions from command l
148 test_cmp expect actual
149 '
150
151 +test_expect_success '--no-walk filters by path (single commit, match)' '
152 + git rev-parse side-1 >expect &&
153 + git rev-list --no-walk side-1 -- file-1 >actual &&
154 + test_cmp expect actual
155 +'
156 +
157 +test_expect_success '--no-walk filters by path (single commit, no match)' '
158 + git rev-list --no-walk side-2 -- file-1 >actual &&
159 + test_must_be_empty actual
160 +'
161 +
162 +test_expect_success '--no-walk with pathspec exclusion' '
163 + git rev-parse side-3 side-2 >expect &&
164 + git rev-parse side-1 side-2 side-3 >input &&
165 + git rev-list --stdin --no-walk -- ":!file-1" <input >actual &&
166 + test_cmp expect actual
167 +'
168 +
169 test_done