Repository navigation
fix(tests): ignore an inherited git repository environment (#2003) - #2337
Merged
Merged
Conversation
DeusData
force-pushed
the
fix/issue-2003
branch
from
September 30, 2026 20:13
8e12fc8 to
fb5333f
Compare
Git exports repository-local variables (GIT_DIR, GIT_INDEX_FILE, GIT_WORK_TREE, ...) into hooks, and they take precedence over `git -C <dir>`. Every fixture git command in the test runner therefore acted on the caller's real repository whenever the suite ran with those variables set: with GIT_DIR alone, fixture assertions failed and commits, branches and linked worktrees were written into the caller's clone; with the full hook set, fixture commits failed and git-dependent tests degraded to "git not available" SKIPs. The pre-commit hook already clears the variables (7883507), but any other caller (a shell with GIT_DIR set, an editor hook, `GIT_DIR=... scripts/test.sh`) still hit it. The test runner and the repro runner now clear git's local-env list (`git rev-parse --local-env-vars`) once at startup, before any fixture or re-exec'd child spawns git, so every fixture scopes to its own repository no matter who invokes the suite. tests/test_git_env_isolation_contract.sh (Step 3a of scripts/test.sh) drives the real runner's git_context suite with GIT_DIR, and with the full hook set, aimed at a throwaway decoy repository. It requires the same pass/skip summary as a clean run and a decoy left untouched (no refs, no linked worktrees). Signed-off-by: Martin Vogel <[email protected]>
DeusData
force-pushed
the
fix/issue-2003
branch
from
September 30, 2026 22:34
fb5333f to
cf72f1a
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Git exports repository-local variables (GIT_DIR, GIT_INDEX_FILE,
GIT_WORK_TREE, ...) into hooks, and they take precedence over
git -C <dir>. Every fixture git command in the test runner thereforeacted on the caller's real repository whenever the suite ran with those
variables set: with GIT_DIR alone, fixture assertions failed and commits,
branches and linked worktrees were written into the caller's clone; with
the full hook set, fixture commits failed and git-dependent tests degraded
to "git not available" SKIPs. The pre-commit hook already clears the
variables (7883507), but any other caller (a shell with GIT_DIR set, an
editor hook,
GIT_DIR=... scripts/test.sh) still hit it.The test runner and the repro runner now clear git's local-env list
(
git rev-parse --local-env-vars) once at startup, before any fixture orre-exec'd child spawns git, so every fixture scopes to its own repository
no matter who invokes the suite.
tests/test_git_env_isolation_contract.sh (Step 3a of scripts/test.sh)
drives the real runner's git_context suite with GIT_DIR, and with the full
hook set, aimed at a throwaway decoy repository. It requires the same
pass/skip summary as a clean run and a decoy left untouched (no refs, no
linked worktrees).
Test-suite half of #2003. The production half (cbm's own git children) is the separate
fix/git-spawn-local-envPR; once both land, the test helper can reusecbm_git_repo_env_vars. Thanks to @metehanulusoy for the report and analysis, and @AmirF194 for the reproduction.Fixes #2003