]> git.ipfire.org Git - thirdparty/git.git/blobdiff - t/t7411-submodule-config.sh
submodule: support reading .gitmodules when it's not in the working tree
[thirdparty/git.git] / t / t7411-submodule-config.sh
index 45953f93007257c9b1d9799b51d555941ecad082..2cfabb18bc5b30896aaf81b34394d3a12f4f05d8 100755 (executable)
@@ -134,7 +134,7 @@ test_expect_success 'error in history in fetchrecursesubmodule lets continue' '
        )
 '
 
-test_expect_success 'reading submodules config with "submodule--helper config"' '
+test_expect_success 'reading submodules config from the working tree with "submodule--helper config"' '
        (cd super &&
                echo "../submodule" >expect &&
                git submodule--helper config submodule.submodule.url >actual &&
@@ -192,4 +192,28 @@ test_expect_success 'non-writeable .gitmodules when it is in the current branch
        )
 '
 
+test_expect_success 'reading submodules config from the index when .gitmodules is not in the working tree' '
+       ORIG=$(git -C super rev-parse HEAD) &&
+       test_when_finished "git -C super reset --hard $ORIG" &&
+       (cd super &&
+               git submodule--helper config submodule.submodule.url "staged_url" &&
+               git add .gitmodules &&
+               rm -f .gitmodules &&
+               echo "staged_url" >expect &&
+               git submodule--helper config submodule.submodule.url >actual &&
+               test_cmp expect actual
+       )
+'
+
+test_expect_success 'reading submodules config from the current branch when .gitmodules is not in the index' '
+       ORIG=$(git -C super rev-parse HEAD) &&
+       test_when_finished "git -C super reset --hard $ORIG" &&
+       (cd super &&
+               git rm .gitmodules &&
+               echo "../submodule" >expect &&
+               git submodule--helper config submodule.submodule.url >actual &&
+               test_cmp expect actual
+       )
+'
+
 test_done