Skip to content

Commit ab8aff4

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

File tree

4 files changed

+17
-8
lines changed

4 files changed

+17
-8
lines changed

midx.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,12 @@ static int midx_read_object_offsets(const unsigned char *chunk_start,
9393
return 0;
9494
}
9595

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+
96102
static struct multi_pack_index *load_multi_pack_index_one(struct odb_source *source,
97103
const char *midx_name)
98104
{

midx.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ void get_midx_chain_filename(struct odb_source *source, struct strbuf *out);
9494
void get_split_midx_filename_ext(struct odb_source *source, struct strbuf *buf,
9595
const unsigned char *hash, const char *ext);
9696

97+
struct multi_pack_index *get_multi_pack_index(struct odb_source *source);
9798
struct multi_pack_index *load_multi_pack_index(struct odb_source *source);
9899
int prepare_midx_pack(struct multi_pack_index *m, uint32_t pack_int_id);
99100
struct packed_git *nth_midxed_pack(struct multi_pack_index *m,

packfile.c

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1003,7 +1003,7 @@ static void packfile_store_prepare_mru(struct packfile_store *store)
10031003
list_add_tail(&p->mru, &store->mru);
10041004
}
10051005

1006-
static void packfile_store_prepare(struct packfile_store *store)
1006+
void packfile_store_prepare(struct packfile_store *store)
10071007
{
10081008
struct odb_source *source;
10091009

@@ -1033,12 +1033,6 @@ struct packed_git *get_packed_git(struct repository *r)
10331033
return r->objects->packfiles->packs;
10341034
}
10351035

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-
}
1041-
10421036
struct packed_git *get_all_packs(struct repository *r)
10431037
{
10441038
packfile_store_prepare(r->objects->packfiles);

packfile.h

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,15 @@ void packfile_store_free(struct packfile_store *store);
112112
*/
113113
void packfile_store_close(struct packfile_store *store);
114114

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+
115124
/*
116125
* Clear the packfile caches and try to look up any new packfiles that have
117126
* appeared since last preparing the packfiles store.
@@ -213,7 +222,6 @@ extern void (*report_garbage)(unsigned seen_bits, const char *path);
213222

214223
struct packed_git *get_packed_git(struct repository *r);
215224
struct list_head *get_packed_git_mru(struct repository *r);
216-
struct multi_pack_index *get_multi_pack_index(struct odb_source *source);
217225
struct packed_git *get_all_packs(struct repository *r);
218226

219227
/*

0 commit comments

Comments
 (0)