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 <gitster@pobox.com>
Junio C Hamano committed
Mar 7, 2008 at 21:56 UTC
5b7570cfb41c34ce585ede3fc1e45fa48febbd8f
1 file changed
+52
t/t7300-clean.sh
+52
@@ -89,6 +89,58 @@ test_expect_success 'git-clean with prefix' '
89
test -f build/lib.so
90
91
'
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
+
144
test_expect_success 'git-clean -d with prefix and path' '
145
146
mkdir -p build docs src/feature &&