pack-objects: prepare `write_reused_pack()` for multi-pack reuse
commit48051257101bc4689f91b4ea2eec9606d71686dc
authorTaylor Blau <me@ttaylorr.com>
Thu, 14 Dec 2023 22:24:14 +0000 (14 17:24 -0500)
committerJunio C Hamano <gitster@pobox.com>
Thu, 14 Dec 2023 22:38:08 +0000 (14 14:38 -0800)
treeaac22a15947a1bff8b94fbf10da10dd95e0aff88
parent073b40eba0064ad3bd9bfad89a050208bc033890
pack-objects: prepare `write_reused_pack()` for multi-pack reuse

The function `write_reused_pack()` within `builtin/pack-objects.c` is
responsible for performing pack-reuse on a single pack, and has two main
functions:

  - it dispatches a call to `write_reused_pack_verbatim()` to see if we
    can reuse portions of the packfile in whole-word chunks

  - for any remaining objects (that is, any objects that appear after
    the first "gap" in the bitmap), call write_reused_pack_one() on that
    object to record it for reuse.

Prepare this function for multi-pack reuse by removing the assumption
that the bit position corresponding to the first object being reused
from a given pack must be at bit position zero.

The changes in this function are mostly straightforward. Initialize `i`
to the position of the first word to contain bits corresponding to that
reuse pack. In most situations, we throw the initialized value away,
since we end up replacing it with the return value from
write_reused_pack_verbatim(), moving us past the section of whole words
that we reused.

Likewise, modify the per-object loop to ignore any bits at the beginning
of the first word that do not belong to the pack currently being reused,
as well as skip to the "done" section once we have processed the last
bit corresponding to this pack.

Signed-off-by: Taylor Blau <me@ttaylorr.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/pack-objects.c