Unset GIT_INDEX_FILE for git+ VCS subprocesses #14291
All Vouch review confidence checks passed
Residual risk 0.25 = Change Risk (0.46) × (1 − Review Confidence (0.45)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.46 · 247 lines diff across 3 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.02 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Shallow Review Depth
shallow_review_depth
0.344
Diff Size
diff_size
0.330
Real PR Conversation Timeline
1 comments
"Review active on #14291"
general
weight: 0.35
2ykwang
Fixes #14290
What
Git.unset_environinpip/_internal/vcs/git.pyalready stripsGIT_DIRandGIT_WORK_TREEfrom git subprocesses spawned forgit+VCS installs (#1130), but notGIT_INDEX_FILE. This PR adds it.Why
gitsetsGIT_INDEX_FILEwhen invoking hooks (e.g.pre-commit), pointing at the index of the repo/worktree currently being committed. If such a hook runs agit+-pinnedpip install(directly, or via a tool likepip-audit), the inheritedGIT_INDEX_FILEcauses pip's owngit checkout— run inside its throwaway temp clone of the dependency — to write its checked-out tree into the hook-invoking repo's index instead of its own. Those entries reference blobs that only ever existed in the temp clone (deleted right after pip finishes), sogit fsck/git diff --stagedin the caller's repo comes back withmissing blob/invalid sha1 pointer in cache-treeerrors. This is fully deterministic — onegit commitis enough, no concurrency needed. Repro steps and more detail are in #14290.Testing
Added
test_git_index_file_ignored, mirroring the existingtest_git_dir_ignored/test_git_work_tree_ignoredpattern: stages a file in a "work" repo withGIT_INDEX_FILEpointed at a separate "victim" repo's index, and asserts the victim index is untouched.ruff checkandruff format --checkclean on both changed files.PR Checklist:
Assisted-by: Claude