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 <avarab@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:

committed by
Junio C Hamano

parent
677c981260
commit
99a32d87f8
@ -1208,12 +1208,13 @@ static int module_summary(int argc, const char **argv, const char *prefix)
|
|||||||
|
|
||||||
struct sync_cb {
|
struct sync_cb {
|
||||||
const char *prefix;
|
const char *prefix;
|
||||||
|
const char *super_prefix;
|
||||||
unsigned int flags;
|
unsigned int flags;
|
||||||
};
|
};
|
||||||
#define SYNC_CB_INIT { 0 }
|
#define SYNC_CB_INIT { 0 }
|
||||||
|
|
||||||
static void sync_submodule(const char *path, const char *prefix,
|
static void sync_submodule(const char *path, const char *prefix,
|
||||||
unsigned int flags)
|
const char *super_prefix, unsigned int flags)
|
||||||
{
|
{
|
||||||
const struct submodule *sub;
|
const struct submodule *sub;
|
||||||
char *remote_key = NULL;
|
char *remote_key = NULL;
|
||||||
@ -1244,8 +1245,7 @@ static void sync_submodule(const char *path, const char *prefix,
|
|||||||
super_config_url = xstrdup("");
|
super_config_url = xstrdup("");
|
||||||
}
|
}
|
||||||
|
|
||||||
displaypath = get_submodule_displaypath(path, prefix,
|
displaypath = get_submodule_displaypath(path, prefix, super_prefix);
|
||||||
get_super_prefix());
|
|
||||||
|
|
||||||
if (!(flags & OPT_QUIET))
|
if (!(flags & OPT_QUIET))
|
||||||
printf(_("Synchronizing submodule url for '%s'\n"),
|
printf(_("Synchronizing submodule url for '%s'\n"),
|
||||||
@ -1282,10 +1282,11 @@ static void sync_submodule(const char *path, const char *prefix,
|
|||||||
cpr.dir = path;
|
cpr.dir = path;
|
||||||
prepare_submodule_repo_env(&cpr.env);
|
prepare_submodule_repo_env(&cpr.env);
|
||||||
|
|
||||||
strvec_push(&cpr.args, "--super-prefix");
|
|
||||||
strvec_pushf(&cpr.args, "%s/", displaypath);
|
|
||||||
strvec_pushl(&cpr.args, "submodule--helper", "sync",
|
strvec_pushl(&cpr.args, "submodule--helper", "sync",
|
||||||
"--recursive", NULL);
|
"--recursive", NULL);
|
||||||
|
strvec_push(&cpr.args, "--super-prefix");
|
||||||
|
strvec_pushf(&cpr.args, "%s/", displaypath);
|
||||||
|
|
||||||
|
|
||||||
if (flags & OPT_QUIET)
|
if (flags & OPT_QUIET)
|
||||||
strvec_push(&cpr.args, "--quiet");
|
strvec_push(&cpr.args, "--quiet");
|
||||||
@ -1308,7 +1309,8 @@ static void sync_submodule_cb(const struct cache_entry *list_item, void *cb_data
|
|||||||
{
|
{
|
||||||
struct sync_cb *info = cb_data;
|
struct sync_cb *info = cb_data;
|
||||||
|
|
||||||
sync_submodule(list_item->name, info->prefix, info->flags);
|
sync_submodule(list_item->name, info->prefix, info->super_prefix,
|
||||||
|
info->flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int module_sync(int argc, const char **argv, const char *prefix)
|
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)
|
|||||||
int quiet = 0;
|
int quiet = 0;
|
||||||
int recursive = 0;
|
int recursive = 0;
|
||||||
struct option module_sync_options[] = {
|
struct option module_sync_options[] = {
|
||||||
|
OPT__SUPER_PREFIX(&info.super_prefix),
|
||||||
OPT__QUIET(&quiet, N_("suppress output of synchronizing submodule url")),
|
OPT__QUIET(&quiet, N_("suppress output of synchronizing submodule url")),
|
||||||
OPT_BOOL(0, "recursive", &recursive,
|
OPT_BOOL(0, "recursive", &recursive,
|
||||||
N_("recurse into nested submodules")),
|
N_("recurse into nested submodules")),
|
||||||
@ -2887,7 +2890,7 @@ static int module_set_url(int argc, const char **argv, const char *prefix)
|
|||||||
config_name = xstrfmt("submodule.%s.url", path);
|
config_name = xstrfmt("submodule.%s.url", path);
|
||||||
|
|
||||||
config_set_in_gitmodules_file_gently(config_name, newurl);
|
config_set_in_gitmodules_file_gently(config_name, newurl);
|
||||||
sync_submodule(path, prefix, quiet ? OPT_QUIET : 0);
|
sync_submodule(path, prefix, NULL, quiet ? OPT_QUIET : 0);
|
||||||
|
|
||||||
free(config_name);
|
free(config_name);
|
||||||
|
|
||||||
@ -3392,8 +3395,7 @@ int cmd_submodule__helper(int argc, const char **argv, const char *prefix)
|
|||||||
subcmd = argv[0];
|
subcmd = argv[0];
|
||||||
|
|
||||||
if (strcmp(subcmd, "clone") && strcmp(subcmd, "update") &&
|
if (strcmp(subcmd, "clone") && strcmp(subcmd, "update") &&
|
||||||
strcmp(subcmd, "status") && strcmp(subcmd, "sync") &&
|
strcmp(subcmd, "status") && get_super_prefix())
|
||||||
get_super_prefix())
|
|
||||||
/*
|
/*
|
||||||
* xstrfmt() rather than "%s %s" to keep the translated
|
* xstrfmt() rather than "%s %s" to keep the translated
|
||||||
* string identical to git.c's.
|
* string identical to git.c's.
|
||||||
|
Reference in New Issue
Block a user