Git fork

packfile: refactor `get_packed_git()` to work on packfile store

The `get_packed_git()` function prepares the packfile store and then
returns its packfiles. Refactor it to accept a packfile store instead of
a repository to clarify its scope.

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
751808b2 ab8aff4a

+13 -8
+1 -1
builtin/gc.c
··· 1423 1423 if (incremental_repack_auto_limit < 0) 1424 1424 return 1; 1425 1425 1426 - for (p = get_packed_git(the_repository); 1426 + for (p = packfile_store_get_packs(the_repository->objects->packfiles); 1427 1427 count < incremental_repack_auto_limit && p; 1428 1428 p = p->next) { 1429 1429 if (!p->multi_pack_index)
+1 -1
builtin/grep.c
··· 1214 1214 if (recurse_submodules) 1215 1215 repo_read_gitmodules(the_repository, 1); 1216 1216 if (startup_info->have_repository) 1217 - (void)get_packed_git(the_repository); 1217 + (void)packfile_store_get_packs(the_repository->objects->packfiles); 1218 1218 1219 1219 start_threads(&opt); 1220 1220 } else {
+2 -2
object-name.c
··· 213 213 unique_in_midx(m, ds); 214 214 } 215 215 216 - for (p = get_packed_git(ds->repo); p && !ds->ambiguous; 216 + for (p = packfile_store_get_packs(ds->repo->objects->packfiles); p && !ds->ambiguous; 217 217 p = p->next) 218 218 unique_in_pack(p, ds); 219 219 } ··· 806 806 find_abbrev_len_for_midx(m, mad); 807 807 } 808 808 809 - for (p = get_packed_git(mad->repo); p; p = p->next) 809 + for (p = packfile_store_get_packs(mad->repo->objects->packfiles); p; p = p->next) 810 810 find_abbrev_len_for_pack(p, mad); 811 811 } 812 812
+3 -3
packfile.c
··· 1027 1027 packfile_store_prepare(store); 1028 1028 } 1029 1029 1030 - struct packed_git *get_packed_git(struct repository *r) 1030 + struct packed_git *packfile_store_get_packs(struct packfile_store *store) 1031 1031 { 1032 - packfile_store_prepare(r->objects->packfiles); 1033 - return r->objects->packfiles->packs; 1032 + packfile_store_prepare(store); 1033 + return store->packs; 1034 1034 } 1035 1035 1036 1036 struct packed_git *get_all_packs(struct repository *r)
+6 -1
packfile.h
··· 137 137 struct packed_git *pack); 138 138 139 139 /* 140 + * Get packs managed by the given store. Does not load the MIDX or any packs 141 + * referenced by it. 142 + */ 143 + struct packed_git *packfile_store_get_packs(struct packfile_store *store); 144 + 145 + /* 140 146 * Open the packfile and add it to the store if it isn't yet known. Returns 141 147 * either the newly opened packfile or the preexisting packfile. Returns a 142 148 * `NULL` pointer in case the packfile could not be opened. ··· 220 226 #define PACKDIR_FILE_GARBAGE 4 221 227 extern void (*report_garbage)(unsigned seen_bits, const char *path); 222 228 223 - struct packed_git *get_packed_git(struct repository *r); 224 229 struct list_head *get_packed_git_mru(struct repository *r); 225 230 struct packed_git *get_all_packs(struct repository *r); 226 231