]> git.99rst.org Git - git.git/commit
pack-bitmap: iterate object sources when opening bitmaps
authorPatrick Steinhardt <redacted>
Wed, 15 Jul 2026 06:22:35 +0000 (08:22 +0200)
committerJunio C Hamano <redacted>
Wed, 15 Jul 2026 14:19:16 +0000 (07:19 -0700)
commiteaa9807c970254e503cdb2d719d873521de4ed05
tree5086d89c43b26d708fd56d0f7a3d2f5d5c0fad04
parent1ca65ca7b8bce87268900e39315888fd10fc350c
pack-bitmap: iterate object sources when opening bitmaps

When opening a bitmap for a repository we perform two steps:

  - We first look for a multi-pack index bitmap in any of the object
    sources connected to the repository.

  - We then look for a packfile bitmap in any of the packfiles of any of
    the object sources.

Both of these steps thus iterate through object sources themselves, one
via `odb_prepare_alternates()` and one via `repo_for_each_pack()`. This
layout makes it hard to introduce a way to open the bitmap of one
specific object source, which is functionality that we'll require in a
subsequent commit.

Reverse the loop so that we instead loop through all sources in the
outer loop, and then for each source we try to load its bitmap via
either the multi-pack index or via a packfile.

Note that this changes the precedence of bitmaps in one specific edge
case: when an earlier object source only has a packfile bitmap, but a
later source has a multi-pack index bitmap, we now pick the packfile
bitmap of the earlier source. Previously, a multi-pack index bitmap from
any source would have taken precedence over all packfile bitmaps. Given
that object sources are ordered such that the local source comes first,
this arguably is an improvement, as we now prefer local bitmaps over
bitmaps in alternates. Furthermore, we already warn about repositories
that have multiple bitmaps, so this setup is broken and thus arguably
not worth worrying about too much.

Signed-off-by: Patrick Steinhardt <redacted>
Signed-off-by: Junio C Hamano <redacted>
pack-bitmap.c
git clone https://git.99rst.org/PROJECT