]> git.ipfire.org Git - thirdparty/git.git/commit
packfile: move the MRU list into the packfile store
authorPatrick Steinhardt <ps@pks.im>
Thu, 30 Oct 2025 10:38:39 +0000 (11:38 +0100)
committerJunio C Hamano <gitster@pobox.com>
Thu, 30 Oct 2025 14:09:52 +0000 (07:09 -0700)
commitf905a855b1d1e172ba1e51e03fc5ec531445575e
tree8d767b5588c5c62e8a0c57fba8c82c50a80c8db5
parente78ab370545d81a950fa3b2701dd7c72015ee802
packfile: move the MRU list into the packfile store

Packfiles have two lists associated to them:

  - A list that keeps track of packfiles in the order that they were
    added to a packfile store.

  - A list that keeps track of packfiles in most-recently-used order so
    that packfiles that are more likely to contain a specific object are
    ordered towards the front.

Both of these lists are hosted by `struct packed_git` itself, So to
identify all packfiles in a repository you simply need to grab the first
packfile and then iterate the `->next` pointers or the MRU list. This
pattern has the problem that all packfiles are part of the same list,
regardless of whether or not they belong to the same object source.

With the upcoming pluggable object database effort this needs to change:
packfiles should be contained by a single object source, and reading an
object from any such packfile should use that source to look up the
object. Consequently, we need to break up the global lists of packfiles
into per-object-source lists.

A first step towards this goal is to move those lists out of `struct
packed_git` and into the packfile store. While the packfile store is
currently sitting on the `struct object_database` level, the intent is
to push it down one level into the `struct odb_source` in a subsequent
patch series.

Introduce a new `struct packfile_list` that is used to manage lists of
packfiles and use it to store the list of most-recently-used packfiles
in `struct packfile_store`. For now, the new list type is only used in a
single spot, but we'll expand its usage in subsequent patches.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/pack-objects.c
midx.c
packfile.c
packfile.h