Repository navigation
test: real-git worktree preparation reads no host git config (orca #48, slice 10) - #60
Merged
nachumi-a2zoperations merged 1 commit intoNov 15, 2026
Conversation
… slice 10) Root cause of worktree-create-preparation-real-git.test.ts "preserves a replacement owner after the fetch barrier before probing or materializing" failing on the MacBook (Node and Bun): the test read host git config. ~/.gitconfig sets core.hooksPath to the owner's identity-guard hooks, so every git in the test and in the product ran them, including a reference-transaction hook on each ref update. git worktree add holds HEAD.lock while that hook runs; the test looked inside the new worktree in that window and git answered "not a git repository: (null)". Proof: at the failure the worktree's admin dir held HEAD.lock and no HEAD; GIT_TRACE shows the hooks; plain git 2.54 with no hooks hit the window 0 times in 40. Fix (test only, the slice 6 way; per the Leader, neither the product nor the owner's hooks change): each test gets a temp gitconfig holding the test identity, with GIT_CONFIG_NOSYSTEM=1 and GIT_CONFIG_GLOBAL pointing at it (vi.stubEnv, restored after each test). Env-passed git config is kept: vitest-inherited-git-env-setup.ts says the compat lane sets it. New test: git config --show-origin lists only that file (plus env-passed config); on the host it lists ~/.gitconfig and Xcode's system file. Runs, normal runner, 3x each (load 50): - before: 2 failed / 12 passed, 2 failed / 12, 2 failed / 12 (replacement owner + aborted materialization) - after: 1 failed / 14 passed (15 tests), x3; the replacement owner passes every run. Not fixed here, a different cause: "removes partial checkout files and registration after materialization is aborted" aborts on the first fs.watch event, and macOS FSEvents delivers it late, so the 1,000-file reset can finish first (resolves instead of rejecting). Linux inotify is immediate. Noted in #48. Refs #48 Signed-off-by: Nachumi Eliyahu <[email protected]>
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.
Refs #48 (slice 10:
worktree-create-preparation-real-git.test.ts). #48 stays open for the rest.Root cause
The test read host git config.
~/.gitconfigsetscore.hooksPathto the owner's identity-guard hooks, so every git in the test and in the product ran them, including areference-transactionhook on each ref update.git worktree addholdsHEAD.lockwhile that hook runs. The test looked inside the new worktree in that window, and git answeredfatal: not a git repository: (null).Proof:
HEAD.lockand noHEAD(diagnostic print).GIT_TRACEshows the hooks running.Fix (test only)
Per the Leader, neither the product code nor the owner's hooks change. This is done the slice 6 way:
GIT_CONFIG_NOSYSTEM=1andGIT_CONFIG_GLOBALpointing at it (vi.stubEnv, restored after each test).vitest-inherited-git-env-setup.tssays the compat lane sets it.git config --list --show-originlists only that file (plus env-passed config). On the host it lists~/.gitconfigand Xcode's system gitconfig.Runs: normal runner, 3× each, MacBook load ~50
da70f61f)Before, the failures were "preserves a replacement owner after the fetch barrier…" (this fix) and "removes partial checkout files … after materialization is aborted". After, the replacement-owner test passes every run, and so does the new isolation test.
Not fixed here: a different cause
"removes partial checkout files and registration after materialization is aborted" still fails on the MacBook, and fails on the base too. It aborts on the first
fs.watchevent during the 1,000-filereset --hard. macOS FSEvents delivers that event late, so the reset can finish first, and the call resolves instead of rejecting. Linux inotify is immediate. It is noted in #48 and kept out of this test-isolation slice.Preflight
check-changed: 22/23. The one red check is the unit step, with that same pre-existing test as its only failure. The commit is signed off as Nachumi Eliyahu.