Skip to content

Commit 99a32d8

Browse files
avargitster
authored andcommitted
submodule--helper: convert "sync" to its own "--super-prefix"
As with a preceding commit to convert "absorbgitdirs", we can convert "submodule--helper sync" 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 677c981 commit 99a32d8

File tree

1 file changed

+11
-9
lines changed

1 file changed

+11
-9
lines changed

builtin/submodule--helper.c

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1208,12 +1208,13 @@ static int module_summary(int argc, const char **argv, const char *prefix)
12081208

12091209
struct sync_cb {
12101210
const char *prefix;
1211+
const char *super_prefix;
12111212
unsigned int flags;
12121213
};
12131214
#define SYNC_CB_INIT { 0 }
12141215

12151216
static void sync_submodule(const char *path, const char *prefix,
1216-
unsigned int flags)
1217+
const char *super_prefix, unsigned int flags)
12171218
{
12181219
const struct submodule *sub;
12191220
char *remote_key = NULL;
@@ -1244,8 +1245,7 @@ static void sync_submodule(const char *path, const char *prefix,
12441245
super_config_url = xstrdup("");
12451246
}
12461247

1247-
displaypath = get_submodule_displaypath(path, prefix,
1248-
get_super_prefix());
1248+
displaypath = get_submodule_displaypath(path, prefix, super_prefix);
12491249

12501250
if (!(flags & OPT_QUIET))
12511251
printf(_("Synchronizing submodule url for '%s'\n"),
@@ -1282,10 +1282,11 @@ static void sync_submodule(const char *path, const char *prefix,
12821282
cpr.dir = path;
12831283
prepare_submodule_repo_env(&cpr.env);
12841284

1285-
strvec_push(&cpr.args, "--super-prefix");
1286-
strvec_pushf(&cpr.args, "%s/", displaypath);
12871285
strvec_pushl(&cpr.args, "submodule--helper", "sync",
12881286
"--recursive", NULL);
1287+
strvec_push(&cpr.args, "--super-prefix");
1288+
strvec_pushf(&cpr.args, "%s/", displaypath);
1289+
12891290

12901291
if (flags & OPT_QUIET)
12911292
strvec_push(&cpr.args, "--quiet");
@@ -1308,7 +1309,8 @@ static void sync_submodule_cb(const struct cache_entry *list_item, void *cb_data
13081309
{
13091310
struct sync_cb *info = cb_data;
13101311

1311-
sync_submodule(list_item->name, info->prefix, info->flags);
1312+
sync_submodule(list_item->name, info->prefix, info->super_prefix,
1313+
info->flags);
13121314
}
13131315

13141316
static int module_sync(int argc, const char **argv, const char *prefix)
@@ -1319,6 +1321,7 @@ static int module_sync(int argc, const char **argv, const char *prefix)
13191321
int quiet = 0;
13201322
int recursive = 0;
13211323
struct option module_sync_options[] = {
1324+
OPT__SUPER_PREFIX(&info.super_prefix),
13221325
OPT__QUIET(&quiet, N_("suppress output of synchronizing submodule url")),
13231326
OPT_BOOL(0, "recursive", &recursive,
13241327
N_("recurse into nested submodules")),
@@ -2887,7 +2890,7 @@ static int module_set_url(int argc, const char **argv, const char *prefix)
28872890
config_name = xstrfmt("submodule.%s.url", path);
28882891

28892892
config_set_in_gitmodules_file_gently(config_name, newurl);
2890-
sync_submodule(path, prefix, quiet ? OPT_QUIET : 0);
2893+
sync_submodule(path, prefix, NULL, quiet ? OPT_QUIET : 0);
28912894

28922895
free(config_name);
28932896

@@ -3392,8 +3395,7 @@ int cmd_submodule__helper(int argc, const char **argv, const char *prefix)
33923395
subcmd = argv[0];
33933396

33943397
if (strcmp(subcmd, "clone") && strcmp(subcmd, "update") &&
3395-
strcmp(subcmd, "status") && strcmp(subcmd, "sync") &&
3396-
get_super_prefix())
3398+
strcmp(subcmd, "status") && get_super_prefix())
33973399
/*
33983400
* xstrfmt() rather than "%s %s" to keep the translated
33993401
* string identical to git.c's.

0 commit comments

Comments
 (0)