Repository navigation
fix: stop pre-push tests writing to the repository's git config - #424
stuartwdouglas wants to merge 1 commit into
Conversation
Git sets GIT_DIR for hooks. When pushing from a linked worktree it points at the main repository, so the tests' git init/config commands against temp directories instead wrote core.bare=true and a Test user identity into the shared config, breaking the main checkout and authoring later commits as Test <test@example.com>. Amp-Thread-ID: https://ampcode.com/threads/T-01a1a052-93bd-73a1-83b2-d55b78c2b1c0 Co-authored-by: Amp <amp@ampcode.com>
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 4bfc6a6c92
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| # Git sets GIT_DIR for hooks, which makes the tests' git commands write to this repository instead of their | ||
| # temporary repositories. |
There was a problem hiding this comment.
Remove the comment on this single command
This newly added comment documents a single run entry rather than a block of 20 or more lines, conflicting with the root repository policy that comments are only for large, nonobvious blocks. Remove the comment and let the command and commit history carry this rationale.
AGENTS.md reference: AGENTS.md:L19-L20
Useful? React with 👍 / 👎.
Git sets
GIT_DIRwhen it runs hooks. On a push from a linked worktree, it points at the main repository's.git/worktrees/<name>. The pre-push hook runsjust test, and tests that rungit initorgit -C <tmpdir> config ...honourGIT_DIRover-C, so they write into the real repository's shared config instead of their temp repos. That leaves:core.bare = true, which breaks the main checkout (git status: "this operation must be run in a work tree")user.name = Test/user.email = test@example.com, so later commits are authored as Test and fail DCOThe
testpre-push command now unsetsGIT_DIR,GIT_WORK_TREEandGIT_INDEX_FILEbefore running the tests.Verified with a scratch repo and worktree whose pre-push command runs
git initandgit config user.emailin a temp dir, like the tests do. Before this change, a push from the worktree leftuser.email=test@example.comandcore.bare=truein the main repo's config. With it, the config is untouched.