repack-promisor: extract function to remove redundant packs

We're about to add a second caller that wants to remove redundant packs after a geometric repack. Split out the function which does this to prepare for that. Signed-off-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Patrick Steinhardt committed Jan 5, 2026 at 14:16 UTC fa7b91247b42bc9ffab423d42f0e9e12e86769fa
1 file changed +16 -6
repack-geometry.c
+16 -6
@@ -197,17 +197,18 @@ struct packed_git *pack_geometry_preferred_pack(struct pack_geometry *geometry)
197 return NULL;
198 }
199
200 -void pack_geometry_remove_redundant(struct pack_geometry *geometry,
201 - struct string_list *names,
202 - struct existing_packs *existing,
203 - const char *packdir)
200 +static void remove_redundant_packs(struct packed_git **pack,
201 + uint32_t pack_nr,
202 + struct string_list *names,
203 + struct existing_packs *existing,
204 + const char *packdir)
205 {
206 const struct git_hash_algo *algop = existing->repo->hash_algo;
207 struct strbuf buf = STRBUF_INIT;
208 uint32_t i;
209
209 - for (i = 0; i < geometry->split; i++) {
210 - struct packed_git *p = geometry->pack[i];
210 + for (i = 0; i < pack_nr; i++) {
211 + struct packed_git *p = pack[i];
212 if (string_list_has_string(names, hash_to_hex_algop(p->hash,
213 algop)))
214 continue;
@@ -226,6 +227,15 @@ void pack_geometry_remove_redundant(struct pack_geometry *geometry,
227 strbuf_release(&buf);
228 }
229
230 +void pack_geometry_remove_redundant(struct pack_geometry *geometry,
231 + struct string_list *names,
232 + struct existing_packs *existing,
233 + const char *packdir)
234 +{
235 + remove_redundant_packs(geometry->pack, geometry->split,
236 + names, existing, packdir);
237 +}
238 +
239 void pack_geometry_release(struct pack_geometry *geometry)
240 {
241 if (!geometry)