From ba53e6544bcfc03c72e237152562b34abce78908 Mon Sep 17 00:00:00 2001 From: Defame1297 Date: Sun, 5 Jul 2026 12:52:52 +0000 Subject: [PATCH] fix(tests): isolate test-git-hooks-install.sh from inherited GIT_* env vars The test's own `git -C "$TEMP_REPO" init` silently re-targets an inherited GIT_DIR instead of creating a repo in the temp dir when this test itself runs inside a git hook (e.g. pre-push sets GIT_DIR to the invoking repo's gitdir). Unset all GIT_* vars at the top of the script so the temp repo fixture is actually isolated regardless of the calling context. Co-Authored-By: Claude Sonnet 5 Claude-Session: https://claude.ai/code/session_01FNJWdVvdgvZCHi1hZGqgVQ --- tests/test-git-hooks-install.sh | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tests/test-git-hooks-install.sh b/tests/test-git-hooks-install.sh index b4fd5aa..8a36350 100755 --- a/tests/test-git-hooks-install.sh +++ b/tests/test-git-hooks-install.sh @@ -3,6 +3,12 @@ # Runs install.sh from a temp repo to avoid touching the real .git/hooks/. set -euo pipefail +# This script may itself run inside a git hook (e.g. pre-push), which sets +# GIT_DIR/GIT_EXEC_PATH/etc. in the environment. `git init`/`git -C` below +# would silently re-target the inherited GIT_DIR instead of creating an +# isolated repo in $TEMP_REPO, so start from a clean slate. +for var in $(compgen -v | grep '^GIT_'); do unset "$var"; done + REPO_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" PASS=0 FAIL=0