remote-curl: simplify passing of push specs

The push specs are kept in a strvec, whose array is NULL-terminated. Pass only that to the protocol handlers, which avoids dealing with item counts and their conversions from size_t to int, slightly simplifying the code. Signed-off-by: René Scharfe <l.s.r@web.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>

René Scharfe committed Jul 15, 2026 at 06:41 UTC f749a83291681bd19ab8712e2a4e1c931bb8b241
1 file changed +9 -11
remote-curl.c
+9 -11
@@ -1340,10 +1340,9 @@ static void parse_get(const char *arg)
1340 fflush(stdout);
1341 }
1342
1343 -static int push_dav(int nr_spec, const char **specs)
1343 +static int push_dav(const char **specs)
1344 {
1345 struct child_process child = CHILD_PROCESS_INIT;
1346 - size_t i;
1346
1347 child.git_cmd = 1;
1348 strvec_push(&child.args, "http-push");
@@ -1353,15 +1352,14 @@ static int push_dav(int nr_spec, const char **specs)
1352 if (options.verbosity > 1)
1353 strvec_push(&child.args, "--verbose");
1354 strvec_push(&child.args, url.buf);
1356 - for (i = 0; i < nr_spec; i++)
1357 - strvec_push(&child.args, specs[i]);
1355 + strvec_pushv(&child.args, specs);
1356
1357 if (run_command(&child))
1358 die(_("git-http-push failed"));
1359 return 0;
1360 }
1361
1364 -static int push_git(struct discovery *heads, int nr_spec, const char **specs)
1362 +static int push_git(struct discovery *heads, const char **specs)
1363 {
1364 struct rpc_state rpc = RPC_STATE_INIT;
1365 int i, err;
@@ -1400,8 +1398,8 @@ static int push_git(struct discovery *heads, int nr_spec, const char **specs)
1398 strvec_push(&args, "--force-if-includes");
1399
1400 strvec_push(&args, "--stdin");
1403 - for (i = 0; i < nr_spec; i++)
1404 - packet_buf_write(&preamble, "%s\n", specs[i]);
1401 + for (; *specs; specs++)
1402 + packet_buf_write(&preamble, "%s\n", *specs);
1403 packet_buf_flush(&preamble);
1404
1405 memset(&rpc, 0, sizeof(rpc));
@@ -1416,15 +1414,15 @@ static int push_git(struct discovery *heads, int nr_spec, const char **specs)
1414 return err;
1415 }
1416
1419 -static int push(int nr_spec, const char **specs)
1417 +static int push(const char **specs)
1418 {
1419 struct discovery *heads = discover_refs("git-receive-pack", 1);
1420 int ret;
1421
1422 if (heads->proto_git)
1425 - ret = push_git(heads, nr_spec, specs);
1423 + ret = push_git(heads, specs);
1424 else
1427 - ret = push_dav(nr_spec, specs);
1425 + ret = push_dav(specs);
1426 free_discovery(heads);
1427 return ret;
1428 }
@@ -1448,7 +1446,7 @@ static void parse_push(struct strbuf *buf)
1446 break;
1447 } while (1);
1448
1451 - ret = push(specs.nr, specs.v);
1449 + ret = push(specs.v);
1450 printf("\n");
1451 fflush(stdout);
1452