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

Re: [PATCH] use strvec_pushv() to add another strvec

From
René Scharfe <l.s.r@web.de>
Date
Mar 20, 2026, 00:46 UTC
Message-ID
<6c16da38-654d-4959-b0d9-3fff3d96d036@web.de>
In-Reply-To
<xmqqwlz7iks3.fsf@gitster.g>
On 3/19/26 10:14 PM, Junio C Hamano wrote:
Show 26 quoted lines
> René Scharfe <l.s.r@web.de> writes:
> 
>> Simplify the code by letting strvec_pushv() add the items of a second
>> strvec instead of pushing them one by one.
>>
>> Signed-off-by: René Scharfe <l.s.r@web.de>
>> ---
>>  fetch-pack.c | 8 ++------
>>  git.c        | 3 +--
>>  submodule.c  | 4 +---
>>  3 files changed, 4 insertions(+), 11 deletions(-)
> 
> Nice.  Is this something we can make a coccinelle rule for?
> 
> Something like
> 
> @@
> struct strvec SRC;
> struct strvec DST;
> size_t I;
> @@
> -	for (size_t I = 0; I < SRC.nr; I++)
> -		strvec_push(&DST, SRC.v[I]);
> +	strvec_pushv(&DST, SRC.v);
> 
> perhaps?

We can. Should we? It does find a fourth case from the 18th batch that has landed a few hours ago, at least. Will send as v2.

René
Previous: Junio C HamanoNext: René Scharfe
Message 3 of 6 in “use strvec_pushv() to add another strvec”
  1. use strvec_pushv() to add another strvecRené Scharfe, Mar 19, 2026
  2. Junio C HamanoMar 19, 2026
  3. René ScharfeMar 20, 2026
  4. use strvec_pushv() to add another strvecRené Scharfe, Mar 20, 2026
  5. Junio C HamanoMar 22, 2026
  6. René ScharfeMar 27, 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.