aboutsummaryrefslogtreecommitdiff
path: root/submodule.c
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 /submodule.c
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 'submodule.c')
-rw-r--r--submodule.c17
1 files changed, 15 insertions, 2 deletions
diff --git a/submodule.c b/submodule.c
index cd879a5cfe..e20537ba8d 100644
--- a/submodule.c
+++ b/submodule.c
@@ -1708,6 +1708,8 @@ static int get_next_submodule(struct child_process *cp, struct strbuf *err,
if (spf->oid_fetch_tasks_nr) {
struct fetch_task *task =
spf->oid_fetch_tasks[spf->oid_fetch_tasks_nr - 1];
+ struct child_process cp_remote = CHILD_PROCESS_INIT;
+ struct strbuf remote_name = STRBUF_INIT;
spf->oid_fetch_tasks_nr--;
child_process_init(cp);
@@ -1721,8 +1723,19 @@ static int get_next_submodule(struct child_process *cp, struct strbuf *err,
strvec_pushf(&cp->args, "--submodule-prefix=%s%s/",
spf->prefix, task->sub->path);
- /* NEEDSWORK: have get_default_remote from submodule--helper */
- strvec_push(&cp->args, "origin");
+ cp_remote.git_cmd = 1;
+ strvec_pushl(&cp_remote.args, "submodule--helper",
+ "get-default-remote", task->sub->path, NULL);
+
+ if (!capture_command(&cp_remote, &remote_name, 0)) {
+ strbuf_trim_trailing_newline(&remote_name);
+ strvec_push(&cp->args, remote_name.buf);
+ } else {
+ /* Fallback to "origin" if the helper fails */
+ strvec_push(&cp->args, "origin");
+ }
+ strbuf_release(&remote_name);
+
oid_array_for_each_unique(task->commits,
append_oid_to_argv, &cp->args);