X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=t%2Ft7406-submodule-update.sh;h=5b97222c48a15dff018cb814ca14c59ed0ee91a2;hb=5febbda4e7afb4f26bed9d2dc5f9c4ceca86d2b8;hp=c679f36a4daeab3f114c9cf0c84c93549d28c680;hpb=7857e3246fef2fdfa3c0fc645cd3d72ff3e6572b;p=git.git diff --git a/t/t7406-submodule-update.sh b/t/t7406-submodule-update.sh index c679f36a4..5b97222c4 100755 --- a/t/t7406-submodule-update.sh +++ b/t/t7406-submodule-update.sh @@ -30,6 +30,7 @@ test_expect_success 'setup a submodule tree' ' git clone super submodule && git clone super rebasing && git clone super merging && + git clone super none && (cd super && git submodule add ../submodule submodule && test_tick && @@ -58,6 +59,11 @@ test_expect_success 'setup a submodule tree' ' test_tick && git commit -m "rebasing" ) + (cd super && + git submodule add ../none none && + test_tick && + git commit -m "none" + ) ' test_expect_success 'submodule update detaching the HEAD ' ' @@ -298,6 +304,62 @@ test_expect_success 'submodule update ignores update=rebase config for new submo ) ' +test_expect_success 'submodule init picks up update=none' ' + (cd super && + git config -f .gitmodules submodule.none.update none && + git submodule init none && + test "none" = "$(git config submodule.none.update)" + ) +' + +test_expect_success 'submodule update - update=none in .git/config' ' + (cd super && + git config submodule.submodule.update none && + (cd submodule && + git checkout master && + compare_head + ) && + git diff --raw | grep " submodule" && + git submodule update && + git diff --raw | grep " submodule" && + (cd submodule && + compare_head + ) && + git config --unset submodule.submodule.update && + git submodule update submodule + ) +' + +test_expect_success 'submodule update - update=none in .git/config but --checkout given' ' + (cd super && + git config submodule.submodule.update none && + (cd submodule && + git checkout master && + compare_head + ) && + git diff --raw | grep " submodule" && + git submodule update --checkout && + test_must_fail git diff --raw \| grep " submodule" && + (cd submodule && + test_must_fail compare_head + ) && + git config --unset submodule.submodule.update + ) +' + +test_expect_success 'submodule update --init skips submodule with update=none' ' + (cd super && + git add .gitmodules && + git commit -m ".gitmodules" + ) && + git clone super cloned && + (cd cloned && + git submodule update --init && + test -e submodule/.git && + test_must_fail test -e none/.git + ) +' + test_expect_success 'submodule update continues after checkout error' ' (cd super && git reset --hard HEAD && @@ -408,6 +470,7 @@ test_expect_success 'submodule update exit immediately in case of merge conflict test_cmp expect actual ) ' + test_expect_success 'submodule update exit immediately after recursive rebase error' ' (cd super && git checkout master && @@ -442,4 +505,118 @@ test_expect_success 'submodule update exit immediately after recursive rebase er test_cmp expect actual ) ' + +test_expect_success 'add different submodules to the same path' ' + (cd super && + git submodule add ../submodule s1 && + test_must_fail git submodule add ../merging s1 + ) +' + +test_expect_success 'submodule add places git-dir in superprojects git-dir' ' + (cd super && + mkdir deeper && + git submodule add ../submodule deeper/submodule && + (cd deeper/submodule && + git log > ../../expected + ) && + (cd .git/modules/deeper/submodule && + git log > ../../../../actual + ) && + test_cmp actual expected + ) +' + +test_expect_success 'submodule update places git-dir in superprojects git-dir' ' + (cd super && + git commit -m "added submodule" + ) && + git clone super super2 && + (cd super2 && + git submodule init deeper/submodule && + git submodule update && + (cd deeper/submodule && + git log > ../../expected + ) && + (cd .git/modules/deeper/submodule && + git log > ../../../../actual + ) && + test_cmp actual expected + ) +' + +test_expect_success 'submodule add places git-dir in superprojects git-dir recursive' ' + (cd super2 && + (cd deeper/submodule && + git submodule add ../submodule subsubmodule && + (cd subsubmodule && + git log > ../../../expected + ) && + git commit -m "added subsubmodule" && + git push + ) && + (cd .git/modules/deeper/submodule/modules/subsubmodule && + git log > ../../../../../actual + ) && + git add deeper/submodule && + git commit -m "update submodule" && + git push && + test_cmp actual expected + ) +' + +test_expect_success 'submodule update places git-dir in superprojects git-dir recursive' ' + mkdir super_update_r && + (cd super_update_r && + git init --bare + ) && + mkdir subsuper_update_r && + (cd subsuper_update_r && + git init --bare + ) && + mkdir subsubsuper_update_r && + (cd subsubsuper_update_r && + git init --bare + ) && + git clone subsubsuper_update_r subsubsuper_update_r2 && + (cd subsubsuper_update_r2 && + test_commit "update_subsubsuper" file && + git push origin master + ) && + git clone subsuper_update_r subsuper_update_r2 && + (cd subsuper_update_r2 && + test_commit "update_subsuper" file && + git submodule add ../subsubsuper_update_r subsubmodule && + git commit -am "subsubmodule" && + git push origin master + ) && + git clone super_update_r super_update_r2 && + (cd super_update_r2 && + test_commit "update_super" file && + git submodule add ../subsuper_update_r submodule && + git commit -am "submodule" && + git push origin master + ) && + rm -rf super_update_r2 && + git clone super_update_r super_update_r2 && + (cd super_update_r2 && + git submodule update --init --recursive && + (cd submodule/subsubmodule && + git log > ../../expected + ) && + (cd .git/modules/submodule/modules/subsubmodule + git log > ../../../../../actual + ) + test_cmp actual expected + ) +' + +test_expect_success 'submodule add properly re-creates deeper level submodules' ' + (cd super && + git reset --hard master && + rm -rf deeper/ && + git submodule add ../submodule deeper/submodule + ) +' + test_done