test: isolate git config in attach tests to fix TempDir cleanup flake

main

Commit

Soph3mo ago

TestAttachCmd_* / TestReviewAttach_* intermittently failed in t.TempDir cleanup, not on an assertion:

Root cause (COR-394): attach runs git commit --amend via the git CLI (attach.go), which inherits the process env and the developer's real git config. With default gc.auto/gc.autoDetach, the commit forks a detached git gc that keeps writing into the temp repo's .git/objects after rootCmd.Execute() returns, racing Go's deferred os.RemoveAll.

setupAttachTestRepo set up repo-local identity (testutil.InitRepo) but never isolated global/system git config, so the gc-disabling pins didn't apply. Add testutil.IsolateGitConfigEnv(t) — it sets GIT_CONFIG_GLOBAL/SYSTEM to the isolation config (gc.auto=0, gc.autoDetach=false, maintenance.auto=false), the central remedy for exactly this race. Compatible with the helper's existing t.Chdir (both non-parallel).

Co-Authored-By: Claude Opus 4.8 (1M context) noreply@anthropic.com Entire-Checkpoint: 9a948bc09627

Checkpoints

so in ../entiredb "filtered_fetches" is enabled, now today one of my coworkers had this issue:

Claude Code
View session
Checkpoint 1