Re: [PATCH 4/4] repack: retain cruft packs in MIDXs containing kept packs
From: Jeff King <hidden>
Date: 2026-09-30 20:53:13
On Tue, Sep 29, 2026 at 08:28:58PM -0500, Taylor Blau wrote:
When performing a geometric repack with 'repack.midxMustContainCruft' set to "false", Git uses '--stdin-packs=follow' to copy (once-cruft) objects needed for reachability closure out of cruft packs. .keep packs do not need to participate in that walk, though they *are* included in the resulting MIDX. A .keep pack can contain a commit that reaches an object whose only copy is in a cruft pack. When there is no previous MIDX and the repack writes a new pack, neither `midx_has_unknown_packs()` nor the `!names.nr` fallback require that cruft pack to be included. If the kept commit (or a descendant of it) is selected for bitmap coverage, the bitmap writer fails because the MIDX does not contain all of its reachable objects. Include cruft packs whenever the MIDX contains kept packs. This also retains cruft when the kept packs happen to have full closure, or when '--pack-kept-objects' lets the repack walk them. It avoids having to establish their closure before deciding which packs the MIDX needs.
OK. This makes sense to me, but two questions:
1. Is this going to kick in racily because of the .keep that we
temporarily install during pushes? That could cause unexpected
performance changes in a big repo when the midx sometimes has to
randomly include cruft packs.
2. I'd have thought that the solution would be to treat .keep packs
like other included follow-packs: traverse them in the usual way.
But maybe there are good reasons we didn't do that in the first
place.
-Peff