odb: move initialization bit into `struct packfile_store`

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>

Patrick Steinhardt committed Sep 23, 2025 at 12:17 UTC 3421cb56a8b37425f2a47695adfa4a29a06a9d2e
3 files changed +9 -9
odb.h
-6
@@ -169,12 +169,6 @@ struct object_database {
169 unsigned long approximate_object_count;
170 unsigned approximate_object_count_valid : 1;
171
172 - /*
173 - * Whether packed_git has already been populated with this repository's
174 - * packs.
175 - */
176 - unsigned packed_git_initialized : 1;
177 -
172 /*
173 * Submodule source paths that will be added as additional sources to
174 * allow lookup of submodule objects via the main object database.
packfile.c
+3 -3
@@ -1027,7 +1027,7 @@ static void prepare_packed_git(struct repository *r)
1027 {
1028 struct odb_source *source;
1029
1030 - if (r->objects->packed_git_initialized)
1030 + if (r->objects->packfiles->initialized)
1031 return;
1032
1033 odb_prepare_alternates(r->objects);
@@ -1038,7 +1038,7 @@ static void prepare_packed_git(struct repository *r)
1038 rearrange_packed_git(r);
1039
1040 prepare_packed_git_mru(r);
1041 - r->objects->packed_git_initialized = 1;
1041 + r->objects->packfiles->initialized = true;
1042 }
1043
1044 void reprepare_packed_git(struct repository *r)
@@ -1060,7 +1060,7 @@ void reprepare_packed_git(struct repository *r)
1060 odb_clear_loose_cache(source);
1061
1062 r->objects->approximate_object_count_valid = 0;
1063 - r->objects->packed_git_initialized = 0;
1063 + r->objects->packfiles->initialized = false;
1064 prepare_packed_git(r);
1065 obj_read_unlock();
1066 }
packfile.h
+6
@@ -63,6 +63,12 @@ struct packfile_store {
63 * the store.
64 */
65 struct packed_git *packs;
66 +
67 + /*
68 + * Whether packfiles have already been populated with this store's
69 + * packs.
70 + */
71 + bool initialized;
72 };
73
74 /*