]> git.ipfire.org Git - thirdparty/git.git/commit
midx-write.c: support reading an existing MIDX with `packs_to_include`
authorTaylor Blau <me@ttaylorr.com>
Wed, 29 May 2024 22:55:39 +0000 (18:55 -0400)
committerJunio C Hamano <gitster@pobox.com>
Thu, 30 May 2024 20:43:51 +0000 (13:43 -0700)
commitd6a8c58675a04abe2597179e3332bf031bd6e48a
tree83b2d08facb4f5d9165958f056492ea08fb9cae1
parentc5e204af1f395f38724aff08c3440aa86fdd9657
midx-write.c: support reading an existing MIDX with `packs_to_include`

Avoid unconditionally copying all packs from an existing MIDX into a new
MIDX by checking that packs added via `fill_packs_from_midx()` don't
appear in the `to_include` set, if one was provided.

Do so by calling `should_include_pack()` from both `add_pack_to_midx()`
and `fill_packs_from_midx()`.

In order to make this work, teach `should_include_pack()` a new
"exclude_from_midx" parameter, which allows skipping the first check.
This is done so that the caller in `fill_packs_from_midx()` doesn't
reject all of the packs it provided since they appear in an existing
MIDX by definition.

The sum total of this change is that we are now able to read and
reference objects in an existing MIDX even when given a non-NULL
`packs_to_include`. This is a prerequisite step for incremental MIDXs,
which need to load any existing MIDX (if one is present) in order to
determine whether or not an object already appears in an earlier portion
of the MIDX to avoid duplicating it across multiple portions.

Signed-off-by: Taylor Blau <me@ttaylorr.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
midx-write.c