]> git.ipfire.org Git - thirdparty/git.git/commitdiff
pack-objects: extract `stdin_packs_add_all_pack_entries()`
authorTaylor Blau <me@ttaylorr.com>
Fri, 26 Jun 2026 19:02:33 +0000 (15:02 -0400)
committerJunio C Hamano <gitster@pobox.com>
Fri, 26 Jun 2026 21:54:55 +0000 (14:54 -0700)
Extract the pack enumeration loop from stdin_packs_add_pack_entries()
into a separate stdin_packs_add_all_pack_entries() helper, and have the
caller dispatch to it based on the stdin_packs_mode.

This prepares for a subsequent commit which will introduce an alternate
code path for '--stdin-packs=follow-reachable' that determines the set
of objects to include via a reachability walk rather than eagerly adding
all objects from included packs.

Signed-off-by: Taylor Blau <me@ttaylorr.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/pack-objects.c

index 27048bbb4dd3c9507fd1641658d30e16599caff4..29e43abb51e9d48a14b3ed0f299a71f0de6be68a 100644 (file)
@@ -3933,30 +3933,12 @@ static int stdin_packs_include_check(struct commit *commit, void *data)
        return stdin_packs_include_check_obj((struct object *)commit, data);
 }
 
-static void stdin_packs_add_pack_entries(struct strmap *packs,
-                                        struct rev_info *revs)
+static void stdin_packs_add_all_pack_entries(struct string_list *keys,
+                                            struct rev_info *revs)
 {
-       struct string_list keys = STRING_LIST_INIT_NODUP;
        struct string_list_item *item;
-       struct hashmap_iter iter;
-       struct strmap_entry *entry;
-
-       strmap_for_each_entry(packs, &iter, entry) {
-               struct stdin_pack_info *info = entry->value;
-               if (!info->p)
-                       die(_("could not find pack '%s'"), entry->key);
-
-               string_list_append(&keys, entry->key)->util = info;
-       }
 
-       /*
-        * Order packs by ascending mtime; use QSORT directly to access the
-        * string_list_item's ->util pointer, which string_list_sort() does not
-        * provide.
-        */
-       QSORT(keys.items, keys.nr, pack_mtime_cmp);
-
-       for_each_string_list_item(item, &keys) {
+       for_each_string_list_item(item, keys) {
                struct stdin_pack_info *info = item->util;
 
                if (info->kind & STDIN_PACK_EXCLUDE_OPEN) {
@@ -3977,6 +3959,31 @@ static void stdin_packs_add_pack_entries(struct strmap *packs,
                                                revs,
                                                ODB_FOR_EACH_OBJECT_PACK_ORDER);
        }
+}
+
+static void stdin_packs_add_pack_entries(struct strmap *packs,
+                                        struct rev_info *revs)
+{
+       struct string_list keys = STRING_LIST_INIT_NODUP;
+       struct hashmap_iter iter;
+       struct strmap_entry *entry;
+
+       strmap_for_each_entry(packs, &iter, entry) {
+               struct stdin_pack_info *info = entry->value;
+               if (!info->p)
+                       die(_("could not find pack '%s'"), entry->key);
+
+               string_list_append(&keys, entry->key)->util = info;
+       }
+
+       /*
+        * Order packs by ascending mtime; use QSORT directly to access the
+        * string_list_item's ->util pointer, which string_list_sort() does not
+        * provide.
+        */
+       QSORT(keys.items, keys.nr, pack_mtime_cmp);
+
+       stdin_packs_add_all_pack_entries(&keys, revs);
 
        string_list_clear(&keys, 0);
 }