Code

Merge branch 'maint'
[git.git] / t / t7300-clean.sh
index 25d3102dedd31f43bfaabd1ae05fdebbc51863f8..afccfc9973ba864167387b1e1caf6fe8b12f68f9 100755 (executable)
@@ -89,6 +89,58 @@ test_expect_success 'git-clean with prefix' '
        test -f build/lib.so
 
 '
+
+test_expect_success 'git-clean with relative prefix' '
+
+       mkdir -p build docs &&
+       touch a.out src/part3.c docs/manual.txt obj.o build/lib.so &&
+       would_clean=$(
+               cd docs &&
+               git clean -n ../src |
+               sed -n -e "s|^Would remove ||p"
+       ) &&
+       test "$would_clean" = ../src/part3.c || {
+               echo "OOps <$would_clean>"
+               false
+       }
+'
+
+test_expect_success 'git-clean with absolute path' '
+
+       mkdir -p build docs &&
+       touch a.out src/part3.c docs/manual.txt obj.o build/lib.so &&
+       would_clean=$(
+               cd docs &&
+               git clean -n $(pwd)/../src |
+               sed -n -e "s|^Would remove ||p"
+       ) &&
+       test "$would_clean" = ../src/part3.c || {
+               echo "OOps <$would_clean>"
+               false
+       }
+'
+
+test_expect_success 'git-clean with out of work tree relative path' '
+
+       mkdir -p build docs &&
+       touch a.out src/part3.c docs/manual.txt obj.o build/lib.so &&
+       (
+               cd docs &&
+               test_must_fail git clean -n ../..
+       )
+'
+
+test_expect_success 'git-clean with out of work tree absolute path' '
+
+       mkdir -p build docs &&
+       touch a.out src/part3.c docs/manual.txt obj.o build/lib.so &&
+       dd=$(cd .. && pwd) &&
+       (
+               cd docs &&
+               test_must_fail git clean -n $dd
+       )
+'
+
 test_expect_success 'git-clean -d with prefix and path' '
 
        mkdir -p build docs src/feature &&
@@ -126,6 +178,20 @@ test_expect_success 'git-clean symbolic link' '
 
 '
 
+test_expect_success 'git-clean with wildcard' '
+
+       touch a.clean b.clean other.c &&
+       git-clean "*.clean" &&
+       test -f Makefile &&
+       test -f README &&
+       test -f src/part1.c &&
+       test -f src/part2.c &&
+       test ! -f a.clean &&
+       test ! -f b.clean &&
+       test -f other.c
+
+'
+
 test_expect_success 'git-clean -n' '
 
        mkdir -p build docs &&
@@ -291,4 +357,26 @@ test_expect_success 'clean.requireForce and -f' '
 
 '
 
+test_expect_success 'core.excludesfile' '
+
+       echo excludes >excludes &&
+       echo included >included &&
+       git config core.excludesfile excludes &&
+       output=$(git clean -n excludes included 2>&1) &&
+       expr "$output" : ".*included" >/dev/null &&
+       ! expr "$output" : ".*excludes" >/dev/null
+
+'
+
+test_expect_success 'removal failure' '
+
+       mkdir foo &&
+       touch foo/bar &&
+       exec <foo/bar &&
+       chmod 0 foo &&
+       test_must_fail git clean -f -d
+
+'
+chmod 755 foo
+
 test_done