From: Elijah Newren Date: Thu, 16 Apr 2026 22:53:10 GMT Subject: Re: [PATCH 14/16] repack: implement incremental MIDX repacking Message-ID: In-Reply-To: <8d5aa3d6fa70d408fc02561f2203ae1a48186c91.1774820449.git.me@ttaylorr.com> On Sun, Mar 29, 2026 at 2:41 PM Taylor Blau wrote: > > 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... > + /* > + * 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... > 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?