Install hooks into the repo's own hooks dir, ignoring core.hooksPath

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
christianandClaude Opus 5.5 committed 2026-10-21 00:55:32 +02:00
1 parent 24541f0602
commit 480ed6a8b2
2 files changed
+19 -2

No files matched your search

+4 -1
View File
@@ -5,10 +5,13 @@
# (and so their hooks) run outside the sandbox. Re-run after changing anything in .githooks/.
set -e
cd "$(dirname "$0")/.."
if ! hooks=$(git rev-parse --git-path hooks 2>/dev/null); then
# Use the repo's own hooks directory, not `git rev-parse --git-path hooks`: that follows a
# (possibly global) core.hooksPath and would install these hooks for every repo.
if ! common=$(git rev-parse --git-common-dir 2>/dev/null); then
echo "install-hooks: not a git checkout; skipping." >&2
exit 0
fi
hooks="$common/hooks"
mkdir -p "$hooks"
for hook in .githooks/*; do
cp "$hook" "$hooks/"