Re: [PATCH 03/10] packfile: refactor kept-pack cache to work with packfile stores
- From
Justin Tobler <jltobler@gmail.com>
- Date
- Dec 15, 2025, 21:56 UTC
- Message-ID
- <6sverdiyw6y4k5yiocp2v7yhogfvfpmajyiujbmfhzd3n3gb72@wni25ru2m236>
- In-Reply-To
- <20251215-b4-pks-pack-store-via-source-v1-3-433aac465295@pks.im>
On 25/12/15 08:36AM, Patrick Steinhardt wrote:
Show 8 quoted lines
> The kept pack cache is a cache of packfiles that are marked as kept > either via an accompanying ".kept" file or via an in-memory flag. The > cache can be retrieved via `kept_pack_cache()`, where one needs to pass > in a repository. > > Ultimately though the kept-pack cache is a property of the packfile > store, and this causes problems in a subsequent commit where we want to > move down the packfile store to be a per-object-source entity.
Looking at the existing code, the `kept_cache` is already part of the packfile store, but the interface to access it, `kept_pack_cache()`, goes through `struct repository`. Refining this interface to go through the packfile store makes sense.
Show 5 quoted lines
> Prepare for this and refactor the kept-pack cache to work on top of a > packfile store instead. > > Signed-off-by: Patrick Steinhardt <ps@pks.im> > ---
[snip]
Show 12 quoted lines
> diff --git a/packfile.h b/packfile.h
> index 33cc1c1654..701a3b4946 100644
> --- a/packfile.h
> +++ b/packfile.h
> @@ -210,6 +210,19 @@ struct packed_git *packfile_store_load_pack(struct packfile_store *store,
> int packfile_store_freshen_object(struct packfile_store *store,
> const struct object_id *oid);
>
> +enum kept_pack_type {
> + KEPT_PACK_ON_DISK = (1 << 0),
> + KEPT_PACK_IN_CORE = (1 << 1),
> +};Looks like while we are here we are renaming some existing flags and storing them in an enum instead. Makes sense, but maybe we should also explicitly mention this in the commit message since much of the fallout in the diff relates to this change.
Show 8 quoted lines
> + > +/* > + * Retrieve the cache of kept packs from the given packfile store. Accepts a > + * combination of `kept_pack_type` flags. The cache is computed on demand and > + * will be recomputed whenever the flags change. > + */ > +struct packed_git **packfile_store_get_kept_pack_cache(struct packfile_store *store, > + unsigned flags);
Now the kept cache is accessed through the packfile store instead of the repository. Make sense.
Since we are also changing the name from `kept_pack_cache()`, there are some comments in "packfile.h" that are now outdated. We may want to update them here.
The other changes in this patch simply update in accordance to this new interface and all look correct.
-Justin