Skip to content

Commit 3421cb5

Browse files
pks-tgitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 535b7a6 commit 3421cb5

File tree

3 files changed

+9
-9
lines changed

3 files changed

+9
-9
lines changed

odb.h

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -169,12 +169,6 @@ struct object_database {
169169
unsigned long approximate_object_count;
170170
unsigned approximate_object_count_valid : 1;
171171

172-
/*
173-
* Whether packed_git has already been populated with this repository's
174-
* packs.
175-
*/
176-
unsigned packed_git_initialized : 1;
177-
178172
/*
179173
* Submodule source paths that will be added as additional sources to
180174
* allow lookup of submodule objects via the main object database.

packfile.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1027,7 +1027,7 @@ static void prepare_packed_git(struct repository *r)
10271027
{
10281028
struct odb_source *source;
10291029

1030-
if (r->objects->packed_git_initialized)
1030+
if (r->objects->packfiles->initialized)
10311031
return;
10321032

10331033
odb_prepare_alternates(r->objects);
@@ -1038,7 +1038,7 @@ static void prepare_packed_git(struct repository *r)
10381038
rearrange_packed_git(r);
10391039

10401040
prepare_packed_git_mru(r);
1041-
r->objects->packed_git_initialized = 1;
1041+
r->objects->packfiles->initialized = true;
10421042
}
10431043

10441044
void reprepare_packed_git(struct repository *r)
@@ -1060,7 +1060,7 @@ void reprepare_packed_git(struct repository *r)
10601060
odb_clear_loose_cache(source);
10611061

10621062
r->objects->approximate_object_count_valid = 0;
1063-
r->objects->packed_git_initialized = 0;
1063+
r->objects->packfiles->initialized = false;
10641064
prepare_packed_git(r);
10651065
obj_read_unlock();
10661066
}

packfile.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,12 @@ struct packfile_store {
6363
* the store.
6464
*/
6565
struct packed_git *packs;
66+
67+
/*
68+
* Whether packfiles have already been populated with this store's
69+
* packs.
70+
*/
71+
bool initialized;
6672
};
6773

6874
/*

0 commit comments

Comments
 (0)