aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdrian Ratiu <adrian.ratiu@collabora.com>2026-01-12 20:46:24 +0200
committerJunio C Hamano <gitster@pobox.com>2026-01-12 11:56:55 -0800
commit34206caaf7c5059ac8480587e31cfc40473002b4 (patch)
tree3e48a27cd48016bcda9f1562e3966076893d8d56
parent05a1cdb5255b2b438e66bdaa91b7b2ce75fbe71b (diff)
downloadgit-34206caaf7c5059ac8480587e31cfc40473002b4.tar.xz
builtin/submodule--helper: add gitdir command
This exposes the gitdir name computed by submodule_name_to_gitdir() internally, to make it easier for users and tests to interact with it. Next commit will add a gitdir configuration, so this helper can also be used to easily query that config or validate any gitdir path the user sets (submodule_name_to_git_dir now runs the validation logic, since our previous commit). Based-on-patch-by: Brandon Williams <bwilliams.eng@gmail.com> Signed-off-by: Adrian Ratiu <adrian.ratiu@collabora.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
-rw-r--r--builtin/submodule--helper.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/builtin/submodule--helper.c b/builtin/submodule--helper.c
index fc10ace5a8..7ea82d7fa2 100644
--- a/builtin/submodule--helper.c
+++ b/builtin/submodule--helper.c
@@ -1208,6 +1208,22 @@ static int module_summary(int argc, const char **argv, const char *prefix,
return ret;
}
+static int module_gitdir(int argc, const char **argv, const char *prefix UNUSED,
+ struct repository *repo)
+{
+ struct strbuf gitdir = STRBUF_INIT;
+
+ if (argc != 2)
+ usage(_("git submodule--helper gitdir <name>"));
+
+ submodule_name_to_gitdir(&gitdir, repo, argv[1]);
+
+ printf("%s\n", gitdir.buf);
+
+ strbuf_release(&gitdir);
+ return 0;
+}
+
struct sync_cb {
const char *prefix;
const char *super_prefix;
@@ -3587,6 +3603,7 @@ int cmd_submodule__helper(int argc,
NULL
};
struct option options[] = {
+ OPT_SUBCOMMAND("gitdir", &fn, module_gitdir),
OPT_SUBCOMMAND("clone", &fn, module_clone),
OPT_SUBCOMMAND("add", &fn, module_add),
OPT_SUBCOMMAND("update", &fn, module_update),