git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH 0/2] ls-files: reuse the untracked cache

From
Tamir Duberstein <tamird@gmail.com>
Date
Sep 23, 2026, 17:10 UTC
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 <tamird@gmail.com>
---
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

Next: Tamir Duberstein
Message 1 of 8 in “ls-files: reuse the untracked cache”
  1. 0/2 ls-files: reuse the untracked cacheTamir Duberstein, Sep 23, 2026
  2. 1/2 dir: hash ignore files before adding parser LFTamir Duberstein, Sep 23, 2026
  3. 2/2 ls-files: reuse cached untracked listingsTamir Duberstein, Sep 23, 2026
  4. Tamir DubersteinSep 23, 2026
  5. 0/3 ls-files: reuse and update the untracked cacheTamir Duberstein, Sep 23, 2026
  6. 1/3 dir: hash ignore files before appending newlineTamir Duberstein, Sep 23, 2026
  7. 2/3 dir: share untracked caches across output modesTamir Duberstein, Sep 23, 2026
  8. 3/3 ls-files: use and update the untracked cacheTamir Duberstein, Sep 23, 2026

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.