From 4ec91a0bf58e07ce040f08600cd0c6b64f996e07 Mon Sep 17 00:00:00 2001 From: Stefan Haller Date: Wed, 5 Aug 2026 16:58:37 +0200 Subject: [PATCH] Don't let integration tests race a background git repack Every `git commit` forks `git maintenance run --auto --quiet --detach`, and git 2.54 changed what that runs from the `gc` task to the "geometric" strategy. The geometric repack's auto condition passes its threshold of 100 to too_many_loose_objects(), which estimates the loose object count from the objects/17 fanout directory times 256, so the real trigger is two objects in that one directory -- where the old gc task needed 27. Fixture repos reach two easily: every CreateNCommits(n>=6) repo already stores the blob for file06.txt there, so a single commit object hashing into 17 (about 4% of fixtures with 10 commits, 15% with 40) tips it over, and from then on every commit in that repo forks a detached `git repack -d`, which prunes loose objects while the next fixture command -- or lazygit under test -- is still working in the same repo. That is where the CI panics during fixture setup come from: panic: error running command: [git commit -m commit-10] error: invalid object 100644 50d5612... for 'file09.txt' error: Error building trees The reported hashes are exactly the fixture blobs, so `git add` staged them correctly; they were unlinked underneath the commit. Only the "git latest" jobs saw this, since the pinned 2.32/2.38/2.44 jobs predate the strategy change. git's own test suite guards against the same thing by exporting GIT_TEST_MAINT_AUTO_DETACH=false ("Ensure that tests cannot race with background maintenance by default"). Turning maintenance off outright is stronger: no test repo needs it, and it also spares us a forked git process per commit. maintenance.auto has been honored since git 2.29, so it covers every version in the CI matrix. Measured on a 40-commit fixture: a background repack fired in 4 of 25 runs before, 0 of 25 after. --- test/global_git_config | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/test/global_git_config b/test/global_git_config index f4f47c003..b83ea57b4 100644 --- a/test/global_git_config +++ b/test/global_git_config @@ -8,3 +8,12 @@ allow = always [commit] gpgSign = false +[maintenance] + # Every `git commit` forks `git maintenance run --auto --detach`. Since git + # 2.54 that repacks as soon as two objects share the objects/17 fanout + # directory, which happens readily in a fixture repo, and `git repack -d` + # prunes loose objects while the next fixture command -- or lazygit itself -- + # is still working in the same repo. That surfaces as + # "error: invalid object for 'file09.txt'" / "Error building trees". + # Tests must never race a background repack. + auto = false