public inbox for git@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] use strvec_pushv() to add another strvec
@ 2026-03-19 20:49 René Scharfe
  2026-03-19 21:14 ` Junio C Hamano
  2026-03-20  0:46 ` [PATCH v2] " René Scharfe
  0 siblings, 2 replies; 6+ messages in thread
From: René Scharfe @ 2026-03-19 20:49 UTC (permalink / raw)
  To: Git List

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(-)

diff --git a/fetch-pack.c b/fetch-pack.c
index 6ecd468ef7..a32224ed02 100644
--- a/fetch-pack.c
+++ b/fetch-pack.c
@@ -1024,12 +1024,8 @@ static int get_pack(struct fetch_pack_args *args,
 				     fsck_msg_types.buf);
 	}
 
-	if (index_pack_args) {
-		int i;
-
-		for (i = 0; i < cmd.args.nr; i++)
-			strvec_push(index_pack_args, cmd.args.v[i]);
-	}
+	if (index_pack_args)
+		strvec_pushv(index_pack_args, cmd.args.v);
 
 	sigchain_push(SIGPIPE, SIG_IGN);
 
diff --git a/git.c b/git.c
index 2b212e6675..5a40eab8a2 100644
--- a/git.c
+++ b/git.c
@@ -877,8 +877,7 @@ static int run_argv(struct strvec *args)
 			commit_pager_choice();
 
 			strvec_push(&cmd.args, "git");
-			for (size_t i = 0; i < args->nr; i++)
-				strvec_push(&cmd.args, args->v[i]);
+			strvec_pushv(&cmd.args, args->v);
 
 			trace_argv_printf(cmd.args.v, "trace: exec:");
 
diff --git a/submodule.c b/submodule.c
index cd879a5cfe..4c8c674aa4 100644
--- a/submodule.c
+++ b/submodule.c
@@ -1815,7 +1815,6 @@ int fetch_submodules(struct repository *r,
 		     int default_option,
 		     int quiet, int max_parallel_jobs)
 {
-	int i;
 	struct submodule_parallel_fetch spf = SPF_INIT;
 	const struct run_process_parallel_opts opts = {
 		.tr2_category = "submodule",
@@ -1842,8 +1841,7 @@ int fetch_submodules(struct repository *r,
 		die(_("index file corrupt"));
 
 	strvec_push(&spf.args, "fetch");
-	for (i = 0; i < options->nr; i++)
-		strvec_push(&spf.args, options->v[i]);
+	strvec_pushv(&spf.args, options->v);
 	strvec_push(&spf.args, "--recurse-submodules-default");
 	/* default value, "--submodule-prefix" and its value are added later */
 
-- 
2.53.0

^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2026-03-27 23:07 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-19 20:49 [PATCH] use strvec_pushv() to add another strvec René Scharfe
2026-03-19 21:14 ` Junio C Hamano
2026-03-20  0:46   ` René Scharfe
2026-03-20  0:46 ` [PATCH v2] " René Scharfe
2026-03-22 18:05   ` Junio C Hamano
2026-03-27 23:07     ` René Scharfe

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox