pack-objects: extract `stdin_packs_add_all_pack_entries()`
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>
Taylor Blau committed
Jun 26, 2026 at 15:02 UTC
806cd59ba235c0b19261019c039a22392cc6fc04
1 file changed
+28
-21
builtin/pack-objects.c
+28
-21
index 27048bbb4d..29e43abb51 100644
--- a/builtin/pack-objects.c
+++ b/builtin/pack-objects.c
@@ -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);
}