@@ -1154,7 +1154,7 @@ static void parse_fetch(struct strbuf *buf)
11541154 strbuf_reset (buf );
11551155}
11561156
1157- static int push_dav (int nr_spec , char * * specs )
1157+ static int push_dav (int nr_spec , const char * * specs )
11581158{
11591159 struct child_process child = CHILD_PROCESS_INIT ;
11601160 size_t i ;
@@ -1175,7 +1175,7 @@ static int push_dav(int nr_spec, char **specs)
11751175 return 0 ;
11761176}
11771177
1178- static int push_git (struct discovery * heads , int nr_spec , char * * specs )
1178+ static int push_git (struct discovery * heads , int nr_spec , const char * * specs )
11791179{
11801180 struct rpc_state rpc ;
11811181 int i , err ;
@@ -1225,7 +1225,7 @@ static int push_git(struct discovery *heads, int nr_spec, char **specs)
12251225 return err ;
12261226}
12271227
1228- static int push (int nr_spec , char * * specs )
1228+ static int push (int nr_spec , const char * * specs )
12291229{
12301230 struct discovery * heads = discover_refs ("git-receive-pack" , 1 );
12311231 int ret ;
@@ -1240,14 +1240,12 @@ static int push(int nr_spec, char **specs)
12401240
12411241static void parse_push (struct strbuf * buf )
12421242{
1243- char * * specs = NULL ;
1244- int alloc_spec = 0 , nr_spec = 0 , i , ret ;
1243+ struct argv_array specs = ARGV_ARRAY_INIT ;
1244+ int ret ;
12451245
12461246 do {
1247- if (starts_with (buf -> buf , "push " )) {
1248- ALLOC_GROW (specs , nr_spec + 1 , alloc_spec );
1249- specs [nr_spec ++ ] = xstrdup (buf -> buf + 5 );
1250- }
1247+ if (starts_with (buf -> buf , "push " ))
1248+ argv_array_push (& specs , buf -> buf + 5 );
12511249 else
12521250 die (_ ("http transport does not support %s" ), buf -> buf );
12531251
@@ -1258,17 +1256,15 @@ static void parse_push(struct strbuf *buf)
12581256 break ;
12591257 } while (1 );
12601258
1261- ret = push (nr_spec , specs );
1259+ ret = push (specs . argc , specs . argv );
12621260 printf ("\n" );
12631261 fflush (stdout );
12641262
12651263 if (ret )
12661264 exit (128 ); /* error already reported */
12671265
12681266 free_specs :
1269- for (i = 0 ; i < nr_spec ; i ++ )
1270- free (specs [i ]);
1271- free (specs );
1267+ argv_array_clear (& specs );
12721268}
12731269
12741270static int stateless_connect (const char * service_name )
0 commit comments