Skip to content

Commit dd52a29

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

File tree

3 files changed

+10
-7
lines changed

3 files changed

+10
-7
lines changed

builtin/pack-objects.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1748,12 +1748,12 @@ static int want_object_in_pack_mtime(const struct object_id *oid,
17481748
}
17491749
}
17501750

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)) {
17521752
struct packed_git *p = list_entry(pos, struct packed_git, mru);
17531753
want = want_object_in_pack_one(p, oid, exclude, found_pack, found_offset, found_mtime);
17541754
if (!exclude && want > 0)
17551755
list_move(&p->mru,
1756-
get_packed_git_mru(the_repository));
1756+
packfile_store_get_packs_mru(the_repository->objects->packfiles));
17571757
if (want != -1)
17581758
return want;
17591759
}

packfile.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1048,10 +1048,10 @@ struct packed_git *packfile_store_get_all_packs(struct packfile_store *store)
10481048
return store->packs;
10491049
}
10501050

1051-
struct list_head *get_packed_git_mru(struct repository *r)
1051+
struct list_head *packfile_store_get_packs_mru(struct packfile_store *store)
10521052
{
1053-
packfile_store_prepare(r->objects->packfiles);
1054-
return &r->objects->packfiles->mru;
1053+
packfile_store_prepare(store);
1054+
return &store->mru;
10551055
}
10561056

10571057
/*

packfile.h

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,11 @@ struct packed_git *packfile_store_get_packs(struct packfile_store *store);
148148
*/
149149
struct packed_git *packfile_store_get_all_packs(struct packfile_store *store);
150150

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+
151156
/*
152157
* Open the packfile and add it to the store if it isn't yet known. Returns
153158
* either the newly opened packfile or the preexisting packfile. Returns a
@@ -232,8 +237,6 @@ int for_each_packed_object(struct repository *repo, each_packed_object_fn cb,
232237
#define PACKDIR_FILE_GARBAGE 4
233238
extern void (*report_garbage)(unsigned seen_bits, const char *path);
234239

235-
struct list_head *get_packed_git_mru(struct repository *r);
236-
237240
/*
238241
* Give a rough count of objects in the repository. This sacrifices accuracy
239242
* for speed.

0 commit comments

Comments
 (0)