Why: the `git rev-parse --local-env-vars` loop in clean-git-env.sh also unset GIT_CONFIG_PARAMETERS / GIT_CONFIG_COUNT, silently dropping `git -c` overrides (extraHeader, credentials, safe.directory) that apm's remote clones may need. Only the repo-locating vars caused #204. Implementation Notes: - clean-git-env.sh now unsets an explicit list only: GIT_DIR, GIT_WORK_TREE, GIT_INDEX_FILE, GIT_OBJECT_DIRECTORY, GIT_COMMON_DIR, GIT_PREFIX, GIT_IMPLICIT_WORK_TREE; gates.md updated to match. - apm-pack-check-clean.sh points at the real gates.md paragraph. - run-tests.sh's comment now says git exports GIT_DIR to hooks only from a linked worktree, matching LESSONS.md. - test-apm-hooks-git-env.sh isolates from global/system git config. - Reflow the "Two of these shell out to apm" paragraph in gates.md. Refs #204 Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_014uGZTNugst7K9Bd2FTR4Mi
21 lines
1.1 KiB
Bash
21 lines
1.1 KiB
Bash
#!/usr/bin/env bash
|
|
# Scrubs git's repo-locating environment variables from the current shell, so
|
|
# every git process it spawns -- directly or through another tool -- discovers
|
|
# its repository from its own working directory. Issue #204.
|
|
#
|
|
# Why: `git push` from a LINKED worktree exports an absolute
|
|
# GIT_DIR=<main>/.git/worktrees/<name> to its hooks (from the main checkout it
|
|
# exports none). A hook that runs a tool which itself runs git in a temp dir --
|
|
# apm's drift replay does `git init` / `git checkout` there with os.environ --
|
|
# hands that GIT_DIR on, and the temp-dir git operates on THIS repo instead:
|
|
# core.bare=true in the shared .git/config, and the worktree's HEAD moved to a
|
|
# lock-pinned commit. Hooks run from the worktree root, so plain discovery
|
|
# finds the right repo once these are gone.
|
|
#
|
|
# Config-passing vars (GIT_CONFIG_PARAMETERS, GIT_CONFIG_COUNT) are kept on purpose: they carry `git -c` overrides apm's remote clones may need.
|
|
#
|
|
# Not meant to be executed directly -- source it before any git call.
|
|
|
|
unset GIT_DIR GIT_WORK_TREE GIT_INDEX_FILE GIT_OBJECT_DIRECTORY GIT_COMMON_DIR \
|
|
GIT_PREFIX GIT_IMPLICIT_WORK_TREE
|