aboutsummaryrefslogtreecommitdiff
path: root/t/t5572-pull-submodule.sh
diff options
context:
space:
mode:
authorNasser Grainawi <nasser.grainawi@oss.qualcomm.com>2026-03-03 15:40:44 -0800
committerJunio C Hamano <gitster@pobox.com>2026-03-03 18:00:43 -0800
commit3b5fb32da836f5aead1cef319bc3e0a9b975ea35 (patch)
tree6b21ac32451adcd65ae382f4be021a52c08bc217 /t/t5572-pull-submodule.sh
parent1faf5b085a171f9ba9a6d7a446e0de16acccb1dc (diff)
downloadgit-3b5fb32da836f5aead1cef319bc3e0a9b975ea35.tar.xz
submodule: fetch missing objects from default remote
When be76c21282 (fetch: ensure submodule objects fetched, 2018-12-06) added support for fetching a missing submodule object by id, it hardcoded the remote name as "origin" and deferred anything more complicated for a later patch. Implement the NEEDSWORK item to remove the hardcoded assumption by adding and using a submodule helper subcmd 'get-default-remote'. Fixing this lets 'git fetch --recurse-submodules' succeed when the fetched commit(s) in the superproject trigger a submodule fetch, and that submodule's default remote name is not "origin". Add non-"origin" remote tests to t5526-fetch-submodules.sh and t5572-pull-submodule.sh demonstrating this works as expected and add dedicated tests for get-default-remote. Signed-off-by: Nasser Grainawi <nasser.grainawi@oss.qualcomm.com> Reviewed-by: Jacob Keller <jacob.keller@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't/t5572-pull-submodule.sh')
-rwxr-xr-xt/t5572-pull-submodule.sh21
1 files changed, 20 insertions, 1 deletions
diff --git a/t/t5572-pull-submodule.sh b/t/t5572-pull-submodule.sh
index 45f384dd32..42d14328b6 100755
--- a/t/t5572-pull-submodule.sh
+++ b/t/t5572-pull-submodule.sh
@@ -257,7 +257,26 @@ test_expect_success 'fetch submodule remote of different name from superproject'
git -C a-submodule reset --hard HEAD^^ &&
git -C child pull --no-recurse-submodules &&
- git -C child submodule update
+ git -C child submodule update &&
+ test_path_is_file child/a-submodule/moreecho.t
+'
+
+test_expect_success 'fetch non-origin submodule remote named different from superproject' '
+ git -C child/a-submodule remote rename origin o2 &&
+
+ # Create commit that is unreachable from current master branch
+ # newmain is already reset in the previous test
+ test_commit -C a-submodule echo_o2 &&
+ test_commit -C a-submodule moreecho_o2 &&
+ subc=$(git -C a-submodule rev-parse --short HEAD) &&
+
+ git -C parent/a-submodule fetch &&
+ git -C parent/a-submodule checkout "$subc" &&
+ git -C parent commit -m "update submodule o2" a-submodule &&
+ git -C a-submodule reset --hard HEAD^^ &&
+
+ git -C child pull --recurse-submodules &&
+ test_path_is_file child/a-submodule/moreecho_o2.t
'
test_done