pack: move prepare_packed_git_run_once to object store
Each repository's object store can be initialized independently, so they must not share a run_once variable. Signed-off-by: Stefan Beller <sbeller@google.com> Signed-off-by: Jonathan Nieder <jrnieder@gmail.com> Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Stefan Beller committed
Mar 23, 2018 at 18:21 UTC
5508f69348ee1073666d3611a4a62ecdb0849e4e
2 files changed
+9
-4
object-store.h
+6
@@ -98,6 +98,12 @@ struct raw_object_store {
98
struct packed_git *packed_git;
99
/* A most-recently-used ordered version of the packed_git list. */
100
struct list_head packed_git_mru;
101
+
102
+ /*
103
+ * Whether packed_git has already been populated with this repository's
104
+ * packs.
105
+ */
106
+ unsigned packed_git_initialized : 1;
107
};
108
109
struct raw_object_store *raw_object_store_new(void);
packfile.c
+3
-4
@@ -884,12 +884,11 @@ static void prepare_packed_git_mru(void)
884
list_add_tail(&p->mru, &the_repository->objects->packed_git_mru);
885
}
886
887
-static int prepare_packed_git_run_once = 0;
887
void prepare_packed_git(void)
888
{
889
struct alternate_object_database *alt;
890
892
- if (prepare_packed_git_run_once)
891
+ if (the_repository->objects->packed_git_initialized)
892
return;
893
prepare_packed_git_one(get_object_directory(), 1);
894
prepare_alt_odb();
@@ -897,13 +896,13 @@ void prepare_packed_git(void)
896
prepare_packed_git_one(alt->path, 0);
897
rearrange_packed_git();
898
prepare_packed_git_mru();
900
- prepare_packed_git_run_once = 1;
899
+ the_repository->objects->packed_git_initialized = 1;
900
}
901
902
void reprepare_packed_git(void)
903
{
904
approximate_object_count_valid = 0;
906
- prepare_packed_git_run_once = 0;
905
+ the_repository->objects->packed_git_initialized = 0;
906
prepare_packed_git();
907
}
908