@@ -1154,7 +1154,7 @@ static void parse_fetch(struct strbuf *buf)
1154
1154
strbuf_reset (buf );
1155
1155
}
1156
1156
1157
- static int push_dav (int nr_spec , char * * specs )
1157
+ static int push_dav (int nr_spec , const char * * specs )
1158
1158
{
1159
1159
struct child_process child = CHILD_PROCESS_INIT ;
1160
1160
size_t i ;
@@ -1175,7 +1175,7 @@ static int push_dav(int nr_spec, char **specs)
1175
1175
return 0 ;
1176
1176
}
1177
1177
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 )
1179
1179
{
1180
1180
struct rpc_state rpc ;
1181
1181
int i , err ;
@@ -1225,7 +1225,7 @@ static int push_git(struct discovery *heads, int nr_spec, char **specs)
1225
1225
return err ;
1226
1226
}
1227
1227
1228
- static int push (int nr_spec , char * * specs )
1228
+ static int push (int nr_spec , const char * * specs )
1229
1229
{
1230
1230
struct discovery * heads = discover_refs ("git-receive-pack" , 1 );
1231
1231
int ret ;
@@ -1240,14 +1240,12 @@ static int push(int nr_spec, char **specs)
1240
1240
1241
1241
static void parse_push (struct strbuf * buf )
1242
1242
{
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 ;
1245
1245
1246
1246
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 );
1251
1249
else
1252
1250
die (_ ("http transport does not support %s" ), buf -> buf );
1253
1251
@@ -1258,17 +1256,15 @@ static void parse_push(struct strbuf *buf)
1258
1256
break ;
1259
1257
} while (1 );
1260
1258
1261
- ret = push (nr_spec , specs );
1259
+ ret = push (specs . argc , specs . argv );
1262
1260
printf ("\n" );
1263
1261
fflush (stdout );
1264
1262
1265
1263
if (ret )
1266
1264
exit (128 ); /* error already reported */
1267
1265
1268
1266
free_specs :
1269
- for (i = 0 ; i < nr_spec ; i ++ )
1270
- free (specs [i ]);
1271
- free (specs );
1267
+ argv_array_clear (& specs );
1272
1268
}
1273
1269
1274
1270
static int stateless_connect (const char * service_name )
0 commit comments