Re: [PATCH 14/16] repack: implement incremental MIDX repacking
- From
Elijah Newren <newren@gmail.com>
- Date
- Apr 16, 2026, 22:53 UTC
- Message-ID
- <CABPp-BHuj8UKG3Mh9opniHMrgNkKiWLKv7pqVAex3PeAX1+Ydw@mail.gmail.com>
- In-Reply-To
- <8d5aa3d6fa70d408fc02561f2203ae1a48186c91.1774820449.git.me@ttaylorr.com>
On Sun, Mar 29, 2026 at 2:41 PM Taylor Blau <me@ttaylorr.com> wrote:
Show 5 quoted lines
> > At present, this functionality is exposed behind a new enum value, > `REPACK_WRITE_MIDX_INCREMENTAL`, but has no external callers. A > subsequent commit will expose this mode via `git repack > --write-midx=incremental`.
Noted, although...
Show 11 quoted lines
> + /*
> + * Compact additional MIDX layers into this proposed one until
> + * the merging condition is violated.
> + */
> + while (m) {
> + uint32_t preferred_pack_idx;
> +
> + trace2_data_string("repack", opts->existing->repo,
> + "candidate", midx_get_checksum_hex(m));
> +
> + if (step.objects_nr < m->num_objects / opts->midx_split_factor) {Here the new value is used...
> + if (proposed_objects_nr < next->base_midx->num_objects / opts->midx_split_factor) {...and here...
Show 9 quoted lines
> struct repack_write_midx_opts {
> @@ -148,6 +149,8 @@ struct repack_write_midx_opts {
> int show_progress;
> int write_bitmaps;
> int midx_must_contain_cruft;
> + int midx_split_factor;
> + int midx_new_layer_threshold;
> enum repack_write_midx_mode mode;
> };...and here it is defined. There is also another new value defined here (midx_new_layer_threshold) that isn't used anywhere in this patch yet, but I'll focus on midx_split_factor.
Although, midx_split_factor is defined here, it isn't explicitly initialized anywhere. As far as I can tell, it's only initialized through a designated initializer in builtin/repack.c with midx_split_factor not appearing as one of the designated fields and thus getting a value of 0. That would result in a divide by zero...although, as you noted in the commit message, this code isn't yet active.
Still, would it make sense to initialize opts.midx_split_factor in builtin/repack.c to something non-zero as part of this patch?