pub enum EnvPolicy {
ClearLocal,
ClearAll,
Inherit,
}Expand description
Which inherited GIT_* environment variables a command clears before
spawning git.
Composite operations (git commit, git rebase) and hooks export GIT_*
variables to pin child git processes to their repository and index. A
git_proc command spawned in that context — a hook, a git rebase -x, or a
test launched from one — would otherwise be hijacked onto the ambient
repository instead of the one named by -C or the positional directory; most
dangerously GIT_INDEX_FILE, which no command-line flag can override.
Variants§
ClearLocal
Clear git’s repository-local variables — GIT_DIR, GIT_INDEX_FILE,
GIT_WORK_TREE, and the rest of git rev-parse --local-env-vars, the
exact set git clears when entering another repository. Fixes the hijack
while leaving global config/auth (GIT_SSH_COMMAND, GIT_ASKPASS,
GIT_CONFIG_GLOBAL) intact. The default.
ClearAll
Clear every inherited GIT_* variable. Maximally hermetic, but also drops
env-based auth/config.
Inherit
Inherit the ambient git environment unchanged.