t1430: improve test coverage of deletion of badly-named refs

Check "branch -d broken...ref" Check various combinations of * Deleting using "update-ref -d" * Deleting using "update-ref --no-deref -d" * Deleting using "branch -d" in the following combinations of symref -> ref: * badname -> broken...ref * badname -> broken...ref (dangling) * broken...symref -> master * broken...symref -> idonotexist (dangling) Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu> Signed-off-by: David Turner <dturner@twopensource.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Michael Haggerty committed Apr 7, 2016 at 15:02 UTC 757552db5794056cdeccab827745f3de1fb82f4b
1 file changed +96 -8
t/t1430-bad-ref-name.sh
+96 -8
@@ -171,25 +171,113 @@ test_expect_success 'for-each-ref emits warnings for broken names' '
171 test_i18ngrep "ignoring ref with broken name refs/heads/broken\.\.\.symref" error
172 '
173
174 -test_expect_success 'update-ref --no-deref -d can delete reference to broken name' '
174 +test_expect_success 'update-ref -d can delete broken name' '
175 + cp .git/refs/heads/master .git/refs/heads/broken...ref &&
176 + test_when_finished "rm -f .git/refs/heads/broken...ref" &&
177 + git update-ref -d refs/heads/broken...ref >output 2>error &&
178 + test_must_be_empty output &&
179 + test_must_be_empty error &&
180 + git branch >output 2>error &&
181 + ! grep -e "broken\.\.\.ref" error &&
182 + ! grep -e "broken\.\.\.ref" output
183 +'
184 +
185 +test_expect_success 'branch -d can delete broken name' '
186 + cp .git/refs/heads/master .git/refs/heads/broken...ref &&
187 + test_when_finished "rm -f .git/refs/heads/broken...ref" &&
188 + git branch -d broken...ref >output 2>error &&
189 + test_i18ngrep "Deleted branch broken...ref (was broken)" output &&
190 + test_must_be_empty error &&
191 + git branch >output 2>error &&
192 + ! grep -e "broken\.\.\.ref" error &&
193 + ! grep -e "broken\.\.\.ref" output
194 +'
195 +
196 +test_expect_success 'update-ref --no-deref -d can delete symref to broken name' '
197 + cp .git/refs/heads/master .git/refs/heads/broken...ref &&
198 + test_when_finished "rm -f .git/refs/heads/broken...ref" &&
199 printf "ref: refs/heads/broken...ref\n" >.git/refs/heads/badname &&
200 test_when_finished "rm -f .git/refs/heads/badname" &&
177 - test_path_is_file .git/refs/heads/badname &&
201 git update-ref --no-deref -d refs/heads/badname >output 2>error &&
202 test_path_is_missing .git/refs/heads/badname &&
203 test_must_be_empty output &&
204 test_must_be_empty error
205 '
206
184 -test_expect_success 'update-ref -d can delete broken name' '
207 +test_expect_success 'branch -d can delete symref to broken name' '
208 cp .git/refs/heads/master .git/refs/heads/broken...ref &&
209 test_when_finished "rm -f .git/refs/heads/broken...ref" &&
187 - git update-ref -d refs/heads/broken...ref >output 2>error &&
210 + printf "ref: refs/heads/broken...ref\n" >.git/refs/heads/badname &&
211 + test_when_finished "rm -f .git/refs/heads/badname" &&
212 + git branch -d badname >output 2>error &&
213 + test_path_is_missing .git/refs/heads/badname &&
214 + test_i18ngrep "Deleted branch badname (was refs/heads/broken\.\.\.ref)" output &&
215 + test_must_be_empty error
216 +'
217 +
218 +test_expect_success 'update-ref --no-deref -d can delete dangling symref to broken name' '
219 + printf "ref: refs/heads/broken...ref\n" >.git/refs/heads/badname &&
220 + test_when_finished "rm -f .git/refs/heads/badname" &&
221 + git update-ref --no-deref -d refs/heads/badname >output 2>error &&
222 + test_path_is_missing .git/refs/heads/badname &&
223 test_must_be_empty output &&
189 - test_must_be_empty error &&
190 - git branch >output 2>error &&
191 - ! grep -e "broken\.\.\.ref" error &&
192 - ! grep -e "broken\.\.\.ref" output
224 + test_must_be_empty error
225 +'
226 +
227 +test_expect_success 'branch -d can delete dangling symref to broken name' '
228 + printf "ref: refs/heads/broken...ref\n" >.git/refs/heads/badname &&
229 + test_when_finished "rm -f .git/refs/heads/badname" &&
230 + git branch -d badname >output 2>error &&
231 + test_path_is_missing .git/refs/heads/badname &&
232 + test_i18ngrep "Deleted branch badname (was refs/heads/broken\.\.\.ref)" output &&
233 + test_must_be_empty error
234 +'
235 +
236 +test_expect_success 'update-ref -d can delete broken name through symref' '
237 + cp .git/refs/heads/master .git/refs/heads/broken...ref &&
238 + test_when_finished "rm -f .git/refs/heads/broken...ref" &&
239 + printf "ref: refs/heads/broken...ref\n" >.git/refs/heads/badname &&
240 + test_when_finished "rm -f .git/refs/heads/badname" &&
241 + git update-ref -d refs/heads/badname >output 2>error &&
242 + test_path_is_missing .git/refs/heads/broken...ref &&
243 + test_must_be_empty output &&
244 + test_must_be_empty error
245 +'
246 +
247 +test_expect_success 'update-ref --no-deref -d can delete symref with broken name' '
248 + printf "ref: refs/heads/master\n" >.git/refs/heads/broken...symref &&
249 + test_when_finished "rm -f .git/refs/heads/broken...symref" &&
250 + git update-ref --no-deref -d refs/heads/broken...symref >output 2>error &&
251 + test_path_is_missing .git/refs/heads/broken...symref &&
252 + test_must_be_empty output &&
253 + test_must_be_empty error
254 +'
255 +
256 +test_expect_success 'branch -d can delete symref with broken name' '
257 + printf "ref: refs/heads/master\n" >.git/refs/heads/broken...symref &&
258 + test_when_finished "rm -f .git/refs/heads/broken...symref" &&
259 + git branch -d broken...symref >output 2>error &&
260 + test_path_is_missing .git/refs/heads/broken...symref &&
261 + test_i18ngrep "Deleted branch broken...symref (was refs/heads/master)" output &&
262 + test_must_be_empty error
263 +'
264 +
265 +test_expect_success 'update-ref --no-deref -d can delete dangling symref with broken name' '
266 + printf "ref: refs/heads/idonotexist\n" >.git/refs/heads/broken...symref &&
267 + test_when_finished "rm -f .git/refs/heads/broken...symref" &&
268 + git update-ref --no-deref -d refs/heads/broken...symref >output 2>error &&
269 + test_path_is_missing .git/refs/heads/broken...symref &&
270 + test_must_be_empty output &&
271 + test_must_be_empty error
272 +'
273 +
274 +test_expect_success 'branch -d can delete dangling symref with broken name' '
275 + printf "ref: refs/heads/idonotexist\n" >.git/refs/heads/broken...symref &&
276 + test_when_finished "rm -f .git/refs/heads/broken...symref" &&
277 + git branch -d broken...symref >output 2>error &&
278 + test_path_is_missing .git/refs/heads/broken...symref &&
279 + test_i18ngrep "Deleted branch broken...symref (was refs/heads/idonotexist)" output &&
280 + test_must_be_empty error
281 '
282
283 test_expect_success 'update-ref -d cannot delete non-ref in .git dir' '