Skip to content

Commit 5b7570c

Browse files
committed
git-clean: add tests for relative path
This adds tests for recent change by Dmitry to fix the report "git clean" gives on removed paths, and also makes sure the command detects paths that is outside working tree. Signed-off-by: Junio C Hamano <[email protected]>
1 parent 1fb3289 commit 5b7570c

File tree

1 file changed

+52
-0
lines changed

1 file changed

+52
-0
lines changed

t/t7300-clean.sh

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,58 @@ test_expect_success 'git-clean with prefix' '
8989
test -f build/lib.so
9090
9191
'
92+
93+
test_expect_success 'git-clean with relative prefix' '
94+
95+
mkdir -p build docs &&
96+
touch a.out src/part3.c docs/manual.txt obj.o build/lib.so &&
97+
would_clean=$(
98+
cd docs &&
99+
git clean -n ../src |
100+
sed -n -e "s|^Would remove ||p"
101+
) &&
102+
test "$would_clean" = ../src/part3.c || {
103+
echo "OOps <$would_clean>"
104+
false
105+
}
106+
'
107+
108+
test_expect_success 'git-clean with absolute path' '
109+
110+
mkdir -p build docs &&
111+
touch a.out src/part3.c docs/manual.txt obj.o build/lib.so &&
112+
would_clean=$(
113+
cd docs &&
114+
git clean -n $(pwd)/../src |
115+
sed -n -e "s|^Would remove ||p"
116+
) &&
117+
test "$would_clean" = ../src/part3.c || {
118+
echo "OOps <$would_clean>"
119+
false
120+
}
121+
'
122+
123+
test_expect_success 'git-clean with out of work tree relative path' '
124+
125+
mkdir -p build docs &&
126+
touch a.out src/part3.c docs/manual.txt obj.o build/lib.so &&
127+
(
128+
cd docs &&
129+
test_must_fail git clean -n ../..
130+
)
131+
'
132+
133+
test_expect_success 'git-clean with out of work tree absolute path' '
134+
135+
mkdir -p build docs &&
136+
touch a.out src/part3.c docs/manual.txt obj.o build/lib.so &&
137+
dd=$(cd .. && pwd) &&
138+
(
139+
cd docs &&
140+
test_must_fail git clean -n $dd
141+
)
142+
'
143+
92144
test_expect_success 'git-clean -d with prefix and path' '
93145
94146
mkdir -p build docs src/feature &&

0 commit comments

Comments
 (0)