]> git.ipfire.org Git - thirdparty/git.git/commitdiff
packfile: refactor `get_packed_git_mru()` to work on packfile store
authorPatrick Steinhardt <ps@pks.im>
Tue, 23 Sep 2025 10:17:14 +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_mru()` function prepares the packfile store and then
returns its packfiles in most-recently-used order. 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/pack-objects.c
packfile.c
packfile.h

index de351b757ae4462f73b8162d1b5a2fafa1321c81..61bbbdfb83feeb1f1df2bbd2792d8e6f14ef4fa2 100644 (file)
@@ -1748,12 +1748,12 @@ static int want_object_in_pack_mtime(const struct object_id *oid,
                }
        }
 
-       list_for_each(pos, get_packed_git_mru(the_repository)) {
+       list_for_each(pos, packfile_store_get_packs_mru(the_repository->objects->packfiles)) {
                struct packed_git *p = list_entry(pos, struct packed_git, mru);
                want = want_object_in_pack_one(p, oid, exclude, found_pack, found_offset, found_mtime);
                if (!exclude && want > 0)
                        list_move(&p->mru,
-                                 get_packed_git_mru(the_repository));
+                                 packfile_store_get_packs_mru(the_repository->objects->packfiles));
                if (want != -1)
                        return want;
        }
index cd5431b6aa18801d871a23f75c8e45a0152f9ca7..5a7caec29259771d2f15e9ac4979c0eec964251a 100644 (file)
@@ -1048,10 +1048,10 @@ struct packed_git *packfile_store_get_all_packs(struct packfile_store *store)
        return store->packs;
 }
 
-struct list_head *get_packed_git_mru(struct repository *r)
+struct list_head *packfile_store_get_packs_mru(struct packfile_store *store)
 {
-       packfile_store_prepare(r->objects->packfiles);
-       return &r->objects->packfiles->mru;
+       packfile_store_prepare(store);
+       return &store->mru;
 }
 
 /*
index 1afb9cd6641696287e4b310d8139a38ce4bc4c23..e7a5792b6cf691453e116ce541abf6e3280066f6 100644 (file)
@@ -148,6 +148,11 @@ struct packed_git *packfile_store_get_packs(struct packfile_store *store);
  */
 struct packed_git *packfile_store_get_all_packs(struct packfile_store *store);
 
+/*
+ * Get all packs in most-recently-used order.
+ */
+struct list_head *packfile_store_get_packs_mru(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
@@ -232,8 +237,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 list_head *get_packed_git_mru(struct repository *r);
-
 /*
  * Give a rough count of objects in the repository. This sacrifices accuracy
  * for speed.