Skip to content

fix(workspace): report git hooks as live in a linked worktree - #1461

Merged
c-vigo merged 4 commits into
release/1.8.0from
bugfix/1454-doctor-linked-worktree
Aug 12, 2026
Merged

c-vigo merged 4 commits into
release/1.8.0from
bugfix/1454-doctor-linked-worktree

Conversation

@c-vigo

@c-vigo c-vigo commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

Description

Fixes #1454. Targets release/1.8.0 (post-recovery base 9cce85ed).

just doctor reported WARN git hooks: … tracked but inert inside a linked worktree where the hooks are live, and the remediation it offered would have undone the worktree setup. A diagnostic that lies is the exact failure class #1430 exists to close.

just worktree-start unsets core.hooksPath on purpose — prek refuses to install its shims while it is set — and installs the shims instead. hooks is one of git's shared paths, so they land in the common git dir and git runs them from inside the worktree. Both doctor recipes read that intended state as the fresh-clone failure.

Type of Change

  • fix -- Bug fix
  • test -- Adding or updating tests

Modifiers

  • Breaking change (!) -- This change breaks backward compatibility

Changes Made

  • justfile -- devkit's doctor: linked-worktree PASS branch ahead of the fresh-clone WARN.
  • assets/workspace/justfile -- the scaffolded doctor: identical branch, inserted after the mode-aware hint construction so [FEATURE] Ship a doctor recipe on the consumer surface (host preflight for scaffolded repos) #1448's hints are untouched.
  • tests/bats/doctor.bats -- 3 tests + hermetic _git_fixture / _init_linked_worktree helpers (real git worktree add under BATS_TEST_TMPDIR, pinned identity, signing off).
  • tests/bats/consumer-doctor.bats -- 3 tests + _run_doctor_at / _scaffold_linked_worktree (commits the fixture so the linked checkout really carries justfile, .githooks, .vig-os).
  • CHANGELOG.md (+ hook-synced mirror) -- entry under the 1.8.0 ### Fixed.

Two mechanics the obvious implementation gets wrong, both established empirically rather than assumed:

  • .git is a file in a linked worktree, so a literal .git/hooks/pre-commit test can never see the shim. This uses git rev-parse --git-path hooks/pre-commit — the file git itself would run.
  • git rev-parse --absolute-git-dir vs --path-format=absolute --git-common-dir is the safe comparison. A plain --git-dir / --git-common-dir compare falsely reports "linked" from a subdirectory of the main worktree (/abs/.git vs ../.git). This is also the idiom flake.nix's githooksPathHook already uses.

The PASS additionally requires the shim to be executable (-x), since git ignores a non-executable hook.

Verdict matrix

worktree core.hooksPath installed hooks/pre-commit verdict
main .githooks any PASS core.hooksPath -> .githooks
main unset none WARN fresh-clone
main unset present WARN fresh-clone (unchanged — see notes)
main other any WARN naming the value
linked .githooks any PASS (still live; pinned by a new test)
linked unset present PASS linked worktree, installed at <path> (core.hooksPath unset by design)
linked unset none WARN fresh-clone — genuinely inert
linked other any WARN naming the value
not a repo — — WARN (the -n "$gitdir" guard keeps it out of the PASS branch)

Changelog Entry

### Fixed

- **`just doctor` no longer calls the git hooks inert inside a linked worktree** ([#1454](https://github.com/vig-os/devkit/issues/1454))

Placed in ## [1.8.0] - TBD, matching every post-freeze entry on this branch.

Testing

  • Tests pass locally
  • Manual testing performed (describe below)

Manual Testing Details

Real clone + git worktree add + the exact worktree-start setup (unset-all core.hooksPath, prek install):

BEFORE:

WARN git hooks: core.hooksPath not set, .githooks is tracked but inert (run: ./scripts/init.sh)

AFTER:

PASS git hooks: linked worktree, installed at /…/demo/.git/hooks/pre-commit (core.hooksPath unset by design)

AFTER, same worktree with the shims deleted (must-stay-WARN case):

WARN git hooks: core.hooksPath not set, .githooks is tracked but inert (run: ./scripts/init.sh)

The verdicts are grounded in behavior, not inference: in the live worktree git commit -m "bad message" was rejected by validate-commit-msg; after deleting the shims the same commit landed unblocked, confirming the WARN is true in that state.

  • RED: bats tests/bats/doctor.bats tests/bats/consumer-doctor.bats -> exit 1, exactly 2 failures (not ok 6, not ok 23), both showing the lying WARN. The other 4 new tests passed as intended — they pin cells that must not move.
  • GREEN: same command -> 26/26 ok, exit 0.
  • Full bats after merging the recovered release/1.8.0: 502 ok, 0 not ok, exit 0.
  • prek run --all-files -> exit 0, tree clean.
  • Full pytest -> 776 passed, 20 skipped, 1 failed — the known stale-image test_manifest_files, verified pre-existing two ways (branch-point changelog sha already differs from the image's baked copy; re-ran with the pristine changelog checked out and it still failed).

Checklist

  • My code follows the project's style guidelines
  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • I have updated the documentation accordingly
  • I have updated CHANGELOG.md (and pasted the entry above)
  • My changes generate no new warnings or errors
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published

Additional Notes

Drift guard intact. #1448's consumer doctor checks exactly what devkit's doctor checks passes — the new PASS keeps the git hooks label, so both label sets stay identical. All mode-aware hint tests pass, and refute_output --partial "scripts/init.sh" was added to both new consumer tests.

Deliberately unchanged: main worktree + unset core.hooksPath + a prek shim in .git/hooks still WARNs. The gates are live there too, so the WARN is under-informative — but it is literally true (.githooks is inert) and its remediation is harmless. #1454 explicitly says to keep the fresh-clone WARN for every other unset case, so that cell was left alone and not pinned either way. Worth a follow-up if doctor should key purely off "what will git execute".

Separate bug found, not fixed here: git config --unset-all core.hooksPath inside a linked worktree writes to the shared config, so just worktree-start silently unsets core.hooksPath for the main checkout too, leaving its .githooks inert until something re-sets it. Reproduced. Deserves its own issue — and doctor will now correctly WARN about it.

The base merge resolved one additive CHANGELOG.md conflict by keeping both this entry and the restored #1447 entry (#1459 recovery); the 1.8.0 section was re-audited afterwards and all entries carry their title bullets.

Closes #1454

Refs: #1454

@c-vigo
c-vigo merged commit 4c6d57d into release/1.8.0 Aug 12, 2026
12 checks passed
@c-vigo
c-vigo deleted the bugfix/1454-doctor-linked-worktree branch August 12, 2026 11:03
c-vigo added a commit that referenced this pull request Aug 12, 2026
…ling (#1471)

## Summary

After #1463 (PR #1464), `just worktree-start` no longer unsets
`core.hooksPath` — a configured hooks path is left untouched (the
tracked `.githooks` shims cover the new worktree) and the prek install
into the shared `.git/hooks` survives only as the fallback when no hooks
path is set. The #1454 doctor comments in both `justfile` copies still
asserted the old behavior was "the INTENDED state ... on purpose", which
would actively mislead the next hook-state investigation (the #1430 →
#1454 → #1461 → #1463 chain shows how much debugging here leans on these
comments).

## Changes

Comment-only, zero behavior delta:

- `justfile` + `assets/workspace/justfile`: the doctor linked-worktree
comment now describes post-#1463 reality — the shared-hooks PASS branch
covers the no-hooksPath fallback plus worktrees created before #1463; a
post-fix worktree keeps the shared setting and hits the normal
`.githooks` PASS branch. The `--git-path` rationale and the copies'
one-phrase wording difference are preserved. (These are independent
copies — `scripts/manifest.toml` mirrors only
`justfile.gh`/`justfile.worktree` — so both needed the hand edit.)
- `tests/bats/doctor.bats`, `tests/bats/consumer-doctor.bats`,
`tests/test_flake_hooks.py`: the same stale claim repeated in test
comments, folded in per the scope note on the issue.

Doctor logic and echo strings untouched; no changelog entry (internal
docs). TDD skipped: comment-only, non-testable.

## Verification

`bats tests/bats/doctor.bats tests/bats/consumer-doctor.bats` → 26/26
ok; full `prek run --all-files` → exit 0; clean tree.

Closes #1469
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