builtin/repack.c: reorder `remove_redundant_bitmaps()`

The next commit will inline the call to `remove_redundant_bitmaps()` into `write_midx_included_packs()`. Reorder these two functions to avoid a forward declaration to `remove_redundant_bitmaps()`. Signed-off-by: Taylor Blau <me@ttaylorr.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Taylor Blau committed Oct 15, 2025 at 18:29 UTC 42088e3d4ae5c5bc77a49fcbba79832d10d03499
1 file changed +29 -29
builtin/repack.c
+29 -29
@@ -296,6 +296,35 @@ static void midx_included_packs(struct string_list *include,
296 strbuf_release(&buf);
297 }
298
299 +static void remove_redundant_bitmaps(struct string_list *include,
300 + const char *packdir)
301 +{
302 + struct strbuf path = STRBUF_INIT;
303 + struct string_list_item *item;
304 + size_t packdir_len;
305 +
306 + strbuf_addstr(&path, packdir);
307 + strbuf_addch(&path, '/');
308 + packdir_len = path.len;
309 +
310 + /*
311 + * Remove any pack bitmaps corresponding to packs which are now
312 + * included in the MIDX.
313 + */
314 + for_each_string_list_item(item, include) {
315 + strbuf_addstr(&path, item->string);
316 + strbuf_strip_suffix(&path, ".idx");
317 + strbuf_addstr(&path, ".bitmap");
318 +
319 + if (unlink(path.buf) && errno != ENOENT)
320 + warning_errno(_("could not remove stale bitmap: %s"),
321 + path.buf);
322 +
323 + strbuf_setlen(&path, packdir_len);
324 + }
325 + strbuf_release(&path);
326 +}
327 +
328 static int write_midx_included_packs(struct repack_write_midx_opts *opts)
329 {
330 struct child_process cmd = CHILD_PROCESS_INIT;
@@ -373,35 +402,6 @@ static int write_midx_included_packs(struct repack_write_midx_opts *opts)
402 return finish_command(&cmd);
403 }
404
376 -static void remove_redundant_bitmaps(struct string_list *include,
377 - const char *packdir)
378 -{
379 - struct strbuf path = STRBUF_INIT;
380 - struct string_list_item *item;
381 - size_t packdir_len;
382 -
383 - strbuf_addstr(&path, packdir);
384 - strbuf_addch(&path, '/');
385 - packdir_len = path.len;
386 -
387 - /*
388 - * Remove any pack bitmaps corresponding to packs which are now
389 - * included in the MIDX.
390 - */
391 - for_each_string_list_item(item, include) {
392 - strbuf_addstr(&path, item->string);
393 - strbuf_strip_suffix(&path, ".idx");
394 - strbuf_addstr(&path, ".bitmap");
395 -
396 - if (unlink(path.buf) && errno != ENOENT)
397 - warning_errno(_("could not remove stale bitmap: %s"),
398 - path.buf);
399 -
400 - strbuf_setlen(&path, packdir_len);
401 - }
402 - strbuf_release(&path);
403 -}
404 -
405 static int finish_pack_objects_cmd(const struct git_hash_algo *algop,
406 struct child_process *cmd,
407 struct string_list *names,