From: Tamir Duberstein Date: Wed, 23 Sep 2026 17:10:07 GMT Subject: [PATCH 0/2] ls-files: reuse the untracked cache Message-ID: <20260923-ls-files-untracked-cache-v1-0-08db4cc1efdb@gmail.com> Repeated queries such as git ls-files --cached --others --exclude-standard -z -- "**/pyproject.toml" walk the working tree even when status has already populated an untracked cache. This series lets ls-files reuse those directory listings. It expands partial scans and collapsed untracked directories as needed, without writing the converted cache back to the index. The first patch fixes inconsistent ignore-file hashes that invalidate an unchanged cache. The second enables reuse for ls-files and filters complete listings after the walk. Fixed-prefix queries retain directory pruning; attribute and exclude pathspecs retain their existing traversal because matching a directory can differ from matching its children. On macOS, a synthetic tree with 100,000 tracked files in 5,000 directories and a few untracked files averaged 361 ms before and 50 ms after in five hyperfine runs after one warmup. Directory opens fell from 5,058 to seven. With half the files untracked, five alternating runs averaged 659 ms before and 339 ms after; that case still expands 2,533 partially cached directories. A cache populated with status.showUntrackedFiles=all avoids directory opens in both cases. These measurements disable fsmonitor and use a populated cache with a warm filesystem. Uncached controls were noisy; the apparent slowdown in the first batch did not recur. Literal-query results varied in both directions, with a separate five-run hyperfine check measuring 17 ms before and 20 ms after. Prepared with Codex, including code review and benchmark work by separate Codex agents. Signed-off-by: Tamir Duberstein --- Tamir Duberstein (2): dir: hash ignore files before adding parser LF ls-files: reuse cached untracked listings builtin/ls-files.c | 11 +++++-- dir.c | 64 +++++++++++++++++++++++++++++++++--- dir.h | 2 ++ t/perf/p3010-ls-files.sh | 15 +++++++++ t/t7063-status-untracked-cache.sh | 68 ++++++++++++++++++++++++++++++++++++--- 5 files changed, 149 insertions(+), 11 deletions(-) --- base-commit: 3bc0341126508f78f5869cbfc0005e987efdf0c7 change-id: 20260923-ls-files-untracked-cache-3559bed01a3e