builtin/repack.c: use `write_pack_opts` within `write_cruft_pack()`
Similar to the changes made in the previous commit to `write_filtered_pack()`, teach `write_cruft_pack()` to take a `write_pack_opts` struct and use that where possible. 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
3d2ac2065e2ac230c92cb87cc46053a0f3db1616
1 file changed
+14
-13
builtin/repack.c
+14
-13
@@ -221,9 +221,7 @@ static void combine_small_cruft_packs(FILE *in, size_t combine_cruft_below_size,
221
strbuf_release(&buf);
222
}
223
224
-static int write_cruft_pack(const struct pack_objects_args *args,
225
- const char *destination,
226
- const char *pack_prefix,
224
+static int write_cruft_pack(const struct write_pack_opts *opts,
225
const char *cruft_expiration,
226
unsigned long combine_cruft_below_size,
227
struct string_list *names,
@@ -234,9 +232,9 @@ static int write_cruft_pack(const struct pack_objects_args *args,
232
FILE *in;
233
int ret;
234
const char *scratch;
237
- int local = skip_prefix(destination, packdir, &scratch);
235
+ int local = skip_prefix(opts->destination, opts->packdir, &scratch);
236
239
- prepare_pack_objects(&cmd, args, destination);
237
+ prepare_pack_objects(&cmd, opts->po_args, opts->destination);
238
239
strvec_push(&cmd.args, "--cruft");
240
if (cruft_expiration)
@@ -267,7 +265,7 @@ static int write_cruft_pack(const struct pack_objects_args *args,
265
*/
266
in = xfdopen(cmd.in, "w");
267
for_each_string_list_item(item, names)
270
- fprintf(in, "%s-%s.pack\n", pack_prefix, item->string);
268
+ fprintf(in, "%s-%s.pack\n", opts->pack_prefix, item->string);
269
if (combine_cruft_below_size && !cruft_expiration) {
270
combine_small_cruft_packs(in, combine_cruft_below_size,
271
existing);
@@ -599,6 +597,13 @@ int cmd_repack(int argc,
597
598
if (pack_everything & PACK_CRUFT) {
599
const char *pack_prefix = find_pack_prefix(packdir, packtmp);
600
+ struct write_pack_opts opts = {
601
+ .po_args = &cruft_po_args,
602
+ .destination = packtmp,
603
+ .pack_prefix = pack_prefix,
604
+ .packtmp = packtmp,
605
+ .packdir = packdir,
606
+ };
607
608
if (!cruft_po_args.window)
609
cruft_po_args.window = xstrdup_or_null(po_args.window);
@@ -615,8 +620,7 @@ int cmd_repack(int argc,
620
cruft_po_args.quiet = po_args.quiet;
621
cruft_po_args.delta_base_offset = po_args.delta_base_offset;
622
618
- ret = write_cruft_pack(&cruft_po_args, packtmp, pack_prefix,
619
- cruft_expiration,
623
+ ret = write_cruft_pack(&opts, cruft_expiration,
624
combine_cruft_below_size, &names,
625
&existing);
626
if (ret)
@@ -651,11 +655,8 @@ int cmd_repack(int argc,
655
* pack, but rather removing all cruft packs from the
656
* main repository regardless of size.
657
*/
654
- ret = write_cruft_pack(&cruft_po_args, expire_to,
655
- pack_prefix,
656
- NULL,
657
- 0ul,
658
- &names,
658
+ opts.destination = expire_to;
659
+ ret = write_cruft_pack(&opts, NULL, 0ul, &names,
660
&existing);
661
if (ret)
662
goto cleanup;