From: tnyman@openai.com
To: git@vger.kernel.org
Cc: Ted Nyman <tnyman@openai.com>, Derrick Stolee <stolee@gmail.com>,
Taylor Blau <me@ttaylorr.com>, Jeff King <peff@peff.net>,
Victoria Dye <vdye@github.com>
Subject: [PATCH 0/2] stash: avoid sparse-index expansion for in-cone paths
Date: Mon, 20 Jul 2026 15:31:19 -0700 [thread overview]
Message-ID: <20260720223118.62821-4-tnyman@openai.com> (raw)
From: Ted Nyman <tnyman@openai.com>
`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
next reply other threads:[~2026-07-20 22:31 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-20 22:31 tnyman [this message]
2026-07-20 22:31 ` [PATCH 1/2] pathspec: use match for sparse-index expansion checks tnyman
2026-07-20 23:53 ` Taylor Blau
2026-07-20 22:31 ` [PATCH 2/2] stash: avoid sparse-index expansion for in-cone paths tnyman
2026-07-20 23:54 ` Taylor Blau
2026-07-21 19:34 ` Junio C Hamano
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260720223118.62821-4-tnyman@openai.com \
--to=tnyman@openai.com \
--cc=git@vger.kernel.org \
--cc=me@ttaylorr.com \
--cc=peff@peff.net \
--cc=stolee@gmail.com \
--cc=vdye@github.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox