]> git.ipfire.org Git - thirdparty/git.git/commitdiff
for-each-repo: simplify passing of parameters
authorDerrick Stolee <stolee@gmail.com>
Tue, 3 Mar 2026 17:31:54 +0000 (17:31 +0000)
committerJunio C Hamano <gitster@pobox.com>
Tue, 3 Mar 2026 18:20:00 +0000 (10:20 -0800)
This change simplifies the code somewhat from its original
implementation.

Signed-off-by: Derrick Stolee <stolee@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/for-each-repo.c

index 82727c4aa2d0152acc609df7ac46743ee68a6656..927d3d92da5732f56f41ccdcf09f316a7ee24eab 100644 (file)
@@ -14,9 +14,8 @@ 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)
 {
-       int i;
        struct child_process child = CHILD_PROCESS_INIT;
        char *abspath = interpolate_path(path, 0);
 
@@ -24,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);
 
@@ -66,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;