Skip to content

test: real-git worktree preparation reads no host git config (orca #48, slice 10) - #60

Merged
nachumi-a2zoperations merged 1 commit into
blowzer/fork-onlyfrom
nachumi-a2zoperations/issue-48-real-git-host-hooks
Nov 15, 2026
Merged

nachumi-a2zoperations merged 1 commit into
blowzer/fork-onlyfrom
nachumi-a2zoperations/issue-48-real-git-host-hooks

Conversation

@nachumi-a2zoperations

Copy link
Copy Markdown

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. ~/.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 fatal: not a git repository: (null).

Proof:

  • At the failure, the worktree's admin dir held HEAD.lock and no HEAD (diagnostic print).
  • GIT_TRACE shows the hooks running.
  • Plain git 2.54 with no hooks hit the window 0 times in 40.

Fix (test only)

Per the Leader, neither the product code nor the owner's hooks change. This is done the slice 6 way:

  • 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 --list --show-origin lists only that file (plus env-passed config). On the host it lists ~/.gitconfig and Xcode's system gitconfig.

Runs: normal runner, 3× each, MacBook load ~50

Run 1 Run 2 Run 3
before (base da70f61f) 2 failed / 12 passed 2 failed / 12 passed 2 failed / 12 passed
after (this head, 15 tests) 1 failed / 14 passed 1 failed / 14 passed 1 failed / 14 passed

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.watch event during the 1,000-file reset --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.

… 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]>
@nachumi-a2zoperations
nachumi-a2zoperations merged commit 1cedd81 into blowzer/fork-only Nov 15, 2026
2 checks passed
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