From: Ted Nyman <[email protected]>
`git stash push -- <pathspec>` expands a sparse index before checking
whether the pathspec matches a tracked path. A pathspec wholly inside
the sparse-checkout cone cannot match part of a sparse-directory entry,
so that expansion needlessly makes the command proportional to the full
index size.
The first patch fixes the pathspec helper to use the parsed, prefixed
path consistently. The existing code can read past the end of the
unprefixed path for a wildcard passed to `git rm` or `git reset` from a
subdirectory; AddressSanitizer reports a heap-buffer-overflow in that
case.
The second patch uses the helper in `git stash push`, following the same
approach as bcf96cfca6 ("rm: expand the index only when necessary",
2022-08-07). It adds compatibility coverage for the supported pathspec
forms and a path-limited stash case to p2000.
On a cone-mode repository with 349,525 tracked paths and 49 sparse-index
entries, the best of three runs was:
before: 18.87s (2.93s user + 15.62s system), 4 expansions
after: 0.06s (0.01s user + 0.02s system), 0 expansions
A full-index control was unchanged (1.62s before, 1.65s after).
The series is based on 48bbf81c29 ("The 5th batch", 2026-07-19), the
current master. Focused sparse-index, stash, pathspec, rm, reset,
SHA-256, and unit-test coverage passes. Clang, GCC, and sanitizer
builds also pass.
Ted Nyman (2):
pathspec: use match for sparse-index expansion checks
stash: avoid sparse-index expansion for in-cone paths
builtin/stash.c | 4 +-
pathspec.c | 12 ++---
t/perf/p2000-sparse-operations.sh | 1 +
t/t1092-sparse-checkout-compatibility.sh | 62 ++++++++++++++++++++++++
4 files changed, 71 insertions(+), 8 deletions(-)
base-commit: 48bbf81c29ca9a4479ec7850fe206518682cdb2f
lmpx.com only provides a reader for public news (NNTP) servers. It is not
affiliated with the servers or forums shown here and is not responsible for
the content of articles, which is written by their respective authors.