diff options
author | Jens Lehmann <Jens.Lehmann@web.de> | 2012-11-22 23:32:26 +0100 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2012-11-23 18:35:15 -0800 |
commit | 53e4c5dcab33d2718476867b865da9679bd2c24a (patch) | |
tree | c1de0d72c32d656a2de096fa36e2ab1056897ca9 /t | |
parent | docs: move submodule section (diff) | |
download | tgif-53e4c5dcab33d2718476867b865da9679bd2c24a.tar.xz |
Teach rm to remove submodules when given with a trailing '/'
Doing a "git rm submod/" on a submodule results in an error:
fatal: pathspec 'submod/' did not match any files
This is really inconvenient as e.g. using TAB completion in a shell on a
submodule automatically adds the trailing '/' when it completes the path
of the submodule directory. The user has then to remove the '/' herself to
make a "git rm" succeed. Doing a "git rm -r somedir/" is working fine, so
there is no reason why that shouldn't work for submodules too.
Teach git rm to not error out when a '/' is appended to the path of a
submodule. Achieve this by chopping off trailing slashes from the path
names given if they represent directories. Add tests to make sure that
logic only applies to directories and not to files.
Signed-off-by: Jens Lehmann <Jens.Lehmann@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't')
-rwxr-xr-x | t/t3600-rm.sh | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/t/t3600-rm.sh b/t/t3600-rm.sh index 97254e8d33..06f63848ea 100755 --- a/t/t3600-rm.sh +++ b/t/t3600-rm.sh @@ -302,6 +302,23 @@ test_expect_success 'rm removes work tree of unmodified submodules' ' test_cmp expect actual ' +test_expect_success 'rm removes a submodule with a trailing /' ' + git reset --hard && + git submodule update && + git rm submod/ && + test ! -d submod && + git status -s -uno --ignore-submodules=none > actual && + test_cmp expect actual +' + +test_expect_success 'rm fails when given a file with a trailing /' ' + test_must_fail git rm empty/ +' + +test_expect_success 'rm succeeds when given a directory with a trailing /' ' + git rm -r frotz/ +' + test_expect_success 'rm of a populated submodule with different HEAD fails unless forced' ' git reset --hard && git submodule update && |