Repository navigation
fix(setup): resolve repo root without a work tree in linked worktrees - #10401
Merged
kodjima33 merged 1 commit intoJul 23, 2026
Merged
Conversation
`git rev-parse --show-toplevel` exits 128 ("this operation must be run in
a work tree") in a linked worktree whose git context resolves to a git
dir rather than a work tree (e.g. a Conductor workspace). Three call
sites assumed it always returns a path:
- Makefile PYTHON collapsed to an empty prefix, breaking every target
with `/scripts/dev-harness/_resolve_python.sh: No such file`.
- install-git-hooks.sh aborted `make setup` at setup-hooks (Error 128).
- The installed pre-commit/pre-push dispatcher aborted the hook, forcing
`git push --no-verify` and silently bypassing the local gate.
Makefile and the dispatcher fall back to `pwd` (make and git hooks both
run from the top of the work tree) while keeping the root computed
in-shell, so a checkout path with quote/`$` chars still cannot inject.
install-git-hooks.sh resolves its root from the script's own location.
Adds a regression to scripts/test-make-setup.sh that reproduces the
128 condition via a bare GIT_DIR and fails on the pre-fix Makefile.
Failure-Class: FC-shell-source-path-interpolation
fixes #10352
kodjima33
deleted the
issues-improver/10352-worktree-hook-root-resolution
branch
July 23, 2026 15:23
Git-on-my-level
added a commit
that referenced
this pull request
Jul 30, 2026
Fixes #9724. Fixes #10293. ## Summary - make the single-flight runner register only host-supported signals and replace destructive Windows `os.kill(pid, 0)` probing - launch the extensionless pre-push script through Git Bash and carry one explicit Python executable across every hook boundary, including the `PRE_PUSH_SKIP_PR_PREFLIGHT=1` failure-class hatch - contain the Windows command tree in a kill-on-close Job Object, with a bootstrap barrier that assigns the job before the real command can spawn - bind stale-lock identity to Windows process creation ticks so PID reuse cannot impersonate the prior owner - decode Git metadata as UTF-8 so native Windows locales can resolve non-ASCII worktree paths - make the check manifest Windows-aware and add a path-scoped native Windows workflow that executes the manifest-owned portability checks - preserve the mainline `forwardable_signals` and direct-child fallback contracts while extending Windows ownership to the full process tree - restore the linked-worktree repo-root fallback across all five downstream shell/Python pre-push entrypoints, so a `show-toplevel` exit 128 does not force contributors toward `--no-verify` - keep native process tests event-driven with pipe handshakes and `WaitForSingleObject`, without wall-clock polling or leaked handles ## Root cause The pre-push control plane assumed POSIX signals, process groups, executable script launching, virtualenv layout, and `python3` naming at native Windows boundaries. It also let Python decode Git's UTF-8 output with the active Windows code page, so a worktree path containing non-ASCII characters could fail before any check ran. A second gap remained after #10401: the installed hook dispatcher could recover when `git rev-parse --show-toplevel` failed in a linked worktree, but `scripts/pre-push`, `scripts/pre-push-singleflight`, `scripts/pr-preflight`, `.github/scripts/preflight_runner.py`, and `.github/scripts/pr_preflight.py` repeated the unguarded lookup and aborted later in the same chain. Fixing only the first Windows exception or only the Makefile/dispatcher boundary would expose the next launch, liveness, decoding, root-resolution, or hatch failure. This PR closes that reachable portability chain. ## Attribution The linked-worktree root-resolution slice preserves Nik Shevchenko's original #10491 implementation through the rebased commit lineage, with `Co-authored-by: Nik Shevchenko <[email protected]>`. Its regression was adapted to the explicit Windows Python launcher introduced by this PR and registered in both manifest lanes plus native Windows CI. ## Verification - rebased onto current `origin/main` (`ffc13daf4c`) and reran the native Windows checks - native Windows manifest run: `pre-push-worktree-fallback`, `preflight-runner-portability`, and `check-manifest-contract` -> 3 checks passed - native Windows: `test_preflight_runner.py` -> 23 tests passed with `ResourceWarning` promoted to an error, including a real Job Object parent/descendant termination proof, explicit hatch interpreter coverage, and runner/direct PR-preflight execution from a Chinese worktree path with `PYTHONUTF8=0` - native Windows: a temporary Git repository ran the real `pre-push-singleflight -> preflight_runner -> pre-push` chain with no `python3` on `PATH` - native Windows: `test_run_checks.py` -> 33 tests passed, 1 POSIX-only fixture skipped; the real manifest subprocess path also resolved `python3` to the active interpreter with an empty `PATH` - native Windows: full `test_pr_preflight.py` -> 26 tests passed, 3 explicit host-capability skips - native Windows: `test-pre-push-worktree-fallback.sh` passed against all five downstream root resolvers under the reproduced exit-128 condition - `test_pre_push_ci_prediction.py` -> 14 tests passed - `scripts/test-pre-push-diff-base.sh` passed under Git Bash - `bash -n` passed for all four touched shell scripts - Black 26.5.1 passed for the touched Python files with the repository's 120-column/no-string-normalization settings - actionlint 1.7.12 passed for the Windows workflow - `python -m py_compile` passed for all touched Python files - `scripts/failure-class validate --base origin/main --head HEAD ...` passed with `Failure-Class: none` - `git diff --check origin/main...HEAD` passed GNU Make is not installed on the local Windows host, so `scripts/test-make-setup.sh` could not be rerun there. The new regression exercises every downstream root resolver directly on native Windows; Linux CI remains authoritative for the existing Make fixture and the full manifest. The committed diff changes the manifest, so the legacy local selector intentionally attempts every manifest check. On native Windows that broad run currently stops while collecting the existing `dev-harness-unit-tests` because its qualification module imports POSIX-only `fcntl`; the path-scoped Windows workflow therefore executes the portability contracts by manifest check ID, while Linux CI remains the full-manifest authority. ## Product invariants affected none ## Failure class (fixes) Failure-Class: none
undivisible
pushed a commit
to undivisible/omi
that referenced
this pull request
Sep 29, 2026
…BasedHardware#10401) `git rev-parse --show-toplevel` exits 128 ("this operation must be run in a work tree") in a linked worktree whose git context resolves to a git dir rather than a work tree (e.g. a Conductor workspace). Three call sites assumed it always returns a path: - Makefile PYTHON collapsed to an empty prefix, breaking every target with `/scripts/dev-harness/_resolve_python.sh: No such file`. - install-git-hooks.sh aborted `make setup` at setup-hooks (Error 128). - The installed pre-commit/pre-push dispatcher aborted the hook, forcing `git push --no-verify` and silently bypassing the local gate. Makefile and the dispatcher fall back to `pwd` (make and git hooks both run from the top of the work tree) while keeping the root computed in-shell, so a checkout path with quote/`$` chars still cannot inject. install-git-hooks.sh resolves its root from the script's own location. Adds a regression to scripts/test-make-setup.sh that reproduces the 128 condition via a bare GIT_DIR and fails on the pre-fix Makefile. Failure-Class: FC-shell-source-path-interpolation fixes BasedHardware#10352
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.
What
Make repo-root resolution in
make setup, the git hook installer, and the installed hook dispatchers survive a linked worktree whose git context resolves to a git dir rather than a work tree.Why
In a linked worktree (e.g. a Conductor workspace whose gitdir lives under the main clone's
.git/worktrees/),git rev-parse --show-toplevelexits 128 withfatal: this operation must be run in a work tree. Three call sites assumed it always returns a path:Makefile—PYTHON ?= $(shell … source "$(git rev-parse --show-toplevel)/scripts/dev-harness/_resolve_python.sh" …)collapsed to an empty prefix, so every target failed with/scripts/dev-harness/_resolve_python.sh: No such fileanddev_harness_python: command not found.scripts/install-git-hooks.sh—ROOT="$(git rev-parse --show-toplevel)"abortedmake setupatsetup-hookswithError 128.git push --no-verifyand silently bypassing the local gate.AGENTS.mdmandates worktrees for all code changes, so this hit every agent working from a secondary workspace mount. Reported in #10352 (and duplicate #10293).Fix
Makefileand the dispatcher fall back topwd(git runs hooks, and make, from the top of the work tree) when--show-toplevelcan't resolve a work tree. The root stays computed in-shell and is never interpolated into recipe text, soFC-shell-source-path-interpolationstill holds (a checkout path with quote/$characters cannot inject).install-git-hooks.shresolves its root from the script's own location (${BASH_SOURCE[0]}), matching the pattern_resolve_python.shalready uses.--git-path hooksis kept as-is forHOOKS_DIR— it does not require a work tree and resolves correctly in this context.Tested
bash scripts/test-make-setup.sh— added a regression that reproduces the exact condition (bareGIT_DIR->--show-toplevelexits 128 while--git-path hooksstill resolves) and assertsPYTHONresolves. It fails on the pre-fix Makefile (PYTHON=empty, exit 1) and passes after.python3 -m pytest scripts/dev-harness/tests/test_python_resolver.py— 5 passed (the shell-injection/space-in-path contract still holds; an earlier$(REPO_ROOT)interpolation attempt was rejected by these tests).bash scripts/dev-harness/run-tests.sh— 50 passed.make setup-hookssucceeds and installs dispatchers carrying thepwdfallback; firing the installed pre-push/pre-commit dispatchers routes to the invoking worktree'sscripts/.Failure-Class: FC-shell-source-path-interpolation
Auto-generated from issue feedback by the mini issues-improver — tested and merged.