]> git.ipfire.org Git - thirdparty/git.git/commitdiff
repack-promisor: extract function to remove redundant packs
authorPatrick Steinhardt <ps@pks.im>
Mon, 5 Jan 2026 13:16:44 +0000 (14:16 +0100)
committerJunio C Hamano <gitster@pobox.com>
Wed, 14 Jan 2026 14:29:24 +0000 (06:29 -0800)
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>
repack-geometry.c

index 17e6652a91c7230e74aeb3f07e687beca50191a8..0daf545a815c0f223fc7f8a9b7e24cc62a99d06a 100644 (file)
@@ -197,17 +197,18 @@ struct packed_git *pack_geometry_preferred_pack(struct pack_geometry *geometry)
        return NULL;
 }
 
-void pack_geometry_remove_redundant(struct pack_geometry *geometry,
-                                   struct string_list *names,
-                                   struct existing_packs *existing,
-                                   const char *packdir)
+static void remove_redundant_packs(struct packed_git **pack,
+                                  uint32_t pack_nr,
+                                  struct string_list *names,
+                                  struct existing_packs *existing,
+                                  const char *packdir)
 {
        const struct git_hash_algo *algop = existing->repo->hash_algo;
        struct strbuf buf = STRBUF_INIT;
        uint32_t i;
 
-       for (i = 0; i < geometry->split; i++) {
-               struct packed_git *p = geometry->pack[i];
+       for (i = 0; i < pack_nr; i++) {
+               struct packed_git *p = pack[i];
                if (string_list_has_string(names, hash_to_hex_algop(p->hash,
                                                                    algop)))
                        continue;
@@ -226,6 +227,15 @@ void pack_geometry_remove_redundant(struct pack_geometry *geometry,
        strbuf_release(&buf);
 }
 
+void pack_geometry_remove_redundant(struct pack_geometry *geometry,
+                                   struct string_list *names,
+                                   struct existing_packs *existing,
+                                   const char *packdir)
+{
+       remove_redundant_packs(geometry->pack, geometry->split,
+                              names, existing, packdir);
+}
+
 void pack_geometry_release(struct pack_geometry *geometry)
 {
        if (!geometry)