Skip to content

fix: disable automatic Git maintenance in gix-testtools#2612

Merged
Sebastian Thiel (Byron) merged 2 commits into
mainfrom
improvements
May 25, 2026
Merged

fix: disable automatic Git maintenance in gix-testtools#2612
Sebastian Thiel (Byron) merged 2 commits into
mainfrom
improvements

Conversation

@Byron
Copy link
Copy Markdown
Member

@Byron Sebastian Thiel (Byron) commented May 19, 2026

Tasks

  • refackiew

Created by Codex on behalf of Byron. Byron will review before this is ready to merge.

Reported issue

Make sure that `gix-testtools` doesn't allow git gc to run automatically, in anything that it executes. See here for details.

Root cause: the fixture used a tick() function that set GIT_COMMITTER_DATE
to a fixed timestamp in January 2023. On git 2.54, git maintenance runs
automatically in the background after commits (triggered by git commit via
--auto). It packs loose objects and creates cruft packs, assigning each
object an mtime derived from its referencing commit's committer date. With
a 2023 timestamp, all objects appeared over two years old — exceeding
gc.cruftPackExpire=2.weeks.ago — and were pruned immediately, corrupting
the repository mid-fixture.

Summary

  • Added command-scope Git config helpers in gix-testtools to set maintenance.auto=false and gc.auto=0 for processes the crate executes.
  • Applied the guard to fixture script execution, git(), run_git(), invoke_bash(), git-daemon wrappers, Git version discovery, metadata generation, cargo example builds, and shell helpers.
  • Added regression coverage for direct Git, bash-launched Git, and the high-level git() helper.

Git reference

Git's prepare_auto_maintenance() skips automatic maintenance when maintenance.auto=false; Git's maintenance documentation also states that git maintenance register disables foreground maintenance by setting maintenance.auto=false. The fix also sets gc.auto=0 to cover older git gc --auto paths.

Validation

  • cargo test -p gix-testtools auto_maintenance
  • cargo test -p gix-testtools
  • cargo clippy -p gix-testtools --all-targets
  • cargo test -p gix-testtools auto_maintenance --no-default-features

Review

  • codex review --commit de7be303f3f6b9edc5d759f3ae7b39e89ed162e1 found no actionable issues.

Copy link
Copy Markdown
Member

@EliahKagan Eliah Kagan (EliahKagan) left a comment

Choose a reason for hiding this comment

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

It looks like this fixes the problem that causes all CI runs to fail, as seen in all recent PRs and feature branches--and as would be seen on main, but it's been a couple weeks since the last push. Rerunning the tests does not cause them to pass, but the change here does.

I'm not sure what's causing that problem. I haven't managed to look into it much, and I unfortunately I don't have time to look into it for most of today. I suspect it may relate to changes how Git does geometric repacking, making it so that when unanticipated garbage collection occurs, the result does not match what we've tested. I don't know to what extent, if any, it overlaps with the problem described in this PR as the motivating issue for it.

I only advocate merging this if it is already known to be correct. Because this remains a draft, I don't want to assume that it is ready. However, I mention this now just in case it turns out this is ready and in case it's considered valuable to get CI working in advance of the forthcoming monthly release (#2618).

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR hardens gix-testtools (and its companion test binary) against Git 2.54+ auto-maintenance by forcing command-scope config that disables automatic maintenance/auto-gc for Git processes launched by test helpers, and adds regression tests to ensure this remains in effect.

Changes:

  • Introduce and apply command-scope Git config injection (maintenance.auto=false, gc.auto=0) across multiple process-spawning helpers.
  • Extend the “isolated git config” used for fixture/script Git invocations to include the maintenance/auto-gc disables.
  • Add regression tests covering direct Git execution, bash-launched Git, and the high-level git() helper.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.

File Description
tests/tools/src/lib.rs Adds command-scope config helper and applies it broadly to Git-related process spawning (git discovery, run helpers, daemon, meta generation, etc.).
tests/tools/src/main.rs Applies the same command-scope config to the git-daemon wrapper used by journey tests.
tests/tools/src/tests.rs Adds regression tests asserting maintenance.auto and gc.auto are disabled through key helpers.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread tests/tools/src/lib.rs Outdated
Comment thread tests/tools/src/main.rs Outdated
Comment thread tests/tools/src/main.rs Outdated
Codex (codex) and others added 2 commits May 26, 2026 06:18
…it_config_by_environment` utility

Disable maintenance.auto and gc.auto through command-scope Git config for
gix-testtools process execution, including fixture scripts, helper-launched Git,
cargo example builds, git-daemon wrappers, and shell helpers.

Co-authored-by: Sebastian Thiel <sebastian.thiel@icloud.com>
…ally

Previously, it shuffled possible ports which could cause it to retry
multiple times.

Co-authored-by: Sebastian Thiel <sebastian.thiel@icloud.com>gst
@Byron Sebastian Thiel (Byron) marked this pull request as ready for review May 25, 2026 22:37
Copilot AI review requested due to automatic review settings May 25, 2026 22:37
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

Comment thread tests/tools/src/lib.rs
Comment thread tests/tools/src/lib.rs
@Byron
Copy link
Copy Markdown
Member Author

Eliah Kagan (@EliahKagan) Thanks for the heads-up, I wasn't aware. In these PR it's probably the same issue (and I didn't even notice yet), and I agree this should be part of the next release.
Now I should be able to release gix-testtools at will as well as it was decoupled from the workspace crates, solving another unpleasantness that plagued gitoxide for long enough.

Now I just shouldn't forget to rebase the report PR because I plan to release from there directly.

@Byron Sebastian Thiel (Byron) merged commit 4377485 into main May 25, 2026
33 checks passed
@EliahKagan
Copy link
Copy Markdown
Member

Thanks!

I should refine my description of the situation I believe this fixed, by saying that it was occasionally possible for the test suite to pass after the problem started yet before this fix, but I have only managed to produce one known example of it passing. So in a sense it was a flake, but it was more of an anti-flake--the test job passing was the rare thing. I expect that the fix here will much reduce or eliminate the problems, other than those that are due to problems with GHA's own infrastructure (which have been going on for a bit longer than the ones that appear correlated with the new Git version).

@EliahKagan
Copy link
Copy Markdown
Member

Eliah Kagan (EliahKagan) commented May 25, 2026

Now I just shouldn't forget to rebase the report PR because I plan to release from there directly.

If feasible, I think it would be helpful to Windows users if #2607 can also come in before the monthly gitoxide release. I think everything there is in good shape, I've rebased it, and due to the fix in this PR, I expect all tests to pass. I've enabled auto-merge in #2607.

Edit: #2607 has merged.

@Byron Sebastian Thiel (Byron) deleted the improvements branch May 26, 2026 01:21
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.

4 participants