@@ -681,11 +681,10 @@ static int get_pack(struct fetch_pack_args *args,
681
681
int xd [2 ], char * * pack_lockfile )
682
682
{
683
683
struct async demux ;
684
- const char * argv [22 ];
685
- char keep_arg [256 ];
686
- char hdr_arg [256 ];
687
- const char * * av , * cmd_name ;
688
684
int do_keep = args -> keep_pack ;
685
+ const char * cmd_name ;
686
+ struct pack_header header ;
687
+ int pass_header = 0 ;
689
688
struct child_process cmd = CHILD_PROCESS_INIT ;
690
689
int ret ;
691
690
@@ -705,62 +704,61 @@ static int get_pack(struct fetch_pack_args *args,
705
704
else
706
705
demux .out = xd [0 ];
707
706
708
- cmd .argv = argv ;
709
- av = argv ;
710
- * hdr_arg = 0 ;
711
707
if (!args -> keep_pack && unpack_limit ) {
712
- struct pack_header header ;
713
708
714
709
if (read_pack_header (demux .out , & header ))
715
710
die ("protocol error: bad pack header" );
716
- snprintf (hdr_arg , sizeof (hdr_arg ),
717
- "--pack_header=%" PRIu32 ",%" PRIu32 ,
718
- ntohl (header .hdr_version ), ntohl (header .hdr_entries ));
711
+ pass_header = 1 ;
719
712
if (ntohl (header .hdr_entries ) < unpack_limit )
720
713
do_keep = 0 ;
721
714
else
722
715
do_keep = 1 ;
723
716
}
724
717
725
718
if (alternate_shallow_file ) {
726
- * av ++ = "--shallow-file" ;
727
- * av ++ = alternate_shallow_file ;
719
+ argv_array_push ( & cmd . args , "--shallow-file" ) ;
720
+ argv_array_push ( & cmd . args , alternate_shallow_file ) ;
728
721
}
729
722
730
723
if (do_keep ) {
731
724
if (pack_lockfile )
732
725
cmd .out = -1 ;
733
- * av ++ = cmd_name = "index-pack" ;
734
- * av ++ = "--stdin" ;
726
+ cmd_name = "index-pack" ;
727
+ argv_array_push (& cmd .args , cmd_name );
728
+ argv_array_push (& cmd .args , "--stdin" );
735
729
if (!args -> quiet && !args -> no_progress )
736
- * av ++ = "-v" ;
730
+ argv_array_push ( & cmd . args , "-v" ) ;
737
731
if (args -> use_thin_pack )
738
- * av ++ = "--fix-thin" ;
732
+ argv_array_push ( & cmd . args , "--fix-thin" ) ;
739
733
if (args -> lock_pack || unpack_limit ) {
740
- int s = sprintf (keep_arg ,
741
- "--keep=fetch-pack %" PRIuMAX " on " , (uintmax_t ) getpid ());
742
- if (gethostname (keep_arg + s , sizeof (keep_arg ) - s ))
743
- strcpy (keep_arg + s , "localhost" );
744
- * av ++ = keep_arg ;
734
+ char hostname [256 ];
735
+ if (gethostname (hostname , sizeof (hostname )))
736
+ xsnprintf (hostname , sizeof (hostname ), "localhost" );
737
+ argv_array_pushf (& cmd .args ,
738
+ "--keep=fetch-pack %" PRIuMAX " on %s" ,
739
+ (uintmax_t )getpid (), hostname );
745
740
}
746
741
if (args -> check_self_contained_and_connected )
747
- * av ++ = "--check-self-contained-and-connected" ;
742
+ argv_array_push ( & cmd . args , "--check-self-contained-and-connected" ) ;
748
743
}
749
744
else {
750
- * av ++ = cmd_name = "unpack-objects" ;
745
+ cmd_name = "unpack-objects" ;
746
+ argv_array_push (& cmd .args , cmd_name );
751
747
if (args -> quiet || args -> no_progress )
752
- * av ++ = "-q" ;
748
+ argv_array_push ( & cmd . args , "-q" ) ;
753
749
args -> check_self_contained_and_connected = 0 ;
754
750
}
755
- if (* hdr_arg )
756
- * av ++ = hdr_arg ;
751
+
752
+ if (pass_header )
753
+ argv_array_pushf (& cmd .args , "--pack_header=%" PRIu32 ",%" PRIu32 ,
754
+ ntohl (header .hdr_version ),
755
+ ntohl (header .hdr_entries ));
757
756
if (fetch_fsck_objects >= 0
758
757
? fetch_fsck_objects
759
758
: transfer_fsck_objects >= 0
760
759
? transfer_fsck_objects
761
760
: 0 )
762
- * av ++ = "--strict" ;
763
- * av ++ = NULL ;
761
+ argv_array_push (& cmd .args , "--strict" );
764
762
765
763
cmd .in = demux .out ;
766
764
cmd .git_cmd = 1 ;
0 commit comments