mirror of
https://github.com/git-for-windows/git.git
synced 2026-06-28 18:55:47 -05:00
## 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`.