pack-bitmap: return multiple packs via reuse_partial_packfile_from_bitmap()

Further prepare for enabling verbatim pack-reuse over multiple packfiles
by changing the signature of reuse_partial_packfile_from_bitmap() to
populate an array of `struct bitmapped_pack *`'s instead of a pointer to
a single packfile.

Since the array we're filling out is sized dynamically[^1], add an
additional `size_t *` parameter which will hold the number of reusable
packs (equal to the number of elements in the array).

Note that since we still have not implemented true multi-pack reuse,
these changes aren't propagated out to the rest of the caller in
builtin/pack-objects.c.

In the interim state, we expect that the array has a single element, and
we use that element to fill out the static `reuse_packfile` variable
(which is a bog-standard `struct packed_git *`). Future commits will
continue to push this change further out through the pack-objects code.

[^1]: That is, even though we know the number of packs which are
  candidates for pack-reuse, we do not know how many of those
  candidates we can actually reuse.

Signed-off-by: Taylor Blau <me@ttaylorr.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Taylor Blau
2023-12-14 17:24:04 -05:00
committed by Junio C Hamano
parent 35e156b9de
commit 83296d20e8
3 changed files with 14 additions and 6 deletions

View File

@ -2001,7 +2001,8 @@ static int bitmapped_pack_cmp(const void *va, const void *vb)
}
void reuse_partial_packfile_from_bitmap(struct bitmap_index *bitmap_git,
struct packed_git **packfile_out,
struct bitmapped_pack **packs_out,
size_t *packs_nr_out,
struct bitmap **reuse_out)
{
struct repository *r = the_repository;
@ -2069,7 +2070,8 @@ void reuse_partial_packfile_from_bitmap(struct bitmap_index *bitmap_git,
* need to be handled separately.
*/
bitmap_and_not(result, reuse);
*packfile_out = packs[0].p;
*packs_out = packs;
*packs_nr_out = packs_nr;
*reuse_out = reuse;
}