make hooks and make docker both fail when run from a git worktree
#33
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Problem
Two independent bugs make this repo hostile to
git worktreecheckouts. Both were hit during real work on PR #31 and cost time to diagnose and work around.1.
script/install-precommitwrites to a path that does not exist in a worktreeThe script writes
.git/hooks/pre-commitdirectly. In a linked worktree,.gitis a file containing agitdir:pointer, not a directory — so there is no.git/hooks/to write into:make hookstherefore fails outright in any worktree.The fix is one line: resolve the hooks directory with
git rev-parse --git-common-dirinstead of assuming the literal path. That returns the shared.gitof the main checkout from inside a worktree, and the plain.gitdirectory otherwise, so it is correct in both cases.Note
backend/Makefile'shookstarget has the same flaw — it uses$(git rev-parse --show-toplevel)/.git/hooks/pre-commit, which is wrong for the same reason. That target is slated for removal in #16; if #16 lands first this half is moot, so check before duplicating work.2.
Dockerfile.backend'sCOPY .git /repo/.gitbreaks in a worktreeThe Docker build copies
.gitsobackend/Makefile'sgit describecan resolve a version. From a worktree,.gitis the pointer file, so the copy produces something unusable andgit describefails inside the build.make dockercannot be run from a worktree at all.This half is already addressed by #17, which replaces the
.gitcopy withARG VERSIONper the mandated Go Dockerfile pattern. It is recorded here only so the two symptoms are documented together — do not fix it twice. If #17 lands first, close this half as resolved.Why this matters beyond convenience
Worktrees are the standard isolation mechanism for concurrent work in this repo. Every implementer and reviewer is expected to work in one. Both of these bugs are hit on essentially every backend change, and the workarounds are non-obvious:
make setupin a worktree gets a hard failure on a target that is supposed to be routine.That is a tax on every future change, and it invites a worse outcome: an agent that cannot run
make dockerfrom its worktree may skip the Docker gate rather than work around it, and a gate that is inconvenient enough to skip is not a gate.Definition of done
script/install-precommitresolves the hooks directory viagit rev-parse --git-common-dir(or equivalent) rather than the literal.git/hookspath.make hookssucceeds from a linked worktree and from a normal clone. Verify both explicitly and report both results.make dockersucceeds from a linked worktree. If #17 has already landed, verify this still holds rather than re-implementing; if it has not, coordinate — say in the PR which issue you are relying on.backend/Makefile'shookstarget still exists at implementation time, it gets the same fix or is removed per #16.make checkpasses at the root and inbackend/.TODO.mdupdated in the same commit.(closes #N).Implementation requirements
script/files stay POSIX sh:#!/bin/sh,set -eu, no bashisms.script/install-precommitis close to a model script shared across repos — if the fix is generally correct (it is), note in the PR that it is worth upstreaming tosneak/promptsrather than diverging here. See #28, which tracks script drift from the models.maketargets andscript/entrypoints only.