Skip to content

A worktree is a checkout - #53

Merged
dimeloper merged 1 commit into
mainfrom
fix/doctor-reads-a-worktree-as-a-checkout
Sep 22, 2026
Merged

dimeloper merged 1 commit into
mainfrom
fix/doctor-reads-a-worktree-as-a-checkout

Conversation

@dimeloper

Copy link
Copy Markdown
Owner

make doctor reported ok for a question it never asked.

check_submodules() {
  if [ ! -d "${STANDARDS_DIR}/.git" ]; then
    ok "engine checkout is not a git repo — nothing to check for submodule drift"

In a worktree .git is a file holding a gitdir: pointer, not a directory.
So the guard read "not a git repo", the check returned, and it printed a pass.

A false clean is worse than a wrong finding, and this one sat in a load-
bearing place: the engine is routinely developed in a worktree — v0.58.0,
v0.59.0 and v0.59.1 were each built in one — so submodule drift in exactly the
checkouts the last three releases were cut from went unreported behind an ok.

That is not hypothetical. The first run after the fix, in the worktree the fix
was written in:

before:  ok    engine checkout is not a git repo — nothing to check for submodule drift
after:   warn  submodule not initialized (a1dc48e6… vendor/obsidian-skills)
              — run: git submodule update --init --recursive

The submodule really was uninitialised, all day, in every worktree this week.

The fix

git rev-parse --git-dir, which is true in a checkout, a worktree and a
submodule alike — the question actually being asked, rather than a guess at
what a repo looks like on disk.

Testing

The test builds its own sandbox repo and worktree rather than reading this
checkout, so the assertion does not depend on where the suite happens to run
from. It asserts the fixture is really a worktree first — .git is a file, not
a directory — or the whole thing would pass for the wrong reason.

Both new assertions confirmed failing against the pre-fix script:

FAIL an empty rules directory does not abort the remaining checks
FAIL a worktree is not reported as 'not a git repo'

The first of those is the assertion that has been failing in every worktree run
all week and passing in CI; it is fixed by the same change, which is what
identified the cause.

make lint clean. test-doctor.sh 60 passed.

🤖 Generated with Claude Code

check_submodules gated on `[ -d "${STANDARDS_DIR}/.git" ]`. In a worktree
`.git` is a file holding a `gitdir:` pointer rather than a directory, so that
read answered "not a git repo" and the check passed by declaring there was
nothing to check.

A false clean is the one answer worse than a wrong finding, and this one was
load-bearing: the engine is routinely developed in a worktree — v0.58.0,
v0.59.0 and v0.59.1 were each built in one — so submodule drift in exactly the
place the last three releases were cut went unreported behind an `ok`.

`git rev-parse --git-dir` is true in a checkout, a worktree and a submodule
alike, which is the question being asked. The first run after the fix, in the
worktree it was written in, turned the false ok into a real "submodule not
initialized" warning.

The test builds its own sandbox repo and worktree rather than reading this
checkout, so the assertion does not depend on where the suite happens to run
from — and it asserts the fixture is really a worktree first, or it would pass
for the wrong reason.
@dimeloper
dimeloper merged commit c0fa7c7 into main Sep 22, 2026
4 checks passed
@dimeloper
dimeloper deleted the fix/doctor-reads-a-worktree-as-a-checkout branch September 22, 2026 12:33
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