entry: flush fscache after creating directories and writing files#6250
Merged
dscho merged 1 commit intoJun 8, 2026
Merged
Conversation
When checkout.workers > 1 and core.fscache is enabled on Windows, 'git checkout <tree> -- <pathspec>' fails when restoring files into directories that do not yet exist on disk. Two failure modes occur: 1. create_directories(): the fscache returns a stale directory listing that does not include a just-created directory. has_dirs_only_path() reports it as non-existent, triggering the unlink+mkdir recovery path which fails with 'cannot create directory: Directory not empty'. 2. write_pc_item(): after writing and closing a file, lstat() cannot see it through the stale fscache, failing with 'unable to stat just-written file'. With workers=1, write_entry() calls flush_fscache() after each file, keeping the cache in sync. With workers>1, enqueue_checkout() defers the write (and the flush), leaving the cache stale for subsequent entries. Fix both by adding flush_fscache() calls after mkdir() in create_directories() and before lstat() in write_pc_item(). On non-Windows platforms flush_fscache() is a no-op. Assisted-by: Claude Opus 4.6 Signed-off-by: Tyrie Vella <tyrielv@gmail.com>
1 task
dscho
approved these changes
Jun 8, 2026
Member
|
/add relnote bug A bug was fixed which could cause parallel checkouts to fail under certain circumstances when the FSCache is enabled. The workflow run was started |
github-actions Bot
pushed a commit
to git-for-windows/build-extra
that referenced
this pull request
Jun 8, 2026
A bug was [fixed](git-for-windows/git#6250) which could cause parallel checkouts to fail under certain circumstances when the FSCache is enabled. Signed-off-by: gitforwindowshelper[bot] <gitforwindowshelper-bot@users.noreply.github.com>
This was referenced Jun 9, 2026
gitforwindowshelper Bot
pushed a commit
that referenced
this pull request
Jun 10, 2026
) ## Problem `git checkout <tree> -- <pathspec>` with `checkout.workers > 1` and `core.fscache=true` fails when restoring files into directories that do not yet exist on disk. Two failure modes: 1. `fatal: cannot create directory at '...': Directory not empty` (exit 128) 2. `error: unable to stat just-written file '...'` (exit 255) 100% reproducible when two or more files share a not-yet-created parent directory. ## Root Cause The Windows fscache caches directory listings that become stale when `create_directories()` creates new parent directories via `mkdir()` or when `write_pc_item()` writes new files. With `workers=1`, `write_entry()` calls `flush_fscache()` after each file, keeping the cache in sync. With `workers>1`, `enqueue_checkout()` defers the write (and the flush), leaving the cache stale for subsequent entries. ## Fix Add `flush_fscache()` calls: - In `create_directories()` after each successful `mkdir()`, so `has_dirs_only_path()` sees the new directory - In `write_pc_item()` before `lstat()` of the just-written file On non-Windows platforms `flush_fscache()` is a no-op. ## Test Adds a regression test to `t2080-parallel-checkout-basics.sh` (`MINGW` prereq) that deterministically reproduces the bug: two files sharing a nested parent directory, deleted in a second commit, then restored via `git checkout <tree> -- <pathspec>` with `workers=2`.
gitforwindowshelper Bot
pushed a commit
that referenced
this pull request
Jun 10, 2026
) ## Problem `git checkout <tree> -- <pathspec>` with `checkout.workers > 1` and `core.fscache=true` fails when restoring files into directories that do not yet exist on disk. Two failure modes: 1. `fatal: cannot create directory at '...': Directory not empty` (exit 128) 2. `error: unable to stat just-written file '...'` (exit 255) 100% reproducible when two or more files share a not-yet-created parent directory. ## Root Cause The Windows fscache caches directory listings that become stale when `create_directories()` creates new parent directories via `mkdir()` or when `write_pc_item()` writes new files. With `workers=1`, `write_entry()` calls `flush_fscache()` after each file, keeping the cache in sync. With `workers>1`, `enqueue_checkout()` defers the write (and the flush), leaving the cache stale for subsequent entries. ## Fix Add `flush_fscache()` calls: - In `create_directories()` after each successful `mkdir()`, so `has_dirs_only_path()` sees the new directory - In `write_pc_item()` before `lstat()` of the just-written file On non-Windows platforms `flush_fscache()` is a no-op. ## Test Adds a regression test to `t2080-parallel-checkout-basics.sh` (`MINGW` prereq) that deterministically reproduces the bug: two files sharing a nested parent directory, deleted in a second commit, then restored via `git checkout <tree> -- <pathspec>` with `workers=2`.
gitforwindowshelper Bot
pushed a commit
that referenced
this pull request
Jun 10, 2026
) ## Problem `git checkout <tree> -- <pathspec>` with `checkout.workers > 1` and `core.fscache=true` fails when restoring files into directories that do not yet exist on disk. Two failure modes: 1. `fatal: cannot create directory at '...': Directory not empty` (exit 128) 2. `error: unable to stat just-written file '...'` (exit 255) 100% reproducible when two or more files share a not-yet-created parent directory. ## Root Cause The Windows fscache caches directory listings that become stale when `create_directories()` creates new parent directories via `mkdir()` or when `write_pc_item()` writes new files. With `workers=1`, `write_entry()` calls `flush_fscache()` after each file, keeping the cache in sync. With `workers>1`, `enqueue_checkout()` defers the write (and the flush), leaving the cache stale for subsequent entries. ## Fix Add `flush_fscache()` calls: - In `create_directories()` after each successful `mkdir()`, so `has_dirs_only_path()` sees the new directory - In `write_pc_item()` before `lstat()` of the just-written file On non-Windows platforms `flush_fscache()` is a no-op. ## Test Adds a regression test to `t2080-parallel-checkout-basics.sh` (`MINGW` prereq) that deterministically reproduces the bug: two files sharing a nested parent directory, deleted in a second commit, then restored via `git checkout <tree> -- <pathspec>` with `workers=2`.
gitforwindowshelper Bot
pushed a commit
that referenced
this pull request
Jun 11, 2026
) ## Problem `git checkout <tree> -- <pathspec>` with `checkout.workers > 1` and `core.fscache=true` fails when restoring files into directories that do not yet exist on disk. Two failure modes: 1. `fatal: cannot create directory at '...': Directory not empty` (exit 128) 2. `error: unable to stat just-written file '...'` (exit 255) 100% reproducible when two or more files share a not-yet-created parent directory. ## Root Cause The Windows fscache caches directory listings that become stale when `create_directories()` creates new parent directories via `mkdir()` or when `write_pc_item()` writes new files. With `workers=1`, `write_entry()` calls `flush_fscache()` after each file, keeping the cache in sync. With `workers>1`, `enqueue_checkout()` defers the write (and the flush), leaving the cache stale for subsequent entries. ## Fix Add `flush_fscache()` calls: - In `create_directories()` after each successful `mkdir()`, so `has_dirs_only_path()` sees the new directory - In `write_pc_item()` before `lstat()` of the just-written file On non-Windows platforms `flush_fscache()` is a no-op. ## Test Adds a regression test to `t2080-parallel-checkout-basics.sh` (`MINGW` prereq) that deterministically reproduces the bug: two files sharing a nested parent directory, deleted in a second commit, then restored via `git checkout <tree> -- <pathspec>` with `workers=2`.
pull Bot
pushed a commit
to frikke/git
that referenced
this pull request
Jun 11, 2026
…t-for-windows#6250) ## Problem `git checkout <tree> -- <pathspec>` with `checkout.workers > 1` and `core.fscache=true` fails when restoring files into directories that do not yet exist on disk. Two failure modes: 1. `fatal: cannot create directory at '...': Directory not empty` (exit 128) 2. `error: unable to stat just-written file '...'` (exit 255) 100% reproducible when two or more files share a not-yet-created parent directory. ## Root Cause The Windows fscache caches directory listings that become stale when `create_directories()` creates new parent directories via `mkdir()` or when `write_pc_item()` writes new files. With `workers=1`, `write_entry()` calls `flush_fscache()` after each file, keeping the cache in sync. With `workers>1`, `enqueue_checkout()` defers the write (and the flush), leaving the cache stale for subsequent entries. ## Fix Add `flush_fscache()` calls: - In `create_directories()` after each successful `mkdir()`, so `has_dirs_only_path()` sees the new directory - In `write_pc_item()` before `lstat()` of the just-written file On non-Windows platforms `flush_fscache()` is a no-op. ## Test Adds a regression test to `t2080-parallel-checkout-basics.sh` (`MINGW` prereq) that deterministically reproduces the bug: two files sharing a nested parent directory, deleted in a second commit, then restored via `git checkout <tree> -- <pathspec>` with `workers=2`.
gitforwindowshelper Bot
pushed a commit
that referenced
this pull request
Jun 11, 2026
) ## Problem `git checkout <tree> -- <pathspec>` with `checkout.workers > 1` and `core.fscache=true` fails when restoring files into directories that do not yet exist on disk. Two failure modes: 1. `fatal: cannot create directory at '...': Directory not empty` (exit 128) 2. `error: unable to stat just-written file '...'` (exit 255) 100% reproducible when two or more files share a not-yet-created parent directory. ## Root Cause The Windows fscache caches directory listings that become stale when `create_directories()` creates new parent directories via `mkdir()` or when `write_pc_item()` writes new files. With `workers=1`, `write_entry()` calls `flush_fscache()` after each file, keeping the cache in sync. With `workers>1`, `enqueue_checkout()` defers the write (and the flush), leaving the cache stale for subsequent entries. ## Fix Add `flush_fscache()` calls: - In `create_directories()` after each successful `mkdir()`, so `has_dirs_only_path()` sees the new directory - In `write_pc_item()` before `lstat()` of the just-written file On non-Windows platforms `flush_fscache()` is a no-op. ## Test Adds a regression test to `t2080-parallel-checkout-basics.sh` (`MINGW` prereq) that deterministically reproduces the bug: two files sharing a nested parent directory, deleted in a second commit, then restored via `git checkout <tree> -- <pathspec>` with `workers=2`.
gitforwindowshelper Bot
pushed a commit
that referenced
this pull request
Jun 11, 2026
) ## Problem `git checkout <tree> -- <pathspec>` with `checkout.workers > 1` and `core.fscache=true` fails when restoring files into directories that do not yet exist on disk. Two failure modes: 1. `fatal: cannot create directory at '...': Directory not empty` (exit 128) 2. `error: unable to stat just-written file '...'` (exit 255) 100% reproducible when two or more files share a not-yet-created parent directory. ## Root Cause The Windows fscache caches directory listings that become stale when `create_directories()` creates new parent directories via `mkdir()` or when `write_pc_item()` writes new files. With `workers=1`, `write_entry()` calls `flush_fscache()` after each file, keeping the cache in sync. With `workers>1`, `enqueue_checkout()` defers the write (and the flush), leaving the cache stale for subsequent entries. ## Fix Add `flush_fscache()` calls: - In `create_directories()` after each successful `mkdir()`, so `has_dirs_only_path()` sees the new directory - In `write_pc_item()` before `lstat()` of the just-written file On non-Windows platforms `flush_fscache()` is a no-op. ## Test Adds a regression test to `t2080-parallel-checkout-basics.sh` (`MINGW` prereq) that deterministically reproduces the bug: two files sharing a nested parent directory, deleted in a second commit, then restored via `git checkout <tree> -- <pathspec>` with `workers=2`.
gitforwindowshelper Bot
pushed a commit
that referenced
this pull request
Jun 11, 2026
) ## Problem `git checkout <tree> -- <pathspec>` with `checkout.workers > 1` and `core.fscache=true` fails when restoring files into directories that do not yet exist on disk. Two failure modes: 1. `fatal: cannot create directory at '...': Directory not empty` (exit 128) 2. `error: unable to stat just-written file '...'` (exit 255) 100% reproducible when two or more files share a not-yet-created parent directory. ## Root Cause The Windows fscache caches directory listings that become stale when `create_directories()` creates new parent directories via `mkdir()` or when `write_pc_item()` writes new files. With `workers=1`, `write_entry()` calls `flush_fscache()` after each file, keeping the cache in sync. With `workers>1`, `enqueue_checkout()` defers the write (and the flush), leaving the cache stale for subsequent entries. ## Fix Add `flush_fscache()` calls: - In `create_directories()` after each successful `mkdir()`, so `has_dirs_only_path()` sees the new directory - In `write_pc_item()` before `lstat()` of the just-written file On non-Windows platforms `flush_fscache()` is a no-op. ## Test Adds a regression test to `t2080-parallel-checkout-basics.sh` (`MINGW` prereq) that deterministically reproduces the bug: two files sharing a nested parent directory, deleted in a second commit, then restored via `git checkout <tree> -- <pathspec>` with `workers=2`.
This was referenced Jun 12, 2026
gitforwindowshelper Bot
pushed a commit
that referenced
this pull request
Jun 12, 2026
) ## Problem `git checkout <tree> -- <pathspec>` with `checkout.workers > 1` and `core.fscache=true` fails when restoring files into directories that do not yet exist on disk. Two failure modes: 1. `fatal: cannot create directory at '...': Directory not empty` (exit 128) 2. `error: unable to stat just-written file '...'` (exit 255) 100% reproducible when two or more files share a not-yet-created parent directory. ## Root Cause The Windows fscache caches directory listings that become stale when `create_directories()` creates new parent directories via `mkdir()` or when `write_pc_item()` writes new files. With `workers=1`, `write_entry()` calls `flush_fscache()` after each file, keeping the cache in sync. With `workers>1`, `enqueue_checkout()` defers the write (and the flush), leaving the cache stale for subsequent entries. ## Fix Add `flush_fscache()` calls: - In `create_directories()` after each successful `mkdir()`, so `has_dirs_only_path()` sees the new directory - In `write_pc_item()` before `lstat()` of the just-written file On non-Windows platforms `flush_fscache()` is a no-op. ## Test Adds a regression test to `t2080-parallel-checkout-basics.sh` (`MINGW` prereq) that deterministically reproduces the bug: two files sharing a nested parent directory, deleted in a second commit, then restored via `git checkout <tree> -- <pathspec>` with `workers=2`.
gitforwindowshelper Bot
pushed a commit
that referenced
this pull request
Jun 12, 2026
) ## Problem `git checkout <tree> -- <pathspec>` with `checkout.workers > 1` and `core.fscache=true` fails when restoring files into directories that do not yet exist on disk. Two failure modes: 1. `fatal: cannot create directory at '...': Directory not empty` (exit 128) 2. `error: unable to stat just-written file '...'` (exit 255) 100% reproducible when two or more files share a not-yet-created parent directory. ## Root Cause The Windows fscache caches directory listings that become stale when `create_directories()` creates new parent directories via `mkdir()` or when `write_pc_item()` writes new files. With `workers=1`, `write_entry()` calls `flush_fscache()` after each file, keeping the cache in sync. With `workers>1`, `enqueue_checkout()` defers the write (and the flush), leaving the cache stale for subsequent entries. ## Fix Add `flush_fscache()` calls: - In `create_directories()` after each successful `mkdir()`, so `has_dirs_only_path()` sees the new directory - In `write_pc_item()` before `lstat()` of the just-written file On non-Windows platforms `flush_fscache()` is a no-op. ## Test Adds a regression test to `t2080-parallel-checkout-basics.sh` (`MINGW` prereq) that deterministically reproduces the bug: two files sharing a nested parent directory, deleted in a second commit, then restored via `git checkout <tree> -- <pathspec>` with `workers=2`.
dscho
added a commit
to microsoft/git
that referenced
this pull request
Jun 12, 2026
…t-for-windows#6250) ## Problem `git checkout <tree> -- <pathspec>` with `checkout.workers > 1` and `core.fscache=true` fails when restoring files into directories that do not yet exist on disk. Two failure modes: 1. `fatal: cannot create directory at '...': Directory not empty` (exit 128) 2. `error: unable to stat just-written file '...'` (exit 255) 100% reproducible when two or more files share a not-yet-created parent directory. ## Root Cause The Windows fscache caches directory listings that become stale when `create_directories()` creates new parent directories via `mkdir()` or when `write_pc_item()` writes new files. With `workers=1`, `write_entry()` calls `flush_fscache()` after each file, keeping the cache in sync. With `workers>1`, `enqueue_checkout()` defers the write (and the flush), leaving the cache stale for subsequent entries. ## Fix Add `flush_fscache()` calls: - In `create_directories()` after each successful `mkdir()`, so `has_dirs_only_path()` sees the new directory - In `write_pc_item()` before `lstat()` of the just-written file On non-Windows platforms `flush_fscache()` is a no-op. ## Test Adds a regression test to `t2080-parallel-checkout-basics.sh` (`MINGW` prereq) that deterministically reproduces the bug: two files sharing a nested parent directory, deleted in a second commit, then restored via `git checkout <tree> -- <pathspec>` with `workers=2`.
gitforwindowshelper Bot
pushed a commit
that referenced
this pull request
Jun 12, 2026
) ## Problem `git checkout <tree> -- <pathspec>` with `checkout.workers > 1` and `core.fscache=true` fails when restoring files into directories that do not yet exist on disk. Two failure modes: 1. `fatal: cannot create directory at '...': Directory not empty` (exit 128) 2. `error: unable to stat just-written file '...'` (exit 255) 100% reproducible when two or more files share a not-yet-created parent directory. ## Root Cause The Windows fscache caches directory listings that become stale when `create_directories()` creates new parent directories via `mkdir()` or when `write_pc_item()` writes new files. With `workers=1`, `write_entry()` calls `flush_fscache()` after each file, keeping the cache in sync. With `workers>1`, `enqueue_checkout()` defers the write (and the flush), leaving the cache stale for subsequent entries. ## Fix Add `flush_fscache()` calls: - In `create_directories()` after each successful `mkdir()`, so `has_dirs_only_path()` sees the new directory - In `write_pc_item()` before `lstat()` of the just-written file On non-Windows platforms `flush_fscache()` is a no-op. ## Test Adds a regression test to `t2080-parallel-checkout-basics.sh` (`MINGW` prereq) that deterministically reproduces the bug: two files sharing a nested parent directory, deleted in a second commit, then restored via `git checkout <tree> -- <pathspec>` with `workers=2`.
gitforwindowshelper Bot
pushed a commit
that referenced
this pull request
Jun 12, 2026
) ## Problem `git checkout <tree> -- <pathspec>` with `checkout.workers > 1` and `core.fscache=true` fails when restoring files into directories that do not yet exist on disk. Two failure modes: 1. `fatal: cannot create directory at '...': Directory not empty` (exit 128) 2. `error: unable to stat just-written file '...'` (exit 255) 100% reproducible when two or more files share a not-yet-created parent directory. ## Root Cause The Windows fscache caches directory listings that become stale when `create_directories()` creates new parent directories via `mkdir()` or when `write_pc_item()` writes new files. With `workers=1`, `write_entry()` calls `flush_fscache()` after each file, keeping the cache in sync. With `workers>1`, `enqueue_checkout()` defers the write (and the flush), leaving the cache stale for subsequent entries. ## Fix Add `flush_fscache()` calls: - In `create_directories()` after each successful `mkdir()`, so `has_dirs_only_path()` sees the new directory - In `write_pc_item()` before `lstat()` of the just-written file On non-Windows platforms `flush_fscache()` is a no-op. ## Test Adds a regression test to `t2080-parallel-checkout-basics.sh` (`MINGW` prereq) that deterministically reproduces the bug: two files sharing a nested parent directory, deleted in a second commit, then restored via `git checkout <tree> -- <pathspec>` with `workers=2`.
gitforwindowshelper Bot
pushed a commit
that referenced
this pull request
Jun 12, 2026
) ## Problem `git checkout <tree> -- <pathspec>` with `checkout.workers > 1` and `core.fscache=true` fails when restoring files into directories that do not yet exist on disk. Two failure modes: 1. `fatal: cannot create directory at '...': Directory not empty` (exit 128) 2. `error: unable to stat just-written file '...'` (exit 255) 100% reproducible when two or more files share a not-yet-created parent directory. ## Root Cause The Windows fscache caches directory listings that become stale when `create_directories()` creates new parent directories via `mkdir()` or when `write_pc_item()` writes new files. With `workers=1`, `write_entry()` calls `flush_fscache()` after each file, keeping the cache in sync. With `workers>1`, `enqueue_checkout()` defers the write (and the flush), leaving the cache stale for subsequent entries. ## Fix Add `flush_fscache()` calls: - In `create_directories()` after each successful `mkdir()`, so `has_dirs_only_path()` sees the new directory - In `write_pc_item()` before `lstat()` of the just-written file On non-Windows platforms `flush_fscache()` is a no-op. ## Test Adds a regression test to `t2080-parallel-checkout-basics.sh` (`MINGW` prereq) that deterministically reproduces the bug: two files sharing a nested parent directory, deleted in a second commit, then restored via `git checkout <tree> -- <pathspec>` with `workers=2`.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
git checkout <tree> -- <pathspec>withcheckout.workers > 1andcore.fscache=truefails when restoring files into directories that do not yet exist on disk. Two failure modes:fatal: cannot create directory at '...': Directory not empty(exit 128)error: unable to stat just-written file '...'(exit 255)100% reproducible when two or more files share a not-yet-created parent directory.
Root Cause
The Windows fscache caches directory listings that become stale when
create_directories()creates new parent directories viamkdir()or whenwrite_pc_item()writes new files. Withworkers=1,write_entry()callsflush_fscache()after each file, keeping the cache in sync. Withworkers>1,enqueue_checkout()defers the write (and the flush), leaving the cache stale for subsequent entries.Fix
Add
flush_fscache()calls:create_directories()after each successfulmkdir(), sohas_dirs_only_path()sees the new directorywrite_pc_item()beforelstat()of the just-written fileOn non-Windows platforms
flush_fscache()is a no-op.Test
Adds a regression test to
t2080-parallel-checkout-basics.sh(MINGWprereq) that deterministically reproduces the bug: two files sharing a nested parent directory, deleted in a second commit, then restored viagit checkout <tree> -- <pathspec>withworkers=2.