]> git.ipfire.org Git - thirdparty/git.git/commitdiff
odb: move initialization bit into `struct packfile_store`
authorPatrick Steinhardt <ps@pks.im>
Tue, 23 Sep 2025 10:17:02 +0000 (12:17 +0200)
committerJunio C Hamano <gitster@pobox.com>
Wed, 24 Sep 2025 18:53:49 +0000 (11:53 -0700)
The object database knows to skip re-initializing the list of packfiles
in case it's already been initialized. Whether or not that is the case
is tracked via a separate `initialized` bit that is stored in the object
database. With the introduction of the `struct packfile_store` we have a
better place to host this bit though.

Move it accordingly. While at it, convert the field into a boolean now
that we're allowed to use them in our code base.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
odb.h
packfile.c
packfile.h

diff --git a/odb.h b/odb.h
index 22a170b434c929c2ebc381c5a8125fb084608398..bf1b4d4677317c2d7caab9b687fde5524a8be021 100644 (file)
--- a/odb.h
+++ b/odb.h
@@ -169,12 +169,6 @@ struct object_database {
        unsigned long approximate_object_count;
        unsigned approximate_object_count_valid : 1;
 
-       /*
-        * Whether packed_git has already been populated with this repository's
-        * packs.
-        */
-       unsigned packed_git_initialized : 1;
-
        /*
         * Submodule source paths that will be added as additional sources to
         * allow lookup of submodule objects via the main object database.
index 36bc240107b57a0dfa51e53999694e852365fe35..f37557eac5409f9e36ab479d3e89f8f3b2a7643b 100644 (file)
@@ -1027,7 +1027,7 @@ static void prepare_packed_git(struct repository *r)
 {
        struct odb_source *source;
 
-       if (r->objects->packed_git_initialized)
+       if (r->objects->packfiles->initialized)
                return;
 
        odb_prepare_alternates(r->objects);
@@ -1038,7 +1038,7 @@ static void prepare_packed_git(struct repository *r)
        rearrange_packed_git(r);
 
        prepare_packed_git_mru(r);
-       r->objects->packed_git_initialized = 1;
+       r->objects->packfiles->initialized = true;
 }
 
 void reprepare_packed_git(struct repository *r)
@@ -1060,7 +1060,7 @@ void reprepare_packed_git(struct repository *r)
                odb_clear_loose_cache(source);
 
        r->objects->approximate_object_count_valid = 0;
-       r->objects->packed_git_initialized = 0;
+       r->objects->packfiles->initialized = false;
        prepare_packed_git(r);
        obj_read_unlock();
 }
index d7ac8d24b435b20908f7d606557e18787e7edb97..cf81091175f8cd0df4cda8014486ef89fb5bb2ee 100644 (file)
@@ -63,6 +63,12 @@ struct packfile_store {
         * the store.
         */
        struct packed_git *packs;
+
+       /*
+        * Whether packfiles have already been populated with this store's
+        * packs.
+        */
+       bool initialized;
 };
 
 /*