Repository navigation
Conversation
cfb7e6a to
39496d7
Compare
git worktree add writes the index last, so files written in that same second stay racily clean and every status, diff and checkpoint add re-hashes them. Refresh the new worktree's index once, after that second has passed, and ignore refresh failures. Fixes pingdotgg#21328
39496d7 to
3a3eb59
Compare
|
Note Written by Verified in a real dev environmentverified the refresh behavior as-is at ran
blacksmith: both focused regression cases passed. the two vcs suites produced 206 passes and one failure in Not verifiedthe same-second condition was reproduced on main, but repeated content hashing or a latency slowdown was not demonstrated on this linux git 2.43.0/ext4 vm. trace2 native electron, ios/android, macos/windows, submodules, and a real filesystem refresh failure were not exercised. the failure fallback passed its existing focused test. |




Closes #21328
Problem
git worktree addwrites the checkout files first and the index last. Git only trusts an entry's cached stat when the file's mtime is in an earlier second than the index file, so every file written in that last second stays racily clean. Nothing T3 runs after creating a worktree ever rewrites its index (status polling and checkpoint capture deliberately don't, see #14718 and #10792), so those entries stay racy for the life of the worktree and every status refresh and checkpoint capture re-hashes them (#21328).Change
At the end of
GitVcsDriverCore.createWorktree, after the submodule update, the new worktree's index is refreshed once withgit update-index -q --refresh. A refresh in the same second as the index write would leave the entries racy, so it first waits until the wall clock is past the index file's mtime second (plus a 25 ms margin for timestamp lag). A failed refresh is logged at Warn and ignored, so worktree creation still succeeds.Status and capture still never write the index, and clones are unchanged.
Scope and approval
Triaged and accepted by the maintainer as a narrow performance bug: #21328 (comment)
Verification
Two new tests in
apps/server/src/vcs/GitVcsDriverCore.test.ts:leaves no racily clean entries in a new worktree's indexcreates a worktree with 21 tracked files and checks that everygit ls-files --debugmtime second is below the index file's mtime second, which is Git's own racy rule.still creates the worktree when the index refresh failsmakesupdate-indexexit 128 and checks the refresh was attempted once and the worktree still exists.Without the change both fail (21 entries share the index's second; no refresh is attempted). With it both pass, 15 out of 15 runs in a loop. The full
GitVcsDriverCore.test.tsandGitVcsDriver.test.tspass. Format, lint andapps/servertypecheck are clean.Not checked: Linux (tested on macOS only), and timings on a large real repo. Worktree creation now waits up to about 1 s for the index second to pass.
Claude Sonnet 5.5 (xhigh) via T3 Code.