@@ -9,8 +9,6 @@ test_description='Test git update-ref and basic ref logging'
9
9
Z=$ZERO_OID
10
10
11
11
m=refs/heads/main
12
- n_dir=refs/heads/gu
13
- n=$n_dir /fixes
14
12
outside=refs/foo
15
13
bare=bare-repo
16
14
@@ -62,10 +60,10 @@ test_expect_success "delete $m without oldvalue verification" '
62
60
test_must_fail git show-ref --verify -q $m
63
61
'
64
62
65
- test_expect_success " fail to create $n " '
66
- test_when_finished "rm -f .git/$n_dir " &&
67
- touch . git/$n_dir &&
68
- test_must_fail git update-ref $n $A
63
+ test_expect_success " fail to create $n due to file/directory conflict " '
64
+ test_when_finished "git update-ref -d refs/heads/gu " &&
65
+ git update-ref refs/heads/gu $A &&
66
+ test_must_fail git update-ref refs/heads/gu/fixes $A
69
67
'
70
68
71
69
test_expect_success " create $m (by HEAD)" '
@@ -92,7 +90,8 @@ test_expect_success "deleting current branch adds message to HEAD's log" '
92
90
git symbolic-ref HEAD $m &&
93
91
git update-ref -m delete-$m -d $m &&
94
92
test_must_fail git show-ref --verify -q $m &&
95
- grep "delete-$m$" .git/logs/HEAD
93
+ test-tool ref-store main for-each-reflog-ent HEAD >actual &&
94
+ grep "delete-$m$" actual
96
95
'
97
96
98
97
test_expect_success " deleting by HEAD adds message to HEAD's log" '
@@ -101,7 +100,8 @@ test_expect_success "deleting by HEAD adds message to HEAD's log" '
101
100
git symbolic-ref HEAD $m &&
102
101
git update-ref -m delete-by-head -d HEAD &&
103
102
test_must_fail git show-ref --verify -q $m &&
104
- grep "delete-by-head$" .git/logs/HEAD
103
+ test-tool ref-store main for-each-reflog-ent HEAD >actual &&
104
+ grep "delete-by-head$" actual
105
105
'
106
106
107
107
test_expect_success ' update-ref does not create reflogs by default' '
@@ -132,7 +132,7 @@ test_expect_success 'creates no reflog in bare repository' '
132
132
133
133
test_expect_success ' core.logAllRefUpdates=true creates reflog in bare repository' '
134
134
test_when_finished "git -C $bare config --unset core.logAllRefUpdates && \
135
- rm $bare/logs/ $m" &&
135
+ test-tool ref-store main delete-reflog $m" &&
136
136
git -C $bare config core.logAllRefUpdates true &&
137
137
git -C $bare update-ref $m $bareB &&
138
138
git -C $bare rev-parse $bareB >expect &&
@@ -221,27 +221,27 @@ test_expect_success 'delete symref without dereference when the referred ref is
221
221
'
222
222
223
223
test_expect_success ' update-ref -d is not confused by self-reference' '
224
+ test_when_finished "test-tool ref-store main delete-refs REF_NO_DEREF refs/heads/self" &&
224
225
git symbolic-ref refs/heads/self refs/heads/self &&
225
- test_when_finished "rm -f .git/refs/heads/self" &&
226
- test_path_is_file .git/refs/heads/self &&
226
+ git symbolic-ref --no-recurse refs/heads/self &&
227
227
test_must_fail git update-ref -d refs/heads/self &&
228
- test_path_is_file . git/ refs/heads/self
228
+ git symbolic-ref --no-recurse refs/heads/self
229
229
'
230
230
231
231
test_expect_success ' update-ref --no-deref -d can delete self-reference' '
232
+ test_when_finished "test-tool ref-store main delete-refs REF_NO_DEREF refs/heads/self" &&
232
233
git symbolic-ref refs/heads/self refs/heads/self &&
233
- test_when_finished "rm -f .git/refs/heads/self" &&
234
- test_path_is_file .git/refs/heads/self &&
234
+ git symbolic-ref --no-recurse refs/heads/self &&
235
235
git update-ref --no-deref -d refs/heads/self &&
236
236
test_must_fail git show-ref --verify -q refs/heads/self
237
237
'
238
238
239
- test_expect_success ' update-ref --no-deref -d can delete reference to bad ref' '
239
+ test_expect_success REFFILES ' update-ref --no-deref -d can delete reference to bad ref' '
240
240
>.git/refs/heads/bad &&
241
241
test_when_finished "rm -f .git/refs/heads/bad" &&
242
242
git symbolic-ref refs/heads/ref-to-bad refs/heads/bad &&
243
243
test_when_finished "git update-ref -d refs/heads/ref-to-bad" &&
244
- test_path_is_file . git/ refs/heads/ref-to-bad &&
244
+ git symbolic-ref --no-recurse refs/heads/ref-to-bad &&
245
245
git update-ref --no-deref -d refs/heads/ref-to-bad &&
246
246
test_must_fail git show-ref --verify -q refs/heads/ref-to-bad
247
247
'
@@ -265,7 +265,10 @@ test_expect_success "(not) changed .git/$m" '
265
265
! test $B = $(git show-ref -s --verify $m)
266
266
'
267
267
268
- rm -f .git/logs/refs/heads/main
268
+ test_expect_success " clean up reflog" '
269
+ test-tool ref-store main delete-reflog $m
270
+ '
271
+
269
272
test_expect_success " create $m (logged by touch)" '
270
273
test_config core.logAllRefUpdates false &&
271
274
GIT_COMMITTER_DATE="2005-05-26 23:30" \
@@ -285,7 +288,7 @@ test_expect_success "set $m (logged by touch)" '
285
288
test $A = $(git show-ref -s --verify $m)
286
289
'
287
290
288
- test_expect_success ' empty directory removal' '
291
+ test_expect_success REFFILES ' empty directory removal' '
289
292
git branch d1/d2/r1 HEAD &&
290
293
git branch d1/r2 HEAD &&
291
294
test_path_is_file .git/refs/heads/d1/d2/r1 &&
@@ -297,7 +300,7 @@ test_expect_success 'empty directory removal' '
297
300
test_path_is_file .git/logs/refs/heads/d1/r2
298
301
'
299
302
300
- test_expect_success ' symref empty directory removal' '
303
+ test_expect_success REFFILES ' symref empty directory removal' '
301
304
git branch e1/e2/r1 HEAD &&
302
305
git branch e1/r2 HEAD &&
303
306
git checkout e1/e2/r1 &&
@@ -318,7 +321,7 @@ $A $B $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> 1117150260 +0000 Switch
318
321
$B $A $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL > 1117150860 +0000
319
322
EOF
320
323
test_expect_success " verifying $m 's log (logged by touch)" '
321
- test_when_finished "git update-ref -d $m && rm -rf .git/logs actual expect" &&
324
+ test_when_finished "git update-ref -d $m && git reflog expire --expire=all --all && rm -rf actual expect" &&
322
325
test-tool ref-store main for-each-reflog-ent $m >actual &&
323
326
test_cmp actual expect
324
327
'
@@ -348,7 +351,7 @@ $A $B $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> 1117150380 +0000 Switch
348
351
$B $A $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL > 1117150980 +0000
349
352
EOF
350
353
test_expect_success " verifying $m 's log (logged by config)" '
351
- test_when_finished "git update-ref -d $m && rm -rf .git/logs actual expect" &&
354
+ test_when_finished "git update-ref -d $m && git reflog expire --expire=all --all && rm -rf actual expect" &&
352
355
test-tool ref-store main for-each-reflog-ent $m >actual &&
353
356
test_cmp actual expect
354
357
'
@@ -434,7 +437,8 @@ test_expect_success 'Query "main@{2005-05-28}" (past end of history)' '
434
437
test_i18ngrep -F "warning: log for ref $m unexpectedly ended on $ld" e
435
438
'
436
439
437
- rm -f .git/$m .git/logs/$m expect
440
+ rm -f expect
441
+ git update-ref -d $m
438
442
439
443
test_expect_success ' creating initial files' '
440
444
test_when_finished rm -f M &&
@@ -1635,7 +1639,7 @@ test_expect_success PIPE 'transaction flushes status updates' '
1635
1639
test_cmp expected actual
1636
1640
'
1637
1641
1638
- test_expect_success ' directory not created deleting packed ref' '
1642
+ test_expect_success REFFILES ' directory not created deleting packed ref' '
1639
1643
git branch d1/d2/r1 HEAD &&
1640
1644
git pack-refs --all &&
1641
1645
test_path_is_missing .git/refs/heads/d1/d2 &&
0 commit comments