aboutsummaryrefslogtreecommitdiff
path: root/builtin
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2026-03-12 14:09:05 -0700
committerJunio C Hamano <gitster@pobox.com>2026-03-12 14:09:05 -0700
commit03161747b412fe739d8a7ef631769b3d8f60d56f (patch)
tree53971ec6e6ee40b89ccd2f2be909e1bf8fca8541 /builtin
parent67006b9db8b772423ad0706029286096307d2567 (diff)
parente87493b9b4876e8278062af70cf2d97f47c45e60 (diff)
downloadgit-03161747b412fe739d8a7ef631769b3d8f60d56f.tar.xz
Merge branch 'ds/for-each-repo-w-worktree'
"git for-each-repo" started from a secondary worktree did not work as expected, which has been corrected. * ds/for-each-repo-w-worktree: for-each-repo: simplify passing of parameters for-each-repo: work correctly in a worktree run-command: extract sanitize_repo_env helper for-each-repo: test outside of repo context
Diffstat (limited to 'builtin')
-rw-r--r--builtin/for-each-repo.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/builtin/for-each-repo.c b/builtin/for-each-repo.c
index 325a7925f1..927d3d92da 100644
--- a/builtin/for-each-repo.c
+++ b/builtin/for-each-repo.c
@@ -2,6 +2,7 @@
#include "builtin.h"
#include "config.h"
+#include "environment.h"
#include "gettext.h"
#include "parse-options.h"
#include "path.h"
@@ -13,17 +14,16 @@ 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);
+ sanitize_repo_env(&child.env);
+
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);
@@ -63,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;