[PATCH v3 4/4] for-each-repo: simplify passing of parameters
- From
Derrick Stolee via GitGitGadget <gitgitgadget@gmail.com>
- Date
- Mar 2, 2026, 15:36 UTC
- Message-ID
- <f6582e94026eb933dff6fa895775c52ebf32409a.1772465805.git.gitgitgadget@gmail.com>
- In-Reply-To
- <pull.2056.v3.git.1772465805.gitgitgadget@gmail.com>
From: Derrick Stolee <stolee@gmail.com>
This change simplifies the code somewhat from its original implementation.
Signed-off-by: Derrick Stolee <stolee@gmail.com> --- builtin/for-each-repo.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-)
diff --git a/builtin/for-each-repo.c b/builtin/for-each-repo.c index 8bbdc33128..3aafb2cfa8 100644 --- a/builtin/for-each-repo.c +++ b/builtin/for-each-repo.c @@ -14,7 +14,7 @@ static const char * const for_each_repo_usage[] = { NULL }; -static int run_command_on_repo(const char *path, int argc, const char ** argv) +static int run_command_on_repo(const char *path, const char **argv) { struct child_process child = CHILD_PROCESS_INIT; char *abspath = interpolate_path(path, 0); @@ -23,9 +23,7 @@ static int run_command_on_repo(const char *path, int argc, const char ** argv) child.git_cmd = 1; strvec_pushl(&child.args, "-C", abspath, NULL); - - for (i = 0; i < argc; i++) - strvec_push(&child.args, argv[i]); + strvec_pushv(&child.args, argv); free(abspath); @@ -65,7 +63,7 @@ int cmd_for_each_repo(int argc, return 0; for (size_t i = 0; i < values->nr; i++) { - int ret = run_command_on_repo(values->items[i].string, argc, argv); + int ret = run_command_on_repo(values->items[i].string, argv); if (ret) { if (!keep_going) return ret;
-- gitgitgadget