]> git.ipfire.org Git - thirdparty/git.git/commitdiff
packfile: refactor `get_packed_git()` to work on packfile store
authorPatrick Steinhardt <ps@pks.im>
Tue, 23 Sep 2025 10:17:12 +0000 (12:17 +0200)
committerJunio C Hamano <gitster@pobox.com>
Wed, 24 Sep 2025 18:53:51 +0000 (11:53 -0700)
The `get_packed_git()` function prepares the packfile store and then
returns its packfiles. Refactor it to accept a packfile store instead of
a repository to clarify its scope.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/gc.c
builtin/grep.c
object-name.c
packfile.c
packfile.h

index aeca06a08bec5d6299588df97a5ca64eee31c90a..ec6735a540ad1b4a2273e26e121f1a3ae6c65941 100644 (file)
@@ -1423,7 +1423,7 @@ static int incremental_repack_auto_condition(struct gc_config *cfg UNUSED)
        if (incremental_repack_auto_limit < 0)
                return 1;
 
-       for (p = get_packed_git(the_repository);
+       for (p = packfile_store_get_packs(the_repository->objects->packfiles);
             count < incremental_repack_auto_limit && p;
             p = p->next) {
                if (!p->multi_pack_index)
index 5df653733371d809d63c4be283c231de468b8ffd..63a4959568fa1cc375da211282d203c1898dafa2 100644 (file)
@@ -1214,7 +1214,7 @@ int cmd_grep(int argc,
                if (recurse_submodules)
                        repo_read_gitmodules(the_repository, 1);
                if (startup_info->have_repository)
-                       (void)get_packed_git(the_repository);
+                       (void)packfile_store_get_packs(the_repository->objects->packfiles);
 
                start_threads(&opt);
        } else {
index df9e0c5f020a917ecbcfb1264482a1b493fd81c9..53356819a3def23eef662b90b9e23c4a08843706 100644 (file)
@@ -213,7 +213,7 @@ static void find_short_packed_object(struct disambiguate_state *ds)
                        unique_in_midx(m, ds);
        }
 
-       for (p = get_packed_git(ds->repo); p && !ds->ambiguous;
+       for (p = packfile_store_get_packs(ds->repo->objects->packfiles); p && !ds->ambiguous;
             p = p->next)
                unique_in_pack(p, ds);
 }
@@ -806,7 +806,7 @@ static void find_abbrev_len_packed(struct min_abbrev_data *mad)
                        find_abbrev_len_for_midx(m, mad);
        }
 
-       for (p = get_packed_git(mad->repo); p; p = p->next)
+       for (p = packfile_store_get_packs(mad->repo->objects->packfiles); p; p = p->next)
                find_abbrev_len_for_pack(p, mad);
 }
 
index 7a9193e5ef4664b7dcf4e3497933d944242b5ea9..b37f43afb587a59ddf12dc015664273a0b94083c 100644 (file)
@@ -1027,10 +1027,10 @@ void packfile_store_reprepare(struct packfile_store *store)
        packfile_store_prepare(store);
 }
 
-struct packed_git *get_packed_git(struct repository *r)
+struct packed_git *packfile_store_get_packs(struct packfile_store *store)
 {
-       packfile_store_prepare(r->objects->packfiles);
-       return r->objects->packfiles->packs;
+       packfile_store_prepare(store);
+       return store->packs;
 }
 
 struct packed_git *get_all_packs(struct repository *r)
index a9e561ac3948634f66fe1fd929aeb50d2f3eb0b5..0b691ded7ef12a053abb1df5d98c8b45c014bcd9 100644 (file)
@@ -136,6 +136,12 @@ void packfile_store_reprepare(struct packfile_store *store);
 void packfile_store_add_pack(struct packfile_store *store,
                             struct packed_git *pack);
 
+/*
+ * Get packs managed by the given store. Does not load the MIDX or any packs
+ * referenced by it.
+ */
+struct packed_git *packfile_store_get_packs(struct packfile_store *store);
+
 /*
  * Open the packfile and add it to the store if it isn't yet known. Returns
  * either the newly opened packfile or the preexisting packfile. Returns a
@@ -220,7 +226,6 @@ int for_each_packed_object(struct repository *repo, each_packed_object_fn cb,
 #define PACKDIR_FILE_GARBAGE 4
 extern void (*report_garbage)(unsigned seen_bits, const char *path);
 
-struct packed_git *get_packed_git(struct repository *r);
 struct list_head *get_packed_git_mru(struct repository *r);
 struct packed_git *get_all_packs(struct repository *r);