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

From: René Scharfe <[email-masked]>
Date: Fri, 20 Mar 2026 01:46:21 +0100

On 3/19/26 10:14 PM, Junio C Hamano wrote:
> René Scharfe <[email-masked]> 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 <[email-masked]>
>> ---
>>  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é