Git fork

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

The `get_packed_git_mru()` function prepares the packfile store and then
returns its packfiles in most-recently-used order. 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
dd52a29b d2779beb

+10 -7
+2 -2
builtin/pack-objects.c
··· 1748 1748 } 1749 1749 } 1750 1750 1751 - list_for_each(pos, get_packed_git_mru(the_repository)) { 1751 + list_for_each(pos, packfile_store_get_packs_mru(the_repository->objects->packfiles)) { 1752 1752 struct packed_git *p = list_entry(pos, struct packed_git, mru); 1753 1753 want = want_object_in_pack_one(p, oid, exclude, found_pack, found_offset, found_mtime); 1754 1754 if (!exclude && want > 0) 1755 1755 list_move(&p->mru, 1756 - get_packed_git_mru(the_repository)); 1756 + packfile_store_get_packs_mru(the_repository->objects->packfiles)); 1757 1757 if (want != -1) 1758 1758 return want; 1759 1759 }
+3 -3
packfile.c
··· 1048 1048 return store->packs; 1049 1049 } 1050 1050 1051 - struct list_head *get_packed_git_mru(struct repository *r) 1051 + struct list_head *packfile_store_get_packs_mru(struct packfile_store *store) 1052 1052 { 1053 - packfile_store_prepare(r->objects->packfiles); 1054 - return &r->objects->packfiles->mru; 1053 + packfile_store_prepare(store); 1054 + return &store->mru; 1055 1055 } 1056 1056 1057 1057 /*
+5 -2
packfile.h
··· 149 149 struct packed_git *packfile_store_get_all_packs(struct packfile_store *store); 150 150 151 151 /* 152 + * Get all packs in most-recently-used order. 153 + */ 154 + struct list_head *packfile_store_get_packs_mru(struct packfile_store *store); 155 + 156 + /* 152 157 * Open the packfile and add it to the store if it isn't yet known. Returns 153 158 * either the newly opened packfile or the preexisting packfile. Returns a 154 159 * `NULL` pointer in case the packfile could not be opened. ··· 231 236 #define PACKDIR_FILE_IDX 2 232 237 #define PACKDIR_FILE_GARBAGE 4 233 238 extern void (*report_garbage)(unsigned seen_bits, const char *path); 234 - 235 - struct list_head *get_packed_git_mru(struct repository *r); 236 239 237 240 /* 238 241 * Give a rough count of objects in the repository. This sacrifices accuracy