Skip to content

Commit 677c981

Browse files
avargitster
authored andcommitted
submodule--helper: convert "foreach" to its own "--super-prefix"
As with a preceding commit to convert "absorbgitdirs", we can convert "submodule--helper foreach" to use its own "--super-prefix", instead of relying on the global "--super-prefix" argument to "git" itself. See that earlier commit for the rationale and background. Signed-off-by: Ævar Arnfjörð Bjarmason <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent bb61a96 commit 677c981

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

builtin/submodule--helper.c

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -278,6 +278,7 @@ struct foreach_cb {
278278
int argc;
279279
const char **argv;
280280
const char *prefix;
281+
const char *super_prefix;
281282
int quiet;
282283
int recursive;
283284
};
@@ -294,7 +295,7 @@ static void runcommand_in_submodule_cb(const struct cache_entry *list_item,
294295
char *displaypath;
295296

296297
displaypath = get_submodule_displaypath(path, info->prefix,
297-
get_super_prefix());
298+
info->super_prefix);
298299

299300
sub = submodule_from_path(the_repository, null_oid(), path);
300301

@@ -364,10 +365,10 @@ static void runcommand_in_submodule_cb(const struct cache_entry *list_item,
364365
cpr.dir = path;
365366
prepare_submodule_repo_env(&cpr.env);
366367

367-
strvec_pushl(&cpr.args, "--super-prefix", NULL);
368-
strvec_pushf(&cpr.args, "%s/", displaypath);
369368
strvec_pushl(&cpr.args, "submodule--helper", "foreach", "--recursive",
370369
NULL);
370+
strvec_pushl(&cpr.args, "--super-prefix", NULL);
371+
strvec_pushf(&cpr.args, "%s/", displaypath);
371372

372373
if (info->quiet)
373374
strvec_push(&cpr.args, "--quiet");
@@ -391,6 +392,7 @@ static int module_foreach(int argc, const char **argv, const char *prefix)
391392
struct pathspec pathspec = { 0 };
392393
struct module_list list = MODULE_LIST_INIT;
393394
struct option module_foreach_options[] = {
395+
OPT__SUPER_PREFIX(&info.super_prefix),
394396
OPT__QUIET(&info.quiet, N_("suppress output of entering each submodule command")),
395397
OPT_BOOL(0, "recursive", &info.recursive,
396398
N_("recurse into nested submodules")),
@@ -3390,8 +3392,8 @@ int cmd_submodule__helper(int argc, const char **argv, const char *prefix)
33903392
subcmd = argv[0];
33913393

33923394
if (strcmp(subcmd, "clone") && strcmp(subcmd, "update") &&
3393-
strcmp(subcmd, "foreach") && strcmp(subcmd, "status") &&
3394-
strcmp(subcmd, "sync") && get_super_prefix())
3395+
strcmp(subcmd, "status") && strcmp(subcmd, "sync") &&
3396+
get_super_prefix())
33953397
/*
33963398
* xstrfmt() rather than "%s %s" to keep the translated
33973399
* string identical to git.c's.

0 commit comments

Comments
 (0)