Skip to content

make setup and pre-push hook fail with 'this operation must be run in a work tree' in linked git worktrees #10293

Closed

Description

@skanderkaroui

After merging current main (head ~5b74e63582 era, which touched make setup / hook installation — scripts/test-make-setup.sh landed recently), both make setup and the installed pre-push hook fail inside a linked worktree (git worktree add ...):

$ git push origin <branch>
fatal: this operation must be run in a work tree
error: failed to push some refs to 'https://github.com/BasedHardware/omi.git'

$ make setup
fatal: this operation must be run in a work tree
make: *** [setup-hooks] Error 128

Same commands work in the primary checkout. AGENTS.md documents worktrees as the default workflow ("Always work in a git worktree for code changes") and says hooks are installed "with linked-worktree-safe paths", so this looks like a regression in the new setup/hook scripts — likely a git invocation that resolves --git-dir to the shared common dir and then requires a work tree.

Workaround used: ran the full make preflight manifest manually (green) and pushed with --no-verify.

Activity

  1. moved this from Someday to In progress in omi TODO / bountieson Jul 24, 2026
  2. tianmind-studio commented on Jul 27, 2026

    @tianmind-studio
    Contributor

    The full-chain fix from #10491 is now preserved in #10574, including Nik Shevchenko's co-author credit. I adapted its regression to the PR's explicit Windows Python launcher contract and registered it in both manifest lanes plus the native Windows workflow.

    Current main still lacked the five downstream root fallbacks after the Makefile/dispatcher fix: scripts/pre-push, scripts/pre-push-singleflight, scripts/pr-preflight, .github/scripts/preflight_runner.py, and .github/scripts/pr_preflight.py. On the refreshed #10574 head (a0a4622002), the native Windows linked-worktree regression passes across all five entrypoints, and the three-check Windows manifest run is green.

  3. Git-on-my-level commented on Jul 29, 2026

    @Git-on-my-level
    Member

    Both reported symptoms (make setup → setup-hooks Error 128 and git push → pre-push hook "this operation must be run in a work tree" in a linked worktree) are fixed at HEAD by merged PR #10401 — fix(setup): resolve repo root without a work tree in linked worktrees (merged 2026-07-23, an ancestor of current HEAD).

    Verifiable at HEAD:

    • Makefile:1 — HOOKS_DIR := $(shell git rev-parse --git-path hooks). --git-path resolves the hook dir without requiring a work tree, so it never exits 128 in a linked-worktree git-dir context.
    • Makefile:9 — PYTHON ?= $(shell bash -c 'source "$$(git rev-parse --show-toplevel 2>/dev/null || pwd)/scripts/dev-harness/_resolve_python.sh"; dev_harness_python'). The || pwd fallback is exactly the linked-worktree repair (previously an empty prefix turned every target into /scripts/dev-harness/_resolve_python.sh: No such file).
    • scripts/install-git-hooks.sh (the setup-hooks installer and the runtime hook dispatcher) resolves ROOT from the script's own path rather than show-toplevel, and uses --git-path hooks. The installed pre-push dispatcher falls back: ROOT="$(git rev-parse --show-toplevel 2>/dev/null || pwd)" (Git runs hooks with cwd at the worktree top, so this resolves).
    • scripts/test-make-setup.sh:103-141 is a regression test that reproduces the bare-GIT_DIR condition (show-toplevel exits 128 while --git-path hooks still resolves) and asserts the Makefile root no longer collapses.

    The still-open #10574 is a separate follow-up — Windows Python-launcher portability hardening that adds fallbacks to the downstream pre-push/pre-push-singleflight/pr-preflight/preflight_runner.py/pr_preflight.py entrypoints. It is not required for the macOS/Linux linked-worktree regression reported here: in the normal hook-execution context Git sets cwd to the worktree top, so those scripts' git rev-parse --show-toplevel already resolves. Closing on the merged, HEAD-present fix (#10401).

  4. moved this from In progress to In review in omi TODO / bountieson Jul 29, 2026
  5. added a commit that references this issue on Jul 30, 2026
    d524678
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions