]> git.ipfire.org Git - thirdparty/git.git/commit
midx-write.c: factor out common want_included_pack() routine
authorTaylor Blau <me@ttaylorr.com>
Mon, 1 Apr 2024 21:16:38 +0000 (17:16 -0400)
committerJunio C Hamano <gitster@pobox.com>
Mon, 1 Apr 2024 21:18:17 +0000 (14:18 -0700)
commite94be606f3153b486a4dd761762353658f72c978
tree5babd391f671d9660ec4c7bf630f9ea28ec64473
parent748b88a0214d4f65fd56d4728234ea86dbcfffd6
midx-write.c: factor out common want_included_pack() routine

When performing a 'git multi-pack-index repack', the MIDX machinery
tries to aggregate MIDX'd packs together either to (a) fill the given
`--batch-size` argument, or (b) combine all packs together.

In either case (using the `midx-write.c::fill_included_packs_batch()` or
`midx-write.c::fill_included_packs_all()` function, respectively), we
evaluate whether or not we want to repack each MIDX'd pack, according to
whether or it is loadable, kept, cruft, or non-empty.

Between the two `fill_included_packs_` callers, they both care about the
same conditions, except for `fill_included_packs_batch()` which also
cares that the pack is non-empty.

We could extract two functions (say, `want_included_pack()` and a
`_nonempty()` variant), but this is not necessary. For the case in
`fill_included_packs_all()` which does not check the pack size, we add
all of the pack's objects assuming that the pack meets all other
criteria. But if the pack is empty in the first place, we add all of its
zero objects, so whether or not we "accept" or "reject" it in the first
place is irrelevant.

This change improves the readability in both `fill_included_packs_`
functions.

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