diff options
author | Junio C Hamano <gitster@pobox.com> | 2009-06-30 15:33:45 -0700 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2009-07-29 12:22:30 -0700 |
commit | a0f4afbe87ddda7902e36350d163dea146166550 (patch) | |
tree | 9c90142f461b86ef045d672793b95f135be1970f /t/t7300-clean.sh | |
parent | 0a53e9ddeaddad63ad106860237bbf53411d11a7 (diff) | |
download | git-a0f4afbe87ddda7902e36350d163dea146166550.tar.gz |
clean: require double -f options to nuke nested git repository and work tree
When you have an embedded git work tree in your work tree (be it
an orphaned submodule, or an independent checkout of an unrelated
project), "git clean -d -f" blindly descended into it and removed
everything. This is rarely what the user wants.
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't/t7300-clean.sh')
-rwxr-xr-x | t/t7300-clean.sh | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/t/t7300-clean.sh b/t/t7300-clean.sh index 929d5d4d3b..118c6ebb18 100755 --- a/t/t7300-clean.sh +++ b/t/t7300-clean.sh @@ -380,4 +380,43 @@ test_expect_success 'removal failure' ' ' chmod 755 foo +test_expect_success 'nested git work tree' ' + rm -fr foo bar && + mkdir foo bar && + ( + cd foo && + git init && + >hello.world + git add . && + git commit -a -m nested + ) && + ( + cd bar && + >goodbye.people + ) && + git clean -f -d && + test -f foo/.git/index && + test -f foo/hello.world && + ! test -d bar +' + +test_expect_success 'force removal of nested git work tree' ' + rm -fr foo bar && + mkdir foo bar && + ( + cd foo && + git init && + >hello.world + git add . && + git commit -a -m nested + ) && + ( + cd bar && + >goodbye.people + ) && + git clean -f -f -d && + ! test -d foo && + ! test -d bar +' + test_done |