Skip to content

fix: keep fixture scripts isolated when they set GIT_CONFIG_COUNT themselves - #2982

Merged
Sebastian Thiel (Byron) merged 2 commits into
GitoxideLabs:mainfrom
mtsgrd:testtools-config-file-isolation
Sep 9, 2026
Merged

fix: keep fixture scripts isolated when they set GIT_CONFIG_COUNT themselves#2982
Sebastian Thiel (Byron) merged 2 commits into
GitoxideLabs:mainfrom
mtsgrd:testtools-config-file-isolation

Conversation

@mtsgrd

@mtsgrd Mattias Granlund (mtsgrd) commented Sep 8, 2026

Copy link
Copy Markdown
Contributor

The isolation config (no signing, no auto-maintenance, init.defaultBranch=main) reaches fixture scripts only as GIT_CONFIG_COUNT variables, so a script exporting its own GIT_CONFIG_COUNT drops all of it. Each commit then spawns a detached git maintenance run --auto that races the fixture copy, and the test fails with a bare ENOENT. We hit this as a flaky test in GitButler and worked around it per script in gitbutlerapp/gitbutler#15785; this fixes it at the source.

  • the isolation now lives in a global config file under tests/fixtures/generated-do-not-edit/; a script's own GIT_CONFIG_COUNT layers on top
  • a script or git() call that writes global config fails and the file is restored, matching the old GIT_CONFIG_GLOBAL=/dev/null behaviour

Verified with cargo test -p gix-testtools (new isolation test) and GIX_TEST_IGNORE_ARCHIVES=1 cargo test for gix-config, gix-merge, gix-ref, gix-discover, gix-dir and gix-status.

🤖 Generated with Claude Code

…mselves

The isolation configuration (no signing, no auto-maintenance, `init.defaultBranch=main`)
reached scripts only as `GIT_CONFIG_COUNT` variables, so a script exporting its own
`GIT_CONFIG_COUNT` replaced all of it. With maintenance back on, each commit in such a
script spawned a detached `git maintenance run --auto` that could outlive the script and
mutate the fixture while it was being copied, failing tests with a bare ENOENT.

- the isolation now lives in a global configuration file under
  `tests/fixtures/generated-do-not-edit/`, written once per process; a script's own
  `GIT_CONFIG_COUNT` layers on top of it
- ambient `GIT_CONFIG_COUNT` is removed from the script environment, as it used to be
  overwritten
- a script or `git()` call that writes global configuration fails with a clear message
  and the file is restored, so the mistake stays contained to the offender

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 13d784dce6

ℹ️ 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 (@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 (@codex) address that feedback".

Comment thread tests/tools/src/lib.rs Outdated
Comment thread tests/tools/src/lib.rs Outdated
@Byron

Copy link
Copy Markdown
Member

Thanks a lot for the hint!

This was definitely a shortcoming of the current implementation, and it's now using GIT_CONFIG_PARAMETERS to set these values, a hidden feature that stacks with GIT_CONFIG_COUNT and friends.

- Use `GIT_CONFIG_PARAMETERS` instead of fiddling with configuration files

Assisted-by: GPT 6.0
Co-authored-by: GPT 6.0 <codex@openai.com>
@Byron
Sebastian Thiel (Byron) force-pushed the testtools-config-file-isolation branch from de6cb5c to bc9185d Compare September 9, 2026 03:13
@Byron
Sebastian Thiel (Byron) merged commit 0cd9319 into GitoxideLabs:main Sep 9, 2026
32 checks passed
Mattias Granlund (mtsgrd) added a commit to gitbutlerapp/gitbutler that referenced this pull request Sep 9, 2026
- no test references merge-signed-with-two-branches-line-offset or
  two-signed-commits-with-line-offset; only their committed archives and the
  archive whitelist mentioned them
- both scripts replaced GIT_CONFIG_COUNT with their own entries, dropping
  gix-testtools' isolation; the live signed fixtures do the same, and the fix
  for that is upstream (GitoxideLabs/gitoxide#2982), arriving with the next gix bump

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
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.

2 participants