Skip to content

stash: create snapshot after index refresh - #1019

Closed
Tyrie Vella (tyrielv) wants to merge 2 commits into
microsoft:vfs-2.56.0from
tyrielv:merge-stash-failed-vfs
Closed

Tyrie Vella (tyrielv) wants to merge 2 commits into
microsoft:vfs-2.56.0from
tyrielv:merge-stash-failed-vfs

Conversation

@tyrielv

@tyrielv Tyrie Vella (tyrielv) commented Oct 30, 2026 •

Copy link
Copy Markdown

Problem and Context

git stash create first uses a quick worktree check. It then refreshes the
index before creating the stash object. File or virtual-filesystem state can
change between those steps.

The command currently rechecks the old in-memory index after the refresh. That
can report no object for a stat-only race or miss a worktree change made from
post-index-change. Callers such as git merge then either abort or continue
without a complete snapshot.

Changes

  • Make quiet index refresh report unexpected stat failures.
  • After the refresh and hook complete, clear filesystem and VFS caches, reload
    the index, and validate access to tracked paths.
  • Once the initial check requested a stash, create a snapshot from the reloaded
    state even when only stat data changed.
  • Reload merge's parent index after the stash child returns, so later strategy
    writes do not restore stale index state.
  • Add stash tests for stat-only, content-changing, and VFS path-list races.
  • Add merge tests for normal save-state and autostash callers.

@tyrielv Tyrie Vella (tyrielv) changed the title merge: tolerate empty VFS stash result stash: normalize clean result after index refresh Oct 30, 2026
"git stash create" can find a tracked change in its first quick check,
then observe different worktree or virtual-filesystem state after refreshing
the index. Rechecking the old in-memory index can either report no object or
miss changes made by post-index-change.

After the refresh and hook complete, clear the filesystem and VFS caches,
reload the index, and validate that tracked paths can be stated. Once the
initial check requested a stash, create a snapshot from that fresh state even
if only stat data changed. This returns a normal stash object instead of an
ambiguous exit status.

Make quiet refresh report unexpected stat errors. Reload merge's parent index
after the stash child so later strategy writes do not restore stale index
state. Existing stash and autostash callers continue to consume the normal
object-ID contract.

Assisted-by: Claude Opus 4.8
Assisted-by: GPT-5.6 Sol
Signed-off-by: Tyrie Vella <tyrielv@gmail.com>
Add stash-create tests for three post-index-change outcomes: a stat-only
change produces a clean-tree snapshot, a content change is captured, and a
VFS path-list update exposes and captures a newly modified path.

Add merge coverage for the normal save-state caller. Add an autostash case
that forces the parent and child refreshes separately, proving that autostash
creates and consumes the snapshot produced after the race.

Assisted-by: GPT-5.6 Sol
Signed-off-by: Tyrie Vella <tyrielv@gmail.com>
@tyrielv Tyrie Vella (tyrielv) changed the title stash: normalize clean result after index refresh stash: create snapshot after index refresh Oct 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant