test prerequisites: eradicate NOT_FOO
[gitweb.git] / t / t7300-clean.sh
index ccfb54de7ad9473221390d019b109bcb010a2c76..04118ad75be8462fa2ee1e5e870feb0a44ac0482 100755 (executable)
@@ -298,6 +298,23 @@ test_expect_success 'git clean -d -x' '
 
 '
 
+test_expect_success 'git clean -d -x with ignored tracked directory' '
+
+       mkdir -p build docs &&
+       touch a.out src/part3.c docs/manual.txt obj.o build/lib.so &&
+       git clean -d -x -e src &&
+       test -f Makefile &&
+       test -f README &&
+       test -f src/part1.c &&
+       test -f src/part2.c &&
+       test ! -f a.out &&
+       test -f src/part3.c &&
+       test ! -d docs &&
+       test ! -f obj.o &&
+       test ! -d build
+
+'
+
 test_expect_success 'git clean -X' '
 
        mkdir -p build docs &&
@@ -332,6 +349,23 @@ test_expect_success 'git clean -d -X' '
 
 '
 
+test_expect_success 'git clean -d -X with ignored tracked directory' '
+
+       mkdir -p build docs &&
+       touch a.out src/part3.c docs/manual.txt obj.o build/lib.so &&
+       git clean -d -X -e src &&
+       test -f Makefile &&
+       test -f README &&
+       test -f src/part1.c &&
+       test -f src/part2.c &&
+       test -f a.out &&
+       test ! -f src/part3.c &&
+       test -f docs/manual.txt &&
+       test ! -f obj.o &&
+       test ! -d build
+
+'
+
 test_expect_success 'clean.requireForce defaults to true' '
 
        git config --unset clean.requireForce &&
@@ -392,10 +426,10 @@ test_expect_success SANITY 'removal failure' '
 
        mkdir foo &&
        touch foo/bar &&
+       test_when_finished "chmod 755 foo" &&
        (exec <foo/bar &&
         chmod 0 foo &&
-        test_must_fail git clean -f -d &&
-        chmod 755 foo)
+        test_must_fail git clean -f -d)
 '
 
 test_expect_success 'nested git work tree' '
@@ -477,4 +511,20 @@ test_expect_success SANITY 'git clean -d with an unreadable empty directory' '
        ! test -d foo
 '
 
+test_expect_success 'git clean -d respects pathspecs (dir is prefix of pathspec)' '
+       mkdir -p foo &&
+       mkdir -p foobar &&
+       git clean -df foobar &&
+       test_path_is_dir foo &&
+       test_path_is_missing foobar
+'
+
+test_expect_success 'git clean -d respects pathspecs (pathspec is prefix of dir)' '
+       mkdir -p foo &&
+       mkdir -p foobar &&
+       git clean -df foo &&
+       test_path_is_missing foo &&
+       test_path_is_dir foobar
+'
+
 test_done