@@ -10,16 +10,21 @@ export GIT_TEST_FATAL_REGISTER_SUBMODULE_ODB
pwd=$(pwd)
-write_expected_sub () {
- NEW_HEAD=$1 &&
- SUPER_HEAD=$2 &&
+write_expected_sub_remote () {
+ REMOTE=$1 &&
+ NEW_HEAD=$2 &&
+ SUPER_HEAD=$3 &&
cat >"$pwd/expect.err.sub" <<-EOF
Fetching submodule submodule${SUPER_HEAD:+ at commit $SUPER_HEAD}
From $pwd/submodule
- OLD_HEAD..$NEW_HEAD sub -> origin/sub
+ OLD_HEAD..$NEW_HEAD sub -> $REMOTE/sub
EOF
}
+write_expected_sub () {
+ write_expected_sub_remote origin $1 $2
+}
+
write_expected_sub2 () {
NEW_HEAD=$1 &&
SUPER_HEAD=$2 &&
@@ -718,6 +723,47 @@ test_expect_success 'fetching submodules respects parallel settings' '
)
'
+test_expect_success 'fetching submodules works after remote rename' '
+ test_when_finished "git -C downstream/submodule remote rename upstream origin" &&
+ add_submodule_commits &&
+ add_superproject_commits &&
+ (
+ cd submodule &&
+ new_head=$(git rev-parse --short HEAD) &&
+ write_expected_sub_remote upstream $new_head
+ ) &&
+ (
+ cd downstream &&
+ git -C submodule remote rename origin upstream &&
+ git fetch --recurse-submodules >../actual.out 2>../actual.err
+ ) &&
+ test_must_be_empty actual.out &&
+ verify_fetch_result actual.err
+'
+
+test_expect_failure 'fetching submodules works after remote rename with multiple remotes' '
+ test_when_finished "git -C downstream/submodule remote rename upstream origin" &&
+ test_when_finished "git -C downstream/submodule remote rm other" &&
+ add_submodule_commits &&
+ add_superproject_commits &&
+ (
+ cd submodule &&
+ new_head=$(git rev-parse --short HEAD) &&
+ write_expected_sub_remote upstream $new_head
+ ) &&
+ (
+ cd downstream &&
+ (
+ cd submodule &&
+ git remote rename origin upstream &&
+ git remote add other http://other.invalid
+ ) &&
+ git fetch --recurse-submodules >../actual.out 2>../actual.err
+ ) &&
+ test_must_be_empty actual.out &&
+ verify_fetch_result actual.err
+'
+
test_expect_success 'fetching submodule into a broken repository' '
# Prepare src and src/sub nested in it
git init src &&