@@ -40,68 +40,68 @@ test_expect_success \
40
40
" git update-ref $m $A &&
41
41
test $A " ' = $(cat .git/' " $m " ' )'
42
42
test_expect_success \
43
- " create $m " \
43
+ " create $m with oldvalue verification " \
44
44
" git update-ref $m $B $A &&
45
45
test $B " ' = $(cat .git/' " $m " ' )'
46
46
test_expect_success " fail to delete $m with stale ref" '
47
47
test_must_fail git update-ref -d $m $A &&
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
- ! test -f .git/$m
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
- ! test -f .git/$m
61
- "
62
- rm -f .git/$m
61
+ test_path_is_missing .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 >out 2>err "
68
- rm -f .git/ $n_dir out err
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)" \
72
72
" git update-ref HEAD $A &&
73
73
test $A " ' = $(cat .git/' " $m " ' )'
74
74
test_expect_success \
75
- " create $m (by HEAD)" \
75
+ " create $m (by HEAD) with oldvalue verification " \
76
76
" git update-ref HEAD $B $A &&
77
77
test $B " ' = $(cat .git/' " $m " ' )'
78
78
test_expect_success " fail to delete $m (by HEAD) with stale ref" '
79
79
test_must_fail git update-ref -d HEAD $A &&
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
- ! test -f .git/$m
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
- ! test -f .git/$m &&
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
- ! test -f .git/$m &&
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
- ! test -f .git/$m
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
- ! test -f .git/HEAD
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
- ! test -f .git/HEAD
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,94 +242,95 @@ 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 -f .git/$m
246
- "
247
- rm -f .git/ $m
245
+ test_expect_success " (not) prior created .git/$m " '
246
+ test_when_finished "rm -f .git/$m" &&
247
+ test_path_is_missing .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 \
262
263
" create $m (logged by touch)" \
263
- ' GIT_COMMITTER_DATE="2005-05-26 23:30" \
264
+ ' test_config core.logAllRefUpdates false &&
265
+ GIT_COMMITTER_DATE="2005-05-26 23:30" \
264
266
git update-ref --create-reflog HEAD ' " $A " ' -m "Initial Creation" &&
265
267
test ' " $A " ' = $(cat .git/' " $m " ' )'
266
268
test_expect_success \
267
269
" update $m (logged by touch)" \
268
- ' GIT_COMMITTER_DATE="2005-05-26 23:31" \
270
+ ' test_config core.logAllRefUpdates false &&
271
+ GIT_COMMITTER_DATE="2005-05-26 23:31" \
269
272
git update-ref HEAD' " $B $A " ' -m "Switch" &&
270
273
test ' " $B " ' = $(cat .git/' " $m " ' )'
271
274
test_expect_success \
272
275
" set $m (logged by touch)" \
273
- ' GIT_COMMITTER_DATE="2005-05-26 23:41" \
276
+ ' test_config core.logAllRefUpdates false &&
277
+ GIT_COMMITTER_DATE="2005-05-26 23:41" \
274
278
git update-ref HEAD' " $A &&
275
279
test $A " ' = $(cat .git/' " $m " ' )'
276
280
277
281
test_expect_success " empty directory removal" '
278
282
git branch d1/d2/r1 HEAD &&
279
283
git branch d1/r2 HEAD &&
280
- test -f .git/refs/heads/d1/d2/r1 &&
281
- test -f .git/logs/refs/heads/d1/d2/r1 &&
284
+ test_path_is_file .git/refs/heads/d1/d2/r1 &&
285
+ test_path_is_file .git/logs/refs/heads/d1/d2/r1 &&
282
286
git branch -d d1/d2/r1 &&
283
- ! test -e .git/refs/heads/d1/d2 &&
284
- ! test -e .git/logs/refs/heads/d1/d2 &&
285
- test -f .git/refs/heads/d1/r2 &&
286
- test -f .git/logs/refs/heads/d1/r2
287
+ test_path_is_missing .git/refs/heads/d1/d2 &&
288
+ test_path_is_missing .git/logs/refs/heads/d1/d2 &&
289
+ test_path_is_file .git/refs/heads/d1/r2 &&
290
+ test_path_is_file .git/logs/refs/heads/d1/r2
287
291
'
288
292
289
293
test_expect_success " symref empty directory removal" '
290
294
git branch e1/e2/r1 HEAD &&
291
295
git branch e1/r2 HEAD &&
292
296
git checkout e1/e2/r1 &&
293
297
test_when_finished "git checkout master" &&
294
- test -f .git/refs/heads/e1/e2/r1 &&
295
- test -f .git/logs/refs/heads/e1/e2/r1 &&
298
+ test_path_is_file .git/refs/heads/e1/e2/r1 &&
299
+ test_path_is_file .git/logs/refs/heads/e1/e2/r1 &&
296
300
git update-ref -d HEAD &&
297
- ! test -e .git/refs/heads/e1/e2 &&
298
- ! test -e .git/logs/refs/heads/e1/e2 &&
299
- test -f .git/refs/heads/e1/r2 &&
300
- test -f .git/logs/refs/heads/e1/r2 &&
301
- test -f .git/logs/HEAD
301
+ test_path_is_missing .git/refs/heads/e1/e2 &&
302
+ test_path_is_missing .git/logs/refs/heads/e1/e2 &&
303
+ test_path_is_file .git/refs/heads/e1/r2 &&
304
+ test_path_is_file .git/logs/refs/heads/e1/r2 &&
305
+ test_path_is_file .git/logs/HEAD
302
306
'
303
307
304
308
cat > expect << EOF
305
309
$Z $A $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL > 1117150200 +0000 Initial Creation
306
310
$A $B $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL > 1117150260 +0000 Switch
307
311
$B $A $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL > 1117150860 +0000
308
312
EOF
309
- test_expect_success \
310
- " verifying $m 's log" \
311
- " test_cmp expect .git/logs/$m "
312
- rm -rf .git/$m .git/logs expect
313
-
314
- test_expect_success \
315
- ' enable core.logAllRefUpdates' \
316
- ' git config core.logAllRefUpdates true &&
317
- test true = $(git config --bool --get core.logAllRefUpdates)'
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
+ '
318
317
319
318
test_expect_success \
320
319
" create $m (logged by config)" \
321
- ' GIT_COMMITTER_DATE="2005-05-26 23:32" \
320
+ ' test_config core.logAllRefUpdates true &&
321
+ GIT_COMMITTER_DATE="2005-05-26 23:32" \
322
322
git update-ref HEAD' " $A " ' -m "Initial Creation" &&
323
323
test ' " $A " ' = $(cat .git/' " $m " ' )'
324
324
test_expect_success \
325
325
" update $m (logged by config)" \
326
- ' GIT_COMMITTER_DATE="2005-05-26 23:33" \
326
+ ' test_config core.logAllRefUpdates true &&
327
+ GIT_COMMITTER_DATE="2005-05-26 23:33" \
327
328
git update-ref HEAD' " $B $A " ' -m "Switch" &&
328
329
test ' " $B " ' = $(cat .git/' " $m " ' )'
329
330
test_expect_success \
330
331
" set $m (logged by config)" \
331
- ' GIT_COMMITTER_DATE="2005-05-26 23:43" \
332
+ ' test_config core.logAllRefUpdates true &&
333
+ GIT_COMMITTER_DATE="2005-05-26 23:43" \
332
334
git update-ref HEAD ' " $A &&
333
335
test $A " ' = $(cat .git/' " $m " ' )'
334
336
@@ -338,9 +340,9 @@ $A $B $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> 1117150380 +0000 Switch
338
340
$B $A $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL > 1117150980 +0000
339
341
EOF
340
342
test_expect_success \
341
- " verifying $m 's log" \
342
- ' test_cmp expect .git/logs/$m'
343
- rm -f .git/ $m .git/logs/$m expect
343
+ " verifying $m 's log (logged by config) " \
344
+ ' test_when_finished "rm -f .git/$m .git/ logs/$m expect" &&
345
+ test_cmp expect .git/logs/$m'
344
346
345
347
git update-ref $m $D
346
348
cat > .git/logs/$m << EOF
@@ -356,55 +358,55 @@ gd="Thu, 26 May 2005 18:33:00 -0500"
356
358
ld=" Thu, 26 May 2005 18:43:00 -0500"
357
359
test_expect_success \
358
360
' Query "master@{May 25 2005}" (before history)' \
359
- ' rm -f o e &&
361
+ ' test_when_finished " rm -f o e" &&
360
362
git rev-parse --verify "master@{May 25 2005}" >o 2>e &&
361
363
test ' " $C " ' = $(cat o) &&
362
364
test "warning: Log for ' \' master\' ' only goes back to $ed." = "$(cat e)"'
363
365
test_expect_success \
364
366
" Query master@{2005-05-25} (before history)" \
365
- ' rm -f o e &&
367
+ ' test_when_finished " rm -f o e" &&
366
368
git rev-parse --verify master@{2005-05-25} >o 2>e &&
367
369
test ' " $C " ' = $(cat o) &&
368
370
echo test "warning: Log for ' \' master\' ' only goes back to $ed." = "$(cat e)"'
369
371
test_expect_success \
370
372
' Query "master@{May 26 2005 23:31:59}" (1 second before history)' \
371
- ' rm -f o e &&
373
+ ' test_when_finished " rm -f o e" &&
372
374
git rev-parse --verify "master@{May 26 2005 23:31:59}" >o 2>e &&
373
375
test ' " $C " ' = $(cat o) &&
374
376
test "warning: Log for ' \' ' master' \' ' only goes back to $ed." = "$(cat e)"'
375
377
test_expect_success \
376
378
' Query "master@{May 26 2005 23:32:00}" (exactly history start)' \
377
- ' rm -f o e &&
379
+ ' test_when_finished " rm -f o e" &&
378
380
git rev-parse --verify "master@{May 26 2005 23:32:00}" >o 2>e &&
379
381
test ' " $C " ' = $(cat o) &&
380
382
test "" = "$(cat e)"'
381
383
test_expect_success \
382
384
' Query "master@{May 26 2005 23:32:30}" (first non-creation change)' \
383
- ' rm -f o e &&
385
+ ' test_when_finished " rm -f o e" &&
384
386
git rev-parse --verify "master@{May 26 2005 23:32:30}" >o 2>e &&
385
387
test ' " $A " ' = $(cat o) &&
386
388
test "" = "$(cat e)"'
387
389
test_expect_success \
388
390
' Query "master@{2005-05-26 23:33:01}" (middle of history with gap)' \
389
- ' rm -f o e &&
391
+ ' test_when_finished " rm -f o e" &&
390
392
git rev-parse --verify "master@{2005-05-26 23:33:01}" >o 2>e &&
391
393
test ' " $B " ' = $(cat o) &&
392
394
test "warning: Log for ref ' " $m has gap after $gd " ' ." = "$(cat e)"'
393
395
test_expect_success \
394
396
' Query "master@{2005-05-26 23:38:00}" (middle of history)' \
395
- ' rm -f o e &&
397
+ ' test_when_finished " rm -f o e" &&
396
398
git rev-parse --verify "master@{2005-05-26 23:38:00}" >o 2>e &&
397
399
test ' " $Z " ' = $(cat o) &&
398
400
test "" = "$(cat e)"'
399
401
test_expect_success \
400
402
' Query "master@{2005-05-26 23:43:00}" (exact end of history)' \
401
- ' rm -f o e &&
403
+ ' test_when_finished " rm -f o e" &&
402
404
git rev-parse --verify "master@{2005-05-26 23:43:00}" >o 2>e &&
403
405
test ' " $E " ' = $(cat o) &&
404
406
test "" = "$(cat e)"'
405
407
test_expect_success \
406
408
' Query "master@{2005-05-28}" (past end of history)' \
407
- ' rm -f o e &&
409
+ ' test_when_finished " rm -f o e" &&
408
410
git rev-parse --verify "master@{2005-05-28}" >o 2>e &&
409
411
test ' " $D " ' = $(cat o) &&
410
412
test "warning: Log for ref ' " $m unexpectedly ended on $ld " ' ." = "$(cat e)"'
@@ -414,7 +416,8 @@ rm -f .git/$m .git/logs/$m expect
414
416
415
417
test_expect_success \
416
418
' creating initial files' \
417
- ' echo TEST >F &&
419
+ ' test_when_finished rm -f M &&
420
+ echo TEST >F &&
418
421
git add F &&
419
422
GIT_AUTHOR_DATE="2005-05-26 23:30" \
420
423
GIT_COMMITTER_DATE="2005-05-26 23:30" git commit -m add -a &&
@@ -432,8 +435,7 @@ test_expect_success \
432
435
echo $h_TEST >.git/MERGE_HEAD &&
433
436
GIT_AUTHOR_DATE="2005-05-26 23:45" \
434
437
GIT_COMMITTER_DATE="2005-05-26 23:45" git commit -F M &&
435
- h_MERGED=$(git rev-parse --verify HEAD) &&
436
- rm -f M'
438
+ h_MERGED=$(git rev-parse --verify HEAD)'
437
439
438
440
cat > expect << EOF
439
441
$Z $h_TEST $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL > 1117150200 +0000 commit (initial): add
0 commit comments