Problem
cleanGitRepoEnv was added to isolate Git ref resolution from repo-scoped environment leakage such as GIT_DIR, GIT_WORK_TREE, alternate object/index paths, namespace, prefix, quarantine state, and inline GIT_CONFIG_COUNT config injected by surrounding processes.
A review on the subagent/panel branch raised a plausible edge case: the current sanitizer also removes GIT_CONFIG_GLOBAL and GIT_CONFIG_SYSTEM. CI or containerized environments may intentionally set those variables for controlled Git configuration, for example safe.directory or system/global config isolation.
Why this needs a focused follow-up
This code is delicate because it sits between daemon/CI/test execution and Git process environment inheritance. The original isolation was intentional and should not be weakened casually. The right fix is to audit which environment variables are repository-scoped versus configuration-selector variables, then add focused tests for both cases.
Suggested investigation
- Confirm which variables must be stripped to prevent stale repository context from affecting
ResolveSHA.
- Decide whether
GIT_CONFIG_GLOBAL and GIT_CONFIG_SYSTEM should be preserved, stripped, or handled only under specific test/CI conditions.
- Add regression tests covering:
- stale
GIT_DIR / GIT_WORK_TREE cannot redirect ref resolution;
- config selector variables do not break intended controlled Git config, if preserved;
- inline
GIT_CONFIG_COUNT config remains stripped if it can override command behavior unexpectedly.
Context
The speculative branch-local fix was reverted from feat/proper-subagent-reviews; this should be addressed in a separate PR.
Problem
cleanGitRepoEnvwas added to isolate Git ref resolution from repo-scoped environment leakage such asGIT_DIR,GIT_WORK_TREE, alternate object/index paths, namespace, prefix, quarantine state, and inlineGIT_CONFIG_COUNTconfig injected by surrounding processes.A review on the subagent/panel branch raised a plausible edge case: the current sanitizer also removes
GIT_CONFIG_GLOBALandGIT_CONFIG_SYSTEM. CI or containerized environments may intentionally set those variables for controlled Git configuration, for examplesafe.directoryor system/global config isolation.Why this needs a focused follow-up
This code is delicate because it sits between daemon/CI/test execution and Git process environment inheritance. The original isolation was intentional and should not be weakened casually. The right fix is to audit which environment variables are repository-scoped versus configuration-selector variables, then add focused tests for both cases.
Suggested investigation
ResolveSHA.GIT_CONFIG_GLOBALandGIT_CONFIG_SYSTEMshould be preserved, stripped, or handled only under specific test/CI conditions.GIT_DIR/GIT_WORK_TREEcannot redirect ref resolution;GIT_CONFIG_COUNTconfig remains stripped if it can override command behavior unexpectedly.Context
The speculative branch-local fix was reverted from
feat/proper-subagent-reviews; this should be addressed in a separate PR.