git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] remote-curl: simplify passing of push specs

From
Patrick Steinhardt <ps@pks.im>
Date
Jul 16, 2026, 05:27 UTC
Message-ID
<alhr2bb0lUTHtvjO@pks.im>
In-Reply-To
<3b29757e-abcd-4235-a829-ea67c19e71d0@web.de>
On Wed, Jul 15, 2026 at 05:39:51PM +0200, René Scharfe wrote:
Show 43 quoted lines
> On 7/15/26 8:41 AM, Patrick Steinhardt wrote:
> > On Wed, Jul 15, 2026 at 06:41:17AM +0200, René Scharfe wrote:
> >> diff --git a/remote-curl.c b/remote-curl.c
> >> index 9e614c5567..2c35dd5240 100644
> >> --- a/remote-curl.c
> >> +++ b/remote-curl.c
> >> @@ -1340,10 +1340,9 @@ static void parse_get(const char *arg)
> >>  	fflush(stdout);
> >>  }
> >>  
> >> -static int push_dav(int nr_spec, const char **specs)
> >> +static int push_dav(const char **specs)
> >>  {
> >>  	struct child_process child = CHILD_PROCESS_INIT;
> >> -	size_t i;
> >>  
> >>  	child.git_cmd = 1;
> >>  	strvec_push(&child.args, "http-push");
> > 
> > I wonder whether the interface would be even better if we simply passed
> > around a `const struct strvec *` directly. That makes it explicit what
> > kind of guarantees we have, and all transitive callers already have one
> > available anyway.
> 
> You mean that passing a managed array instead of a plain NULL-terminated
> one would make more places visibly safer at almost no cost?
> 
> >> @@ -1353,15 +1352,14 @@ static int push_dav(int nr_spec, const char **specs)
> >>  	if (options.verbosity > 1)
> >>  		strvec_push(&child.args, "--verbose");
> >>  	strvec_push(&child.args, url.buf);
> >> -	for (i = 0; i < nr_spec; i++)
> >> -		strvec_push(&child.args, specs[i]);
> >> +	strvec_pushv(&child.args, specs);
> > 
> > I thought that we had something like `strvec_pushvec()` that knew to
> > also optimize for this case so that we don't have to reallocate the
> > vector multiple times. And if we had that function it would even be more
> > efficient to pass it down the stack. But we seemingly don't have it, so
> > that argument is kind of moot.
> We could add one.  Not sure it would make a measurable difference; if
> the number of specs is huge there are probably other costs that dwarf
> pushing them to a strvec.

Yeah, I don't expect it to make a difference here, either. But by having it we could use it in more places going forward, and that might lead to tiny savings here and there that ultimately add up. So it'd be nudging folks to "do the right thing".

Show 5 quoted lines
> I have to admit that the simplicity of strvec_pushv() nudged me towards
> using a NULL-terminated array here, though.  So just having a
> strvec_pushvec() available could guide towards using the length-limited
> strvec instead of a simpler NULL-terminated array (which explodes if
> left unterminated).

And that's not a huge issue by itself. I think the version you have here is totally fine, and I won't insist on a reroll. But I think it gives us a good opportunity to improve the status quo, if we want to take it.

Thanks!
Patrick
Previous: René ScharfeNext: Junio C Hamano
Message 4 of 5 in “remote-curl: simplify passing of push specs”
  1. remote-curl: simplify passing of push specsRené Scharfe, Jul 15, 2026
  2. Patrick SteinhardtJul 15, 2026
  3. René ScharfeJul 15, 2026
  4. Patrick SteinhardtJul 16, 2026
  5. Junio C HamanoJul 16, 2026

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.