Skip to content

fix: strip GIT_* env vars from git subprocesses - #42

Closed
alecthomas wants to merge 1 commit into
mainfrom
aat/git-env-sanitize
Closed

alecthomas wants to merge 1 commit into
mainfrom
aat/git-env-sanitize

Conversation

@alecthomas

Copy link
Copy Markdown
Collaborator

lhm shells out to git to read and modify repository state. When it runs
as a git hook -- or when its test suite is driven by an outer git
invocation carrying -c overrides -- git exports GIT_DIR,
GIT_CONFIG_PARAMETERS, and friends. Inherited by our child git
processes, these silently redirect which repository is queried or
rewrite the URLs git reports (e.g. url..insteadOf), so a command
no longer reflects the directory we asked about.

Route every git invocation through a helper that removes the entire
GIT_ namespace, rather than blacklisting individual variables.

Co-Authored-By: Claude Opus 4.8 (1M context) noreply@anthropic.com

lhm shells out to git to read and modify repository state. When it runs
as a git hook -- or when its test suite is driven by an outer git
invocation carrying -c overrides -- git exports GIT_DIR,
GIT_CONFIG_PARAMETERS, and friends. Inherited by our child git
processes, these silently redirect which repository is queried or
rewrite the URLs git reports (e.g. url.<base>.insteadOf), so a command
no longer reflects the directory we asked about.

Route every git invocation through a helper that removes the entire
GIT_ namespace, rather than blacklisting individual variables.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@alecthomas

Copy link
Copy Markdown
Collaborator Author

🤖 Closing — dropping the git-env hardening. The failing test was an artifact of a git -c url."…".insteadOf push workaround (exported as GIT_CONFIG_PARAMETERS), not a real scenario; normal git push, CI, and cargo test are unaffected. Keeping the hook path on git's ambient environment.

@alecthomas alecthomas closed this Jul 2, 2026
@alecthomas
alecthomas deleted the aat/git-env-sanitize branch July 2, 2026 05:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant