script/install-precommit fails in a linked worktree: .git is a file, not a directory #129
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?
script/install-precommithardcodes the hooks path:In a linked worktree
.gitis a file, not a directory. Verified in this repo:So the redirect targets a path under a regular file and
make hooksfails outright there.Why it matters here
All implementation and review work on this repo happens in throwaway linked worktrees — that is a standing rule, since concurrent sessions collided in the shared checkout once already. So
make hooksis broken in exactly the environment every agent actually works in. The implementer of PR #128 hit this and had to commit with--no-verify, runningmake checkexplicitly instead.Note the hook is not entirely absent from worktrees: git resolves hooks via the common git dir, so a hook installed once from the main checkout does run in linked worktrees. The defect is specifically that
install-precommitcannot be run from one. That distinction matters — it means the exposure is "agents can't install the hook", not necessarily "no agent has ever had one".Definition of done
script/install-precommitworks from the main checkout and from a linked worktree.git rev-parse --git-path hooksresolves correctly in both and is the idiomatic fix; create the directory if absent.script/install-precommitstays POSIXsh(#!/bin/sh,set -eu, no bashisms);sh -nclean; keeps the$(cd "$(dirname "$0")/.." && pwd -P)idiom.make checkgreen;TODO.mdupdated in the same commit.Commit title ends with
(closes #N).Constraints
.golangci.yml(sha256021cc83f4e6fc7c31b95b34b846723dfcf20b66b7baeea1dc40406e643346bcb) or the golangci-lint pin.parallel golangci-lint is running, or names any path starting with../, or any absolute path outside your worktree.Coordination
Touches
script/install-precommitonly — no overlap with #115/#122 (script/cibuild), #117 (script/bootstrap), #119 (script/fmt,script/fmt-check), or #121/#128 (script/lint).script/install-precommitis byte-identical across repos, so this belongs upstream in the shared template as well; it is already known there as one of the Scripts to Rule Them All defects.