Git fork

packfile: move `get_multi_pack_index()` into "midx.c"

The `get_multi_pack_index()` function is declared and implemented in the
packfile subsystem, even though it really belongs into the multi-pack
index subsystem. The reason for this is likely that it needs to call
`packfile_store_prepare()`, which is not exposed by the packfile system.
In a subsequent commit we're about to add another caller outside of the
packfile system though, so we'll have to expose the function anyway.

Do so now already and move `get_multi_pack_index()` into the MIDX
subsystem.

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

authored by

Patrick Steinhardt and committed by
Junio C Hamano
ab8aff4a d67530f6

+17 -8
+6
midx.c
··· 93 93 return 0; 94 94 } 95 95 96 + struct multi_pack_index *get_multi_pack_index(struct odb_source *source) 97 + { 98 + packfile_store_prepare(source->odb->packfiles); 99 + return source->midx; 100 + } 101 + 96 102 static struct multi_pack_index *load_multi_pack_index_one(struct odb_source *source, 97 103 const char *midx_name) 98 104 {
+1
midx.h
··· 94 94 void get_split_midx_filename_ext(struct odb_source *source, struct strbuf *buf, 95 95 const unsigned char *hash, const char *ext); 96 96 97 + struct multi_pack_index *get_multi_pack_index(struct odb_source *source); 97 98 struct multi_pack_index *load_multi_pack_index(struct odb_source *source); 98 99 int prepare_midx_pack(struct multi_pack_index *m, uint32_t pack_int_id); 99 100 struct packed_git *nth_midxed_pack(struct multi_pack_index *m,
+1 -7
packfile.c
··· 1003 1003 list_add_tail(&p->mru, &store->mru); 1004 1004 } 1005 1005 1006 - static void packfile_store_prepare(struct packfile_store *store) 1006 + void packfile_store_prepare(struct packfile_store *store) 1007 1007 { 1008 1008 struct odb_source *source; 1009 1009 ··· 1031 1031 { 1032 1032 packfile_store_prepare(r->objects->packfiles); 1033 1033 return r->objects->packfiles->packs; 1034 - } 1035 - 1036 - struct multi_pack_index *get_multi_pack_index(struct odb_source *source) 1037 - { 1038 - packfile_store_prepare(source->odb->packfiles); 1039 - return source->midx; 1040 1034 } 1041 1035 1042 1036 struct packed_git *get_all_packs(struct repository *r)
+9 -1
packfile.h
··· 113 113 void packfile_store_close(struct packfile_store *store); 114 114 115 115 /* 116 + * Prepare the packfile store by loading packfiles and multi-pack indices for 117 + * all alternates. This becomes a no-op if the store is already prepared. 118 + * 119 + * It shouldn't typically be necessary to call this function directly, as 120 + * functions that access the store know to prepare it. 121 + */ 122 + void packfile_store_prepare(struct packfile_store *store); 123 + 124 + /* 116 125 * Clear the packfile caches and try to look up any new packfiles that have 117 126 * appeared since last preparing the packfiles store. 118 127 * ··· 213 222 214 223 struct packed_git *get_packed_git(struct repository *r); 215 224 struct list_head *get_packed_git_mru(struct repository *r); 216 - struct multi_pack_index *get_multi_pack_index(struct odb_source *source); 217 225 struct packed_git *get_all_packs(struct repository *r); 218 226 219 227 /*