Skip to content

test: isolate the git environment in cmd/ git-subprocess tests#18

Merged
REPPL merged 1 commit into
mainfrom
test/isolate-git-test-env
Jul 8, 2026
Merged

test: isolate the git environment in cmd/ git-subprocess tests#18
REPPL merged 1 commit into
mainfrom
test/isolate-git-test-env

Conversation

@REPPL

@REPPL REPPL commented Jul 8, 2026

Copy link
Copy Markdown
Owner

Defence-in-depth for the concurrency-corruption hazard in #17.

The cmd/ test helpers scoped the repo (-C <tempdir>) but ran git with append(os.Environ(), …) — which inherits host GIT_* (a stray GIT_DIR could redirect a command at the real repo) and reads the developer's real ~/.gitconfig.

This adds a package-cmd gitIsolatedEnv() mirroring the evals/ harness helper:

  • strips every inherited GIT_* variable,
  • neutralises system/global config discovery (GIT_CONFIG_NOSYSTEM=1, GIT_CONFIG_GLOBAL=/dev/null),
  • pins a distinctive ferry-test identity via env.

The repo's LOCAL .git/config is untouched, so the git-hardening tests still exercise their hostile local config (verified: cmd suite green). Also drops the bare t <t@localhost> fixture identity that made the recent mis-attribution hard to trace — future leaks are now obviously test-originated.

Refs #17. Test-only; no user-facing change. gofmt/vet/go test ./... green.

Note: the operational half of #17 (don't run git-mutating ops concurrently with a test/tooling run) remains a discipline/guardrail, not a code fix.

Assisted-by: Claude:claude-opus-4-8

The cmd/ test helpers scoped the repo (-C <tempdir>) but ran git with append(os.Environ()), which inherits host GIT_* (a stray GIT_DIR could redirect a command at the real repo) and reads the developer's real ~/.gitconfig. Add a package-cmd gitIsolatedEnv() mirroring the evals harness helper: strip every inherited GIT_* var, neutralise system/global config discovery (GIT_CONFIG_NOSYSTEM=1, GIT_CONFIG_GLOBAL=/dev/null), and pin a distinctive ferry-test identity via env. The repo's LOCAL .git/config is untouched, so the git-hardening tests still exercise their hostile local config. Also drops the bare 't <t@localhost>' fixture identity that made the recent mis-attribution leak hard to trace. Defence-in-depth for the concurrency-corruption hazard in issue #17. Refs #17.
@REPPL
REPPL merged commit ad02baf into main Jul 8, 2026
12 checks passed
@REPPL
REPPL deleted the test/isolate-git-test-env branch July 8, 2026 20:36
REPPL added a commit that referenced this pull request Jul 18, 2026
Concurrent heavy git activity (a worktree add during an in-flight go
test) once corrupted the working repo's state: core.bare flipped and an
isolated test fixture's git identity leaked into the local config. The
code-side hardening landed in #18; this records the operational
guardrail in CONTRIBUTING.md and AGENTS.md, the remaining prevention
item.

Closes #17

Assisted-by: Claude:claude-fable-5
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