aboutsummaryrefslogtreecommitdiff
path: root/t/t7400-submodule-basic.sh
diff options
context:
space:
mode:
authorJens Lehmann <Jens.Lehmann@web.de>2013-04-01 21:02:00 +0200
committerJunio C Hamano <gitster@pobox.com>2013-04-01 13:05:54 -0700
commit7b294bf4948931a915cee2d5a692235e9b9c0e27 (patch)
treef3b480c3ac33ce25575dc87e3b86b29fc7b1cfb8 /t/t7400-submodule-basic.sh
parentcf419828064d4f22a2c3134e7b46a7719462b1dc (diff)
downloadgit-7b294bf4948931a915cee2d5a692235e9b9c0e27.tar.gz
git-7b294bf4948931a915cee2d5a692235e9b9c0e27.tar.xz
submodule deinit: clarify work tree removal message
The output of "git submodule deinit sub" of a populated submodule prints rm 'sub' as the first line unless used with the -f option. The "rm 'sub'" line is exactly the same output the user gets when using "git rm sub" (because that command is used with the --dry-run option under the hood to determine if the submodule is clean), which can easily lead to the false impression that the submodule would be permanently removed. Also users might be confused that the "rm 'submodule'" line won't show up when the -f option is used, as the test is skipped in this case. Silence the "rm 'submodule'" output by using the --quiet option for "git rm" and always print Cleared directory 'submodule' instead as the first output line. This line is printed as long as the directory exists, no matter if empty or not. Also extend the tests in t7400 to make sure the "Cleared directory" line is printed correctly. Reported-by: Phil Hord <phil.hord@gmail.com> Signed-off-by: Jens Lehmann <Jens.Lehmann@web.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't/t7400-submodule-basic.sh')
-rwxr-xr-xt/t7400-submodule-basic.sh21
1 files changed, 16 insertions, 5 deletions
diff --git a/t/t7400-submodule-basic.sh b/t/t7400-submodule-basic.sh
index 825c8b945..af0248d48 100755
--- a/t/t7400-submodule-basic.sh
+++ b/t/t7400-submodule-basic.sh
@@ -776,18 +776,22 @@ test_expect_success 'submodule deinit . deinits all initialized submodules' '
git config submodule.example.foo bar &&
git config submodule.example2.frotz nitfol &&
test_must_fail git submodule deinit &&
- git submodule deinit . &&
+ git submodule deinit . >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 &&
- git submodule deinit init example2 &&
+ git submodule deinit init example2 >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
'
@@ -797,8 +801,9 @@ test_expect_success 'submodule deinit fails when the submodule contains modifica
test_must_fail git submodule deinit init &&
test -n "$(git config --get-regexp "submodule\.example\.")" &&
test -f example2/.git &&
- git submodule deinit -f init &&
+ git submodule deinit -f init >actual &&
test -z "$(git config --get-regexp "submodule\.example\.")" &&
+ test_i18ngrep "Cleared directory .init" actual &&
rmdir init
'
@@ -808,8 +813,9 @@ test_expect_success 'submodule deinit fails when the submodule contains untracke
test_must_fail git submodule deinit init &&
test -n "$(git config --get-regexp "submodule\.example\.")" &&
test -f example2/.git &&
- git submodule deinit -f init &&
+ git submodule deinit -f init >actual &&
test -z "$(git config --get-regexp "submodule\.example\.")" &&
+ test_i18ngrep "Cleared directory .init" actual &&
rmdir init
'
@@ -822,8 +828,9 @@ test_expect_success 'submodule deinit fails when the submodule HEAD does not mat
test_must_fail git submodule deinit init &&
test -n "$(git config --get-regexp "submodule\.example\.")" &&
test -f example2/.git &&
- git submodule deinit -f init &&
+ git submodule deinit -f init >actual &&
test -z "$(git config --get-regexp "submodule\.example\.")" &&
+ test_i18ngrep "Cleared directory .init" actual &&
rmdir init
'
@@ -831,14 +838,18 @@ test_expect_success 'submodule deinit is silent when used on an uninitialized su
git submodule update --init &&
git submodule deinit init >actual &&
test_i18ngrep "Submodule .example. (.*) unregistered for path .init" actual &&
+ test_i18ngrep "Cleared directory .init" actual &&
git submodule deinit init >actual &&
test_i18ngrep ! "Submodule .example. (.*) unregistered for path .init" actual &&
+ test_i18ngrep "Cleared directory .init" actual &&
git submodule deinit . >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 &&
git submodule deinit . >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
'