git-submodule: forward exit code of git-submodule--helper more faithfully
[gitweb.git] / t / t7400-submodule-basic.sh
index 75db02389885d74942e0b20da55796130c0d2c62..fba2659a22a9f73e30b1f473ee83cf6c625f4f6a 100755 (executable)
@@ -22,6 +22,22 @@ test_expect_success 'setup - initial commit' '
        git branch initial
 '
 
+test_expect_success 'submodule init aborts on missing .gitmodules file' '
+       test_when_finished "git update-index --remove sub" &&
+       git update-index --add --cacheinfo 160000,$(git rev-parse HEAD),sub &&
+       # missing the .gitmodules file here
+       test_must_fail git submodule init 2>actual &&
+       test_i18ngrep "No url found for submodule path" actual
+'
+
+test_expect_success 'submodule update aborts on missing .gitmodules file' '
+       test_when_finished "git update-index --remove sub" &&
+       git update-index --add --cacheinfo 160000,$(git rev-parse HEAD),sub &&
+       # missing the .gitmodules file here
+       git submodule update sub 2>actual &&
+       test_i18ngrep "Submodule path .sub. not initialized" actual
+'
+
 test_expect_success 'configuration parsing' '
        test_when_finished "rm -f .gitmodules" &&
        cat >.gitmodules <<-\EOF &&
@@ -336,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 &&
@@ -345,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 &&
@@ -466,7 +482,7 @@ test_expect_success 'update --init' '
        git config --remove-section submodule.example &&
        test_must_fail git config submodule.example.url &&
 
-       git submodule update init > update.out &&
+       git submodule update init 2> update.out &&
        cat update.out &&
        test_i18ngrep "not initialized" update.out &&
        test_must_fail git rev-parse --resolve-git-dir init/.git &&
@@ -484,7 +500,7 @@ test_expect_success 'update --init from subdirectory' '
        mkdir -p sub &&
        (
                cd sub &&
-               git submodule update ../init >update.out &&
+               git submodule update ../init 2>update.out &&
                cat update.out &&
                test_i18ngrep "not initialized" update.out &&
                test_must_fail git rev-parse --resolve-git-dir ../init/.git &&
@@ -902,7 +918,7 @@ test_expect_success 'submodule deinit works on repository without submodules' '
                git init &&
                >file &&
                git add file &&
-               git commit -m "repo should not be empty"
+               git commit -m "repo should not be empty" &&
                git submodule deinit . &&
                git submodule deinit --all
        )