Code

clean: require double -f options to nuke nested git repository and work tree
[git.git] / t / t7300-clean.sh
index 1636fac2a43e30a99674df98ff4544ee04612cc5..118c6ebb182b5cd4700e533d6a951b31529149af 100755 (executable)
@@ -373,11 +373,50 @@ test_expect_success 'removal failure' '
 
        mkdir foo &&
        touch foo/bar &&
-       exec <foo/bar &&
-       chmod 0 foo &&
-       test_must_fail git clean -f -d
+       (exec <foo/bar &&
+        chmod 0 foo &&
+        test_must_fail git clean -f -d)
 
 '
 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