git-submodule: forward exit code of git-submodule--helper more faithfully
[gitweb.git] / t / t7400-submodule-basic.sh
index 90d80d369c7e9c35f7f86b50e660b95cd279ccaa..fba2659a22a9f73e30b1f473ee83cf6c625f4f6a 100755 (executable)
@@ -11,6 +11,10 @@ subcommands of git submodule.
 
 . ./test-lib.sh
 
+test_expect_success 'submodule deinit works on empty repository' '
+       git submodule deinit --all
+'
+
 test_expect_success 'setup - initial commit' '
        >t &&
        git add t &&
@@ -348,7 +352,7 @@ test_expect_success 'sync should fail with unknown submodule' '
        test_failure_with_unknown_submodule sync
 '
 
-test_expect_success 'update should fail when path is used by a file' '
+test_expect_failure 'update should fail when path is used by a file' '
        echo hello >expect &&
 
        echo "hello" >init &&
@@ -357,7 +361,7 @@ test_expect_success 'update should fail when path is used by a file' '
        test_cmp expect init
 '
 
-test_expect_success 'update should fail when path is used by a nonempty directory' '
+test_expect_failure 'update should fail when path is used by a nonempty directory' '
        echo hello >expect &&
 
        rm -fr init &&
@@ -915,7 +919,8 @@ test_expect_success 'submodule deinit works on repository without submodules' '
                >file &&
                git add file &&
                git commit -m "repo should not be empty" &&
-               git submodule deinit .
+               git submodule deinit . &&
+               git submodule deinit --all
        )
 '
 
@@ -957,6 +962,19 @@ test_expect_success 'submodule deinit . deinits all initialized submodules' '
        rmdir init example2
 '
 
+test_expect_success 'submodule deinit --all deinits all initialized submodules' '
+       git submodule update --init &&
+       git config submodule.example.foo bar &&
+       git config submodule.example2.frotz nitfol &&
+       test_must_fail git submodule deinit &&
+       git submodule deinit --all >actual &&
+       test -z "$(git config --get-regexp "submodule\.example\.")" &&
+       test -z "$(git config --get-regexp "submodule\.example2\.")" &&
+       test_i18ngrep "Cleared directory .init" actual &&
+       test_i18ngrep "Cleared directory .example2" actual &&
+       rmdir init example2
+'
+
 test_expect_success 'submodule deinit deinits a submodule when its work tree is missing or empty' '
        git submodule update --init &&
        rm -rf init example2/* example2/.git &&
@@ -1023,6 +1041,10 @@ test_expect_success 'submodule deinit is silent when used on an uninitialized su
        test_i18ngrep ! "Submodule .example. (.*) unregistered for path .init" actual &&
        test_i18ngrep ! "Submodule .example2. (.*) unregistered for path .example2" actual &&
        test_i18ngrep "Cleared directory .init" actual &&
+       git submodule deinit --all >actual &&
+       test_i18ngrep ! "Submodule .example. (.*) unregistered for path .init" actual &&
+       test_i18ngrep ! "Submodule .example2. (.*) unregistered for path .example2" actual &&
+       test_i18ngrep "Cleared directory .init" actual &&
        rmdir init example2
 '