@@ -221,9 +221,7 @@ static void combine_small_cruft_packs(FILE *in, size_t combine_cruft_below_size,
221221 strbuf_release (& buf );
222222}
223223
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 ,
227225 const char * cruft_expiration ,
228226 unsigned long combine_cruft_below_size ,
229227 struct string_list * names ,
@@ -234,9 +232,9 @@ static int write_cruft_pack(const struct pack_objects_args *args,
234232 FILE * in ;
235233 int ret ;
236234 const char * scratch ;
237- int local = skip_prefix (destination , packdir , & scratch );
235+ int local = skip_prefix (opts -> destination , opts -> packdir , & scratch );
238236
239- prepare_pack_objects (& cmd , args , destination );
237+ prepare_pack_objects (& cmd , opts -> po_args , opts -> destination );
240238
241239 strvec_push (& cmd .args , "--cruft" );
242240 if (cruft_expiration )
@@ -267,7 +265,7 @@ static int write_cruft_pack(const struct pack_objects_args *args,
267265 */
268266 in = xfdopen (cmd .in , "w" );
269267 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 );
271269 if (combine_cruft_below_size && !cruft_expiration ) {
272270 combine_small_cruft_packs (in , combine_cruft_below_size ,
273271 existing );
@@ -599,6 +597,13 @@ int cmd_repack(int argc,
599597
600598 if (pack_everything & PACK_CRUFT ) {
601599 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+ };
602607
603608 if (!cruft_po_args .window )
604609 cruft_po_args .window = xstrdup_or_null (po_args .window );
@@ -615,8 +620,7 @@ int cmd_repack(int argc,
615620 cruft_po_args .quiet = po_args .quiet ;
616621 cruft_po_args .delta_base_offset = po_args .delta_base_offset ;
617622
618- ret = write_cruft_pack (& cruft_po_args , packtmp , pack_prefix ,
619- cruft_expiration ,
623+ ret = write_cruft_pack (& opts , cruft_expiration ,
620624 combine_cruft_below_size , & names ,
621625 & existing );
622626 if (ret )
@@ -651,11 +655,8 @@ int cmd_repack(int argc,
651655 * pack, but rather removing all cruft packs from the
652656 * main repository regardless of size.
653657 */
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 ,
659660 & existing );
660661 if (ret )
661662 goto cleanup ;
0 commit comments