aboutsummaryrefslogtreecommitdiff
path: root/builtin
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2026-03-23 09:20:30 -0700
committerJunio C Hamano <gitster@pobox.com>2026-03-23 09:20:30 -0700
commit859132edb924423b70f37dccc9caf9945c5316da (patch)
tree8f967a4978501f124d4b5f176e84676ab8af263b /builtin
parentd10d0426566153e096c11072d38c9ba16604c2e6 (diff)
parent3b5fb32da836f5aead1cef319bc3e0a9b975ea35 (diff)
downloadgit-859132edb924423b70f37dccc9caf9945c5316da.tar.xz
Merge branch 'ng/submodule-default-remote'
Instead of hardcoded 'origin', use the configured default remote when fetching from submodules. * ng/submodule-default-remote: submodule: fetch missing objects from default remote
Diffstat (limited to 'builtin')
-rw-r--r--builtin/submodule--helper.c38
1 files changed, 38 insertions, 0 deletions
diff --git a/builtin/submodule--helper.c b/builtin/submodule--helper.c
index f3e132888f..ff8b05d1ba 100644
--- a/builtin/submodule--helper.c
+++ b/builtin/submodule--helper.c
@@ -113,6 +113,43 @@ static int get_default_remote_submodule(const char *module_path, char **default_
return 0;
}
+static int module_get_default_remote(int argc, const char **argv, const char *prefix,
+ struct repository *repo UNUSED)
+{
+ const char *path;
+ char *resolved_path = NULL;
+ char *default_remote = NULL;
+ int code;
+ struct option options[] = {
+ OPT_END()
+ };
+ const char *const usage[] = {
+ N_("git submodule--helper get-default-remote <path>"),
+ NULL
+ };
+
+ argc = parse_options(argc, argv, prefix, options, usage, 0);
+ if (argc != 1)
+ usage_with_options(usage, options);
+
+ path = argv[0];
+ if (prefix && *prefix && !is_absolute_path(path)) {
+ resolved_path = xstrfmt("%s%s", prefix, path);
+ path = resolved_path;
+ }
+
+ code = get_default_remote_submodule(path, &default_remote);
+ if (code) {
+ free(resolved_path);
+ return code;
+ }
+
+ printf("%s\n", default_remote);
+ free(default_remote);
+ free(resolved_path);
+ return 0;
+}
+
/* the result should be freed by the caller. */
static char *get_submodule_displaypath(const char *path, const char *prefix,
const char *super_prefix)
@@ -3789,6 +3826,7 @@ int cmd_submodule__helper(int argc,
OPT_SUBCOMMAND("set-url", &fn, module_set_url),
OPT_SUBCOMMAND("set-branch", &fn, module_set_branch),
OPT_SUBCOMMAND("create-branch", &fn, module_create_branch),
+ OPT_SUBCOMMAND("get-default-remote", &fn, module_get_default_remote),
OPT_END()
};
argc = parse_options(argc, argv, prefix, options, usage, 0);