mirror of
https://github.com/git/git
synced 2024-11-05 18:59:29 +00:00
submodule--helper: convert "status" to its own "--super-prefix"
As with a preceding commit to convert "absorbgitdirs", we can convert "submodule--helper status" 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:
parent
99a32d87f8
commit
04f1fab4a1
1 changed files with 8 additions and 7 deletions
|
@ -573,6 +573,7 @@ static int module_init(int argc, const char **argv, const char *prefix)
|
||||||
|
|
||||||
struct status_cb {
|
struct status_cb {
|
||||||
const char *prefix;
|
const char *prefix;
|
||||||
|
const char *super_prefix;
|
||||||
unsigned int flags;
|
unsigned int flags;
|
||||||
};
|
};
|
||||||
#define STATUS_CB_INIT { 0 }
|
#define STATUS_CB_INIT { 0 }
|
||||||
|
@ -611,7 +612,7 @@ static int handle_submodule_head_ref(const char *refname UNUSED,
|
||||||
|
|
||||||
static void status_submodule(const char *path, const struct object_id *ce_oid,
|
static void status_submodule(const char *path, const struct object_id *ce_oid,
|
||||||
unsigned int ce_flags, const char *prefix,
|
unsigned int ce_flags, const char *prefix,
|
||||||
unsigned int flags)
|
const char *super_prefix, unsigned int flags)
|
||||||
{
|
{
|
||||||
char *displaypath;
|
char *displaypath;
|
||||||
struct strvec diff_files_args = STRVEC_INIT;
|
struct strvec diff_files_args = STRVEC_INIT;
|
||||||
|
@ -627,8 +628,7 @@ static void status_submodule(const char *path, const struct object_id *ce_oid,
|
||||||
die(_("no submodule mapping found in .gitmodules for path '%s'"),
|
die(_("no submodule mapping found in .gitmodules for path '%s'"),
|
||||||
path);
|
path);
|
||||||
|
|
||||||
displaypath = get_submodule_displaypath(path, prefix,
|
displaypath = get_submodule_displaypath(path, prefix, super_prefix);
|
||||||
get_super_prefix());
|
|
||||||
|
|
||||||
if ((CE_STAGEMASK & ce_flags) >> CE_STAGESHIFT) {
|
if ((CE_STAGEMASK & ce_flags) >> CE_STAGESHIFT) {
|
||||||
print_status(flags, 'U', path, null_oid(), displaypath);
|
print_status(flags, 'U', path, null_oid(), displaypath);
|
||||||
|
@ -686,10 +686,10 @@ static void status_submodule(const char *path, const struct object_id *ce_oid,
|
||||||
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", "status",
|
strvec_pushl(&cpr.args, "submodule--helper", "status",
|
||||||
"--recursive", NULL);
|
"--recursive", NULL);
|
||||||
|
strvec_push(&cpr.args, "--super-prefix");
|
||||||
|
strvec_pushf(&cpr.args, "%s/", displaypath);
|
||||||
|
|
||||||
if (flags & OPT_CACHED)
|
if (flags & OPT_CACHED)
|
||||||
strvec_push(&cpr.args, "--cached");
|
strvec_push(&cpr.args, "--cached");
|
||||||
|
@ -713,7 +713,7 @@ static void status_submodule_cb(const struct cache_entry *list_item,
|
||||||
struct status_cb *info = cb_data;
|
struct status_cb *info = cb_data;
|
||||||
|
|
||||||
status_submodule(list_item->name, &list_item->oid, list_item->ce_flags,
|
status_submodule(list_item->name, &list_item->oid, list_item->ce_flags,
|
||||||
info->prefix, info->flags);
|
info->prefix, info->super_prefix, info->flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int module_status(int argc, const char **argv, const char *prefix)
|
static int module_status(int argc, const char **argv, const char *prefix)
|
||||||
|
@ -723,6 +723,7 @@ static int module_status(int argc, const char **argv, const char *prefix)
|
||||||
struct module_list list = MODULE_LIST_INIT;
|
struct module_list list = MODULE_LIST_INIT;
|
||||||
int quiet = 0;
|
int quiet = 0;
|
||||||
struct option module_status_options[] = {
|
struct option module_status_options[] = {
|
||||||
|
OPT__SUPER_PREFIX(&info.super_prefix),
|
||||||
OPT__QUIET(&quiet, N_("suppress submodule status output")),
|
OPT__QUIET(&quiet, N_("suppress submodule status output")),
|
||||||
OPT_BIT(0, "cached", &info.flags, N_("use commit stored in the index instead of the one stored in the submodule HEAD"), OPT_CACHED),
|
OPT_BIT(0, "cached", &info.flags, N_("use commit stored in the index instead of the one stored in the submodule HEAD"), OPT_CACHED),
|
||||||
OPT_BIT(0, "recursive", &info.flags, N_("recurse into nested submodules"), OPT_RECURSIVE),
|
OPT_BIT(0, "recursive", &info.flags, N_("recurse into nested submodules"), OPT_RECURSIVE),
|
||||||
|
@ -3395,7 +3396,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") && 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.
|
||||||
|
|
Loading…
Reference in a new issue