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

[PATCH 0/2] restore: better integrate with sparse index

From
Derrick Stolee via GitGitGadget <gitgitgadget@gmail.com>
Date
May 24, 2026, 17:40 UTC
Message-ID
<pull.2121.git.1779644412.gitgitgadget@gmail.com>

There's still a long tail of situations where Git expands a sparse index in-memory in order to operate on blob path entries instead of intelligently handling trees. I was recently alerted to one such case with git restore --staged -- ..

The basic idea here is that the pathspec . signals that all paths matter, but what we want to do across those pathspecs will ignore the expanded blob paths with the SKIP_WORKTREE bit, so we should avoid expanding the tree when we can.

This series has two patches: first a test to demonstrate the baseline behavior of git restore across different sparsity cases as well as demonstrate that the index is currently expanded. The second patch includes the fix and maintains the same end-to-end behavior with the only change being the performance improvement from not expanding the sparse index.

Thanks, -Stolee
Derrick Stolee (2):
  t1092: test 'git restore' with sparse index
  restore: avoid sparse index expansion
 builtin/checkout.c                       | 57 +++++++++++++++++++++---
 t/t1092-sparse-checkout-compatibility.sh | 50 +++++++++++++++++++++
 2 files changed, 101 insertions(+), 6 deletions(-)
base-commit: aec3f587505a472db67e9462d0702e7d463a449d
Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-2121%2Fderrickstolee%2Frestore-sparse-index-v1
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-2121/derrickstolee/restore-sparse-index-v1
Pull-Request: https://github.com/gitgitgadget/git/pull/2121
-- 
gitgitgadget
Next: Derrick Stolee via GitGitGadget
Message 1 of 9 in “restore: better integrate with sparse index”
  1. 0/2 restore: better integrate with sparse indexDerrick Stolee via GitGitGadget, May 24, 2026
  2. 1/2 t1092: test 'git restore' with sparse indexDerrick Stolee via GitGitGadget, May 24, 2026
  3. Junio C HamanoMay 24, 2026
  4. 2/2 restore: avoid sparse index expansionDerrick Stolee via GitGitGadget, May 24, 2026
  5. Junio C HamanoMay 24, 2026
  6. Derrick StoleeMay 26, 2026
  7. 0/2 restore: better integrate with sparse indexDerrick Stolee via GitGitGadget, May 26, 2026
  8. 1/2 t1092: test 'git restore' with sparse indexDerrick Stolee via GitGitGadget, May 26, 2026
  9. 2/2 restore: avoid sparse index expansionDerrick Stolee via GitGitGadget, May 26, 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.