odb: move kept cache into struct packfile_store

The object database tracks a cache of "kept" packfiles, which is used by
git-pack-objects(1) to handle cruft objects. With the introduction of
the `struct packfile_store` we have a better place to host this cache
though.

Move the cache accordingly.

This moves the last bit of packfile-related state from the object
database into the packfile store. Adapt the comment for the `packfiles`
pointer in `struct object_database` to reflect this.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Patrick Steinhardt
2025-09-23 12:17:05 +02:00
committed by Junio C Hamano
parent fe835b0ca0
commit bd1a521de8
3 changed files with 23 additions and 17 deletions

View File

@@ -64,6 +64,20 @@ struct packfile_store {
*/
struct packed_git *packs;
/*
* Cache of packfiles which are marked as "kept", either because there
* is an on-disk ".keep" file or because they are marked as "kept" in
* memory.
*
* Should not be accessed directly, but via `kept_pack_cache()`. The
* list of packs gets invalidated when the stored flags and the flags
* passed to `kept_pack_cache()` mismatch.
*/
struct {
struct packed_git **packs;
unsigned flags;
} kept_cache;
/* A most-recently-used ordered version of the packs list. */
struct list_head mru;