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>

Ævar Arnfjörð Bjarmason committed Dec 20, 2022 at 13:39 UTC 04f1fab4a13ad9eb2757809765720508abeb38da
1 file changed +8 -7
builtin/submodule--helper.c
+8 -7
@@ -573,6 +573,7 @@ cleanup:
573
574 struct status_cb {
575 const char *prefix;
576 + const char *super_prefix;
577 unsigned int flags;
578 };
579 #define STATUS_CB_INIT { 0 }
@@ -611,7 +612,7 @@ static int handle_submodule_head_ref(const char *refname UNUSED,
612
613 static void status_submodule(const char *path, const struct object_id *ce_oid,
614 unsigned int ce_flags, const char *prefix,
614 - unsigned int flags)
615 + const char *super_prefix, unsigned int flags)
616 {
617 char *displaypath;
618 struct strvec diff_files_args = STRVEC_INIT;
@@ -627,8 +628,7 @@ static void status_submodule(const char *path, const struct object_id *ce_oid,
628 die(_("no submodule mapping found in .gitmodules for path '%s'"),
629 path);
630
630 - displaypath = get_submodule_displaypath(path, prefix,
631 - get_super_prefix());
631 + displaypath = get_submodule_displaypath(path, prefix, super_prefix);
632
633 if ((CE_STAGEMASK & ce_flags) >> CE_STAGESHIFT) {
634 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,
686 cpr.dir = path;
687 prepare_submodule_repo_env(&cpr.env);
688
689 - strvec_push(&cpr.args, "--super-prefix");
690 - strvec_pushf(&cpr.args, "%s/", displaypath);
689 strvec_pushl(&cpr.args, "submodule--helper", "status",
690 "--recursive", NULL);
691 + strvec_push(&cpr.args, "--super-prefix");
692 + strvec_pushf(&cpr.args, "%s/", displaypath);
693
694 if (flags & OPT_CACHED)
695 strvec_push(&cpr.args, "--cached");
@@ -713,7 +713,7 @@ static void status_submodule_cb(const struct cache_entry *list_item,
713 struct status_cb *info = cb_data;
714
715 status_submodule(list_item->name, &list_item->oid, list_item->ce_flags,
716 - info->prefix, info->flags);
716 + info->prefix, info->super_prefix, info->flags);
717 }
718
719 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)
723 struct module_list list = MODULE_LIST_INIT;
724 int quiet = 0;
725 struct option module_status_options[] = {
726 + OPT__SUPER_PREFIX(&info.super_prefix),
727 OPT__QUIET(&quiet, N_("suppress submodule status output")),
728 OPT_BIT(0, "cached", &info.flags, N_("use commit stored in the index instead of the one stored in the submodule HEAD"), OPT_CACHED),
729 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)
3396 subcmd = argv[0];
3397
3398 if (strcmp(subcmd, "clone") && strcmp(subcmd, "update") &&
3398 - strcmp(subcmd, "status") && get_super_prefix())
3399 + get_super_prefix())
3400 /*
3401 * xstrfmt() rather than "%s %s" to keep the translated
3402 * string identical to git.c's.