We have two different functions to retrieve packfiles for a packfile store: - `get_packed_git()` returns the list of packfiles after having called `prepare_packed_git()`. - `get_all_packs()` calls `prepare_packed_git()`, as well, but also calls `prepare_midx_pack()` for each pack. This means that the latter function also properly loads the info of whether or not a packfile is part of a multi-pack index. Preparing this extra information also shouldn't be significantly more expensive: - We have already loaded all packfiles via `prepare_packed_git_one()`. So given that multi-pack indices may only refer to packfiles in the same object directory we know that we already loaded each packfile. - The multi-pack index was prepared via `packfile_store_prepare()` already, which calls `prepare_multi_pack_index_one()`. - So all that remains to be done is to look up the index of the pack in its multi-pack index so that we can store that info in both the pack itself and the MIDX. So it is somewhat confusing to readers that one of these two functions claims to load "all" packfiles while the other one doesn't, even though the ultimate difference is way more nuanced. Convert all of these sites to use `get_all_packs()` instead and remove `get_packed_git()`. There doesn't seem to be a good reason to discern these two functions. Signed-off-by: Patrick Steinhardt <ps@xxxxxx> --- builtin/gc.c | 2 +- builtin/grep.c | 2 +- object-name.c | 4 ++-- packfile.c | 6 ------ packfile.h | 1 - 5 files changed, 4 insertions(+), 11 deletions(-) diff --git a/builtin/gc.c b/builtin/gc.c index 1d30d1af2c..565afda51f 100644 --- a/builtin/gc.c +++ b/builtin/gc.c @@ -1422,7 +1422,7 @@ static int incremental_repack_auto_condition(struct gc_config *cfg UNUSED) if (incremental_repack_auto_limit < 0) return 1; - for (p = get_packed_git(the_repository); + for (p = get_all_packs(the_repository); count < incremental_repack_auto_limit && p; p = p->next) { if (!p->multi_pack_index) diff --git a/builtin/grep.c b/builtin/grep.c index 5df6537333..8f0e21bd70 100644 --- a/builtin/grep.c +++ b/builtin/grep.c @@ -1214,7 +1214,7 @@ int cmd_grep(int argc, if (recurse_submodules) repo_read_gitmodules(the_repository, 1); if (startup_info->have_repository) - (void)get_packed_git(the_repository); + packfile_store_prepare(the_repository->objects->packfiles); start_threads(&opt); } else { diff --git a/object-name.c b/object-name.c index 44b0d416ac..c87995cc1e 100644 --- a/object-name.c +++ b/object-name.c @@ -213,7 +213,7 @@ static void find_short_packed_object(struct disambiguate_state *ds) unique_in_midx(m, ds); } - for (p = get_packed_git(ds->repo); p && !ds->ambiguous; + for (p = get_all_packs(ds->repo); p && !ds->ambiguous; p = p->next) unique_in_pack(p, ds); } @@ -806,7 +806,7 @@ static void find_abbrev_len_packed(struct min_abbrev_data *mad) find_abbrev_len_for_midx(m, mad); } - for (p = get_packed_git(mad->repo); p; p = p->next) + for (p = get_all_packs(mad->repo); p; p = p->next) find_abbrev_len_for_pack(p, mad); } diff --git a/packfile.c b/packfile.c index 16384e0865..523c30c5a7 100644 --- a/packfile.c +++ b/packfile.c @@ -1029,12 +1029,6 @@ void packfile_store_reprepare(struct packfile_store *store) packfile_store_prepare(store); } -struct packed_git *get_packed_git(struct repository *r) -{ - packfile_store_prepare(r->objects->packfiles); - return r->objects->packfiles->packs; -} - struct packed_git *get_all_packs(struct repository *r) { packfile_store_prepare(r->objects->packfiles); diff --git a/packfile.h b/packfile.h index 816b762770..15cb378781 100644 --- a/packfile.h +++ b/packfile.h @@ -211,7 +211,6 @@ int for_each_packed_object(struct repository *repo, each_packed_object_fn cb, #define PACKDIR_FILE_GARBAGE 4 extern void (*report_garbage)(unsigned seen_bits, const char *path); -struct packed_git *get_packed_git(struct repository *r); struct list_head *get_packed_git_mru(struct repository *r); struct packed_git *get_all_packs(struct repository *r); -- 2.51.0.261.g7ce5a0a67e.dirty