@@ -48,24 +48,24 @@ test_expect_success "fail to delete $m with stale ref" '
48
48
test $B = "$(cat .git/$m)"
49
49
'
50
50
test_expect_success " delete $m " '
51
+ test_when_finished "rm -f .git/$m" &&
51
52
git update-ref -d $m $B &&
52
53
test_path_is_missing .git/$m
53
54
'
54
- rm -f .git/$m
55
55
56
- test_expect_success " delete $m without oldvalue verification" "
56
+ test_expect_success " delete $m without oldvalue verification" '
57
+ test_when_finished "rm -f .git/$m" &&
57
58
git update-ref $m $A &&
58
- test $A = \ $ (cat .git/$m ) &&
59
+ test $A = $(cat .git/$m) &&
59
60
git update-ref -d $m &&
60
61
test_path_is_missing .git/$m
61
- "
62
- rm -f .git/$m
62
+ '
63
63
64
- test_expect_success \
65
- " fail to create $n " \
66
- " touch .git/$n_dir &&
67
- test_must_fail git update-ref $n $A "
68
- rm -f .git/ $n_dir
64
+ test_expect_success " fail to create $n " '
65
+ test_when_finished "rm -f .git/$n_dir" &&
66
+ touch .git/$n_dir &&
67
+ test_must_fail git update-ref $n $A
68
+ '
69
69
70
70
test_expect_success \
71
71
" create $m (by HEAD)" \
@@ -80,28 +80,28 @@ test_expect_success "fail to delete $m (by HEAD) with stale ref" '
80
80
test $B = $(cat .git/$m)
81
81
'
82
82
test_expect_success " delete $m (by HEAD)" '
83
+ test_when_finished "rm -f .git/$m" &&
83
84
git update-ref -d HEAD $B &&
84
85
test_path_is_missing .git/$m
85
86
'
86
- rm -f .git/$m
87
87
88
88
test_expect_success " deleting current branch adds message to HEAD's log" '
89
+ test_when_finished "rm -f .git/$m" &&
89
90
git update-ref $m $A &&
90
91
git symbolic-ref HEAD $m &&
91
92
git update-ref -m delete-$m -d $m &&
92
93
test_path_is_missing .git/$m &&
93
94
grep "delete-$m$" .git/logs/HEAD
94
95
'
95
- rm -f .git/$m
96
96
97
97
test_expect_success " deleting by HEAD adds message to HEAD's log" '
98
+ test_when_finished "rm -f .git/$m" &&
98
99
git update-ref $m $A &&
99
100
git symbolic-ref HEAD $m &&
100
101
git update-ref -m delete-by-head -d HEAD &&
101
102
test_path_is_missing .git/$m &&
102
103
grep "delete-by-head$" .git/logs/HEAD
103
104
'
104
- rm -f .git/$m
105
105
106
106
test_expect_success ' update-ref does not create reflogs by default' '
107
107
test_when_finished "git update-ref -d $outside" &&
@@ -188,28 +188,29 @@ test_expect_success \
188
188
" git update-ref HEAD $B $A &&
189
189
test $B " ' = $(cat .git/' " $m " ' )'
190
190
test_expect_success " delete $m (by HEAD) should remove both packed and loose $m " '
191
+ test_when_finished "rm -f .git/$m" &&
191
192
git update-ref -d HEAD $B &&
192
193
! grep "$m" .git/packed-refs &&
193
194
test_path_is_missing .git/$m
194
195
'
195
- rm -f .git/$m
196
196
197
197
cp -f .git/HEAD .git/HEAD.orig
198
198
test_expect_success " delete symref without dereference" '
199
+ test_when_finished "cp -f .git/HEAD.orig .git/HEAD" &&
199
200
git update-ref --no-deref -d HEAD &&
200
201
test_path_is_missing .git/HEAD
201
202
'
202
- cp -f .git/HEAD.orig .git/HEAD
203
203
204
204
test_expect_success " delete symref without dereference when the referred ref is packed" '
205
+ test_when_finished "cp -f .git/HEAD.orig .git/HEAD" &&
205
206
echo foo >foo.c &&
206
207
git add foo.c &&
207
208
git commit -m foo &&
208
209
git pack-refs --all &&
209
210
git update-ref --no-deref -d HEAD &&
210
211
test_path_is_missing .git/HEAD
211
212
'
212
- cp -f .git/HEAD.orig .git/HEAD
213
+
213
214
git update-ref -d $m
214
215
215
216
test_expect_success ' update-ref -d is not confused by self-reference' '
@@ -241,21 +242,21 @@ test_expect_success 'update-ref --no-deref -d can delete reference to bad ref' '
241
242
test_expect_success ' (not) create HEAD with old sha1' "
242
243
test_must_fail git update-ref HEAD $A $B
243
244
"
244
- test_expect_success " (not) prior created .git/$m " "
245
+ test_expect_success " (not) prior created .git/$m " '
246
+ test_when_finished "rm -f .git/$m" &&
245
247
test_path_is_missing .git/$m
246
- "
247
- rm -f .git/$m
248
+ '
248
249
249
250
test_expect_success \
250
251
" create HEAD" \
251
252
" git update-ref HEAD $A "
252
253
test_expect_success ' (not) change HEAD with wrong SHA1' "
253
254
test_must_fail git update-ref HEAD $B $Z
254
255
"
255
- test_expect_success " (not) changed .git/$m " "
256
- ! test $B " ' = $(cat .git/' " $m " ' )
256
+ test_expect_success " (not) changed .git/$m " '
257
+ test_when_finished "rm -f .git/$m" &&
258
+ ! test $B = $(cat .git/$m)
257
259
'
258
- rm -f .git/$m
259
260
260
261
rm -f .git/logs/refs/heads/master
261
262
test_expect_success \
@@ -309,10 +310,10 @@ $Z $A $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> 1117150200 +0000 Initial Creati
309
310
$A $B $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL > 1117150260 +0000 Switch
310
311
$B $A $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL > 1117150860 +0000
311
312
EOF
312
- test_expect_success \
313
- " verifying $m 's log (logged by touch) " \
314
- " test_cmp expect .git/logs/$m "
315
- rm -rf .git/ $m .git/logs expect
313
+ test_expect_success " verifying $m 's log (logged by touch) " '
314
+ test_when_finished "rm -rf .git/$m .git/logs expect" &&
315
+ test_cmp expect .git/logs/$m
316
+ '
316
317
317
318
test_expect_success \
318
319
" create $m (logged by config)" \
@@ -340,8 +341,8 @@ $B $A $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> 1117150980 +0000
340
341
EOF
341
342
test_expect_success \
342
343
" verifying $m 's log (logged by config)" \
343
- ' test_cmp expect .git/logs/$m'
344
- rm -f .git/ $m .git/logs/$m expect
344
+ ' test_when_finished "rm -f .git/$m .git/ logs/$m expect" &&
345
+ test_cmp expect .git/logs/$m'
345
346
346
347
git update-ref $m $D
347
348
cat > .git/logs/$m << EOF
@@ -357,55 +358,55 @@ gd="Thu, 26 May 2005 18:33:00 -0500"
357
358
ld=" Thu, 26 May 2005 18:43:00 -0500"
358
359
test_expect_success \
359
360
' Query "master@{May 25 2005}" (before history)' \
360
- ' rm -f o e &&
361
+ ' test_when_finished " rm -f o e" &&
361
362
git rev-parse --verify "master@{May 25 2005}" >o 2>e &&
362
363
test ' " $C " ' = $(cat o) &&
363
364
test "warning: Log for ' \' master\' ' only goes back to $ed." = "$(cat e)"'
364
365
test_expect_success \
365
366
" Query master@{2005-05-25} (before history)" \
366
- ' rm -f o e &&
367
+ ' test_when_finished " rm -f o e" &&
367
368
git rev-parse --verify master@{2005-05-25} >o 2>e &&
368
369
test ' " $C " ' = $(cat o) &&
369
370
echo test "warning: Log for ' \' master\' ' only goes back to $ed." = "$(cat e)"'
370
371
test_expect_success \
371
372
' Query "master@{May 26 2005 23:31:59}" (1 second before history)' \
372
- ' rm -f o e &&
373
+ ' test_when_finished " rm -f o e" &&
373
374
git rev-parse --verify "master@{May 26 2005 23:31:59}" >o 2>e &&
374
375
test ' " $C " ' = $(cat o) &&
375
376
test "warning: Log for ' \' ' master' \' ' only goes back to $ed." = "$(cat e)"'
376
377
test_expect_success \
377
378
' Query "master@{May 26 2005 23:32:00}" (exactly history start)' \
378
- ' rm -f o e &&
379
+ ' test_when_finished " rm -f o e" &&
379
380
git rev-parse --verify "master@{May 26 2005 23:32:00}" >o 2>e &&
380
381
test ' " $C " ' = $(cat o) &&
381
382
test "" = "$(cat e)"'
382
383
test_expect_success \
383
384
' Query "master@{May 26 2005 23:32:30}" (first non-creation change)' \
384
- ' rm -f o e &&
385
+ ' test_when_finished " rm -f o e" &&
385
386
git rev-parse --verify "master@{May 26 2005 23:32:30}" >o 2>e &&
386
387
test ' " $A " ' = $(cat o) &&
387
388
test "" = "$(cat e)"'
388
389
test_expect_success \
389
390
' Query "master@{2005-05-26 23:33:01}" (middle of history with gap)' \
390
- ' rm -f o e &&
391
+ ' test_when_finished " rm -f o e" &&
391
392
git rev-parse --verify "master@{2005-05-26 23:33:01}" >o 2>e &&
392
393
test ' " $B " ' = $(cat o) &&
393
394
test "warning: Log for ref ' " $m has gap after $gd " ' ." = "$(cat e)"'
394
395
test_expect_success \
395
396
' Query "master@{2005-05-26 23:38:00}" (middle of history)' \
396
- ' rm -f o e &&
397
+ ' test_when_finished " rm -f o e" &&
397
398
git rev-parse --verify "master@{2005-05-26 23:38:00}" >o 2>e &&
398
399
test ' " $Z " ' = $(cat o) &&
399
400
test "" = "$(cat e)"'
400
401
test_expect_success \
401
402
' Query "master@{2005-05-26 23:43:00}" (exact end of history)' \
402
- ' rm -f o e &&
403
+ ' test_when_finished " rm -f o e" &&
403
404
git rev-parse --verify "master@{2005-05-26 23:43:00}" >o 2>e &&
404
405
test ' " $E " ' = $(cat o) &&
405
406
test "" = "$(cat e)"'
406
407
test_expect_success \
407
408
' Query "master@{2005-05-28}" (past end of history)' \
408
- ' rm -f o e &&
409
+ ' test_when_finished " rm -f o e" &&
409
410
git rev-parse --verify "master@{2005-05-28}" >o 2>e &&
410
411
test ' " $D " ' = $(cat o) &&
411
412
test "warning: Log for ref ' " $m unexpectedly ended on $ld " ' ." = "$(cat e)"'
@@ -415,7 +416,8 @@ rm -f .git/$m .git/logs/$m expect
415
416
416
417
test_expect_success \
417
418
' creating initial files' \
418
- ' echo TEST >F &&
419
+ ' test_when_finished rm -f M &&
420
+ echo TEST >F &&
419
421
git add F &&
420
422
GIT_AUTHOR_DATE="2005-05-26 23:30" \
421
423
GIT_COMMITTER_DATE="2005-05-26 23:30" git commit -m add -a &&
@@ -433,8 +435,7 @@ test_expect_success \
433
435
echo $h_TEST >.git/MERGE_HEAD &&
434
436
GIT_AUTHOR_DATE="2005-05-26 23:45" \
435
437
GIT_COMMITTER_DATE="2005-05-26 23:45" git commit -F M &&
436
- h_MERGED=$(git rev-parse --verify HEAD) &&
437
- rm -f M'
438
+ h_MERGED=$(git rev-parse --verify HEAD)'
438
439
439
440
cat > expect << EOF
440
441
$Z $h_TEST $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL > 1117150200 +0000 commit (initial): add
0 commit comments