Skip to content

Commit 7ece6ad

Browse files
committed
Merge branch 'ps/ref-tests-update-even-more'
More tests that are marked as "ref-files only" have been updated to improve test coverage of reftable backend. * ps/ref-tests-update-even-more: t7003: ensure filter-branch prunes reflogs with the reftable backend t2011: exercise D/F conflicts with HEAD with the reftable backend t1405: remove unneeded cleanup step t1404: make D/F conflict tests compatible with reftable backend t1400: exercise reflog with gaps with reftable backend t0410: convert tests to use DEFAULT_REPO_FORMAT prereq t: move tests exercising the "files" backend
2 parents 6546277 + 5918f30 commit 7ece6ad

10 files changed

+125
-140
lines changed

t/t0410-partial-clone.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ test_expect_success 'convert shallow clone to partial clone' '
4949
test_cmp_config -C client 1 core.repositoryformatversion
5050
'
5151

52-
test_expect_success SHA1,REFFILES 'convert to partial clone with noop extension' '
52+
test_expect_success DEFAULT_REPO_FORMAT 'convert to partial clone with noop extension' '
5353
rm -fr server client &&
5454
test_create_repo server &&
5555
test_commit -C server my_commit 1 &&
@@ -60,7 +60,7 @@ test_expect_success SHA1,REFFILES 'convert to partial clone with noop extension'
6060
git -C client fetch --unshallow --filter="blob:none"
6161
'
6262

63-
test_expect_success SHA1,REFFILES 'converting to partial clone fails with unrecognized extension' '
63+
test_expect_success DEFAULT_REPO_FORMAT 'converting to partial clone fails with unrecognized extension' '
6464
rm -fr server client &&
6565
test_create_repo server &&
6666
test_commit -C server my_commit 1 &&

t/t0600-reffiles-backend.sh

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -381,4 +381,95 @@ test_expect_success 'log diagnoses bogus HEAD symref' '
381381
test_grep broken stderr
382382
'
383383

384+
test_expect_success 'empty directory removal' '
385+
git branch d1/d2/r1 HEAD &&
386+
git branch d1/r2 HEAD &&
387+
test_path_is_file .git/refs/heads/d1/d2/r1 &&
388+
test_path_is_file .git/logs/refs/heads/d1/d2/r1 &&
389+
git branch -d d1/d2/r1 &&
390+
test_must_fail git show-ref --verify -q refs/heads/d1/d2 &&
391+
test_must_fail git show-ref --verify -q logs/refs/heads/d1/d2 &&
392+
test_path_is_file .git/refs/heads/d1/r2 &&
393+
test_path_is_file .git/logs/refs/heads/d1/r2
394+
'
395+
396+
test_expect_success 'symref empty directory removal' '
397+
git branch e1/e2/r1 HEAD &&
398+
git branch e1/r2 HEAD &&
399+
git checkout e1/e2/r1 &&
400+
test_when_finished "git checkout main" &&
401+
test_path_is_file .git/refs/heads/e1/e2/r1 &&
402+
test_path_is_file .git/logs/refs/heads/e1/e2/r1 &&
403+
git update-ref -d HEAD &&
404+
test_must_fail git show-ref --verify -q refs/heads/e1/e2 &&
405+
test_must_fail git show-ref --verify -q logs/refs/heads/e1/e2 &&
406+
test_path_is_file .git/refs/heads/e1/r2 &&
407+
test_path_is_file .git/logs/refs/heads/e1/r2 &&
408+
test_path_is_file .git/logs/HEAD
409+
'
410+
411+
test_expect_success 'directory not created deleting packed ref' '
412+
git branch d1/d2/r1 HEAD &&
413+
git pack-refs --all &&
414+
test_path_is_missing .git/refs/heads/d1/d2 &&
415+
git update-ref -d refs/heads/d1/d2/r1 &&
416+
test_path_is_missing .git/refs/heads/d1/d2 &&
417+
test_path_is_missing .git/refs/heads/d1
418+
'
419+
420+
test_expect_success SYMLINKS 'git branch -m u v should fail when the reflog for u is a symlink' '
421+
git branch --create-reflog u &&
422+
mv .git/logs/refs/heads/u real-u &&
423+
ln -s real-u .git/logs/refs/heads/u &&
424+
test_must_fail git branch -m u v
425+
'
426+
427+
test_expect_success SYMLINKS 'git branch -m with symlinked .git/refs' '
428+
test_when_finished "rm -rf subdir" &&
429+
git init --bare subdir &&
430+
431+
rm -rfv subdir/refs subdir/objects subdir/packed-refs &&
432+
ln -s ../.git/refs subdir/refs &&
433+
ln -s ../.git/objects subdir/objects &&
434+
ln -s ../.git/packed-refs subdir/packed-refs &&
435+
436+
git -C subdir rev-parse --absolute-git-dir >subdir.dir &&
437+
git rev-parse --absolute-git-dir >our.dir &&
438+
! test_cmp subdir.dir our.dir &&
439+
440+
git -C subdir log &&
441+
git -C subdir branch rename-src &&
442+
git rev-parse rename-src >expect &&
443+
git -C subdir branch -m rename-src rename-dest &&
444+
git rev-parse rename-dest >actual &&
445+
test_cmp expect actual &&
446+
git branch -D rename-dest
447+
'
448+
449+
test_expect_success MINGW,SYMLINKS_WINDOWS 'rebase when .git/logs is a symlink' '
450+
git checkout main &&
451+
mv .git/logs actual_logs &&
452+
cmd //c "mklink /D .git\logs ..\actual_logs" &&
453+
git rebase -f HEAD^ &&
454+
test -L .git/logs &&
455+
rm .git/logs &&
456+
mv actual_logs .git/logs
457+
'
458+
459+
test_expect_success POSIXPERM 'git reflog expire honors core.sharedRepository' '
460+
umask 077 &&
461+
git config core.sharedRepository group &&
462+
git reflog expire --all &&
463+
actual="$(ls -l .git/logs/refs/heads/main)" &&
464+
case "$actual" in
465+
-rw-rw-*)
466+
: happy
467+
;;
468+
*)
469+
echo Ooops, .git/logs/refs/heads/main is not 066x [$actual]
470+
false
471+
;;
472+
esac
473+
'
474+
384475
test_done

t/t1301-shared-repo.sh

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -137,22 +137,6 @@ test_expect_success POSIXPERM 'info/refs respects umask in unshared repo' '
137137
test_cmp expect actual
138138
'
139139

140-
test_expect_success REFFILES,POSIXPERM 'git reflog expire honors core.sharedRepository' '
141-
umask 077 &&
142-
git config core.sharedRepository group &&
143-
git reflog expire --all &&
144-
actual="$(ls -l .git/logs/refs/heads/main)" &&
145-
case "$actual" in
146-
-rw-rw-*)
147-
: happy
148-
;;
149-
*)
150-
echo Ooops, .git/logs/refs/heads/main is not 066x [$actual]
151-
false
152-
;;
153-
esac
154-
'
155-
156140
test_expect_success POSIXPERM 'forced modes' '
157141
test_when_finished "rm -rf new" &&
158142
mkdir -p templates/hooks &&

t/t1400-update-ref.sh

Lines changed: 7 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -288,33 +288,6 @@ test_expect_success "set $m (logged by touch)" '
288288
test $A = $(git show-ref -s --verify $m)
289289
'
290290

291-
test_expect_success REFFILES 'empty directory removal' '
292-
git branch d1/d2/r1 HEAD &&
293-
git branch d1/r2 HEAD &&
294-
test_path_is_file .git/refs/heads/d1/d2/r1 &&
295-
test_path_is_file .git/logs/refs/heads/d1/d2/r1 &&
296-
git branch -d d1/d2/r1 &&
297-
test_must_fail git show-ref --verify -q refs/heads/d1/d2 &&
298-
test_must_fail git show-ref --verify -q logs/refs/heads/d1/d2 &&
299-
test_path_is_file .git/refs/heads/d1/r2 &&
300-
test_path_is_file .git/logs/refs/heads/d1/r2
301-
'
302-
303-
test_expect_success REFFILES 'symref empty directory removal' '
304-
git branch e1/e2/r1 HEAD &&
305-
git branch e1/r2 HEAD &&
306-
git checkout e1/e2/r1 &&
307-
test_when_finished "git checkout main" &&
308-
test_path_is_file .git/refs/heads/e1/e2/r1 &&
309-
test_path_is_file .git/logs/refs/heads/e1/e2/r1 &&
310-
git update-ref -d HEAD &&
311-
test_must_fail git show-ref --verify -q refs/heads/e1/e2 &&
312-
test_must_fail git show-ref --verify -q logs/refs/heads/e1/e2 &&
313-
test_path_is_file .git/refs/heads/e1/r2 &&
314-
test_path_is_file .git/logs/refs/heads/e1/r2 &&
315-
test_path_is_file .git/logs/HEAD
316-
'
317-
318291
cat >expect <<EOF
319292
$Z $A $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> 1117150200 +0000 Initial Creation
320293
$A $B $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> 1117150260 +0000 Switch
@@ -453,15 +426,15 @@ test_expect_success 'Query "main@{2005-05-28}" (past end of history)' '
453426
rm -f expect
454427
git update-ref -d $m
455428

456-
test_expect_success REFFILES 'query reflog with gap' '
429+
test_expect_success 'query reflog with gap' '
457430
test_when_finished "git update-ref -d $m" &&
458431
459-
git update-ref $m $F &&
460-
cat >.git/logs/$m <<-EOF &&
461-
$Z $A $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> 1117150320 -0500
462-
$A $B $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> 1117150380 -0500
463-
$D $F $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> 1117150680 -0500
464-
EOF
432+
GIT_COMMITTER_DATE="1117150320 -0500" git update-ref $m $A &&
433+
GIT_COMMITTER_DATE="1117150380 -0500" git update-ref $m $B &&
434+
GIT_COMMITTER_DATE="1117150480 -0500" git update-ref $m $C &&
435+
GIT_COMMITTER_DATE="1117150580 -0500" git update-ref $m $D &&
436+
GIT_COMMITTER_DATE="1117150680 -0500" git update-ref $m $F &&
437+
git reflog delete $m@{2} &&
465438
466439
git rev-parse --verify "main@{2005-05-26 23:33:01}" >actual 2>stderr &&
467440
echo "$B" >expect &&
@@ -1668,13 +1641,4 @@ test_expect_success PIPE 'transaction flushes status updates' '
16681641
test_cmp expected actual
16691642
'
16701643

1671-
test_expect_success REFFILES 'directory not created deleting packed ref' '
1672-
git branch d1/d2/r1 HEAD &&
1673-
git pack-refs --all &&
1674-
test_path_is_missing .git/refs/heads/d1/d2 &&
1675-
git update-ref -d refs/heads/d1/d2/r1 &&
1676-
test_path_is_missing .git/refs/heads/d1/d2 &&
1677-
test_path_is_missing .git/refs/heads/d1
1678-
'
1679-
16801644
test_done

t/t1404-update-ref-errors.sh

Lines changed: 17 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -92,9 +92,6 @@ df_test() {
9292
else
9393
delname="$delref"
9494
fi &&
95-
cat >expected-err <<-EOF &&
96-
fatal: cannot lock ref $SQ$addname$SQ: $SQ$delref$SQ exists; cannot create $SQ$addref$SQ
97-
EOF
9895
$pack &&
9996
if $add_del
10097
then
@@ -103,7 +100,7 @@ df_test() {
103100
printf "%s\n" "delete $delname" "create $addname $D"
104101
fi >commands &&
105102
test_must_fail git update-ref --stdin <commands 2>output.err &&
106-
test_cmp expected-err output.err &&
103+
grep "fatal:\( cannot lock ref $SQ$addname$SQ:\)\? $SQ$delref$SQ exists; cannot create $SQ$addref$SQ" output.err &&
107104
printf "%s\n" "$C $delref" >expected-refs &&
108105
git for-each-ref --format="%(objectname) %(refname)" $prefix/r >actual-refs &&
109106
test_cmp expected-refs actual-refs
@@ -191,69 +188,69 @@ test_expect_success 'one new ref is a simple prefix of another' '
191188
192189
'
193190

194-
test_expect_success REFFILES 'D/F conflict prevents add long + delete short' '
191+
test_expect_success 'D/F conflict prevents add long + delete short' '
195192
df_test refs/df-al-ds --add-del foo/bar foo
196193
'
197194

198-
test_expect_success REFFILES 'D/F conflict prevents add short + delete long' '
195+
test_expect_success 'D/F conflict prevents add short + delete long' '
199196
df_test refs/df-as-dl --add-del foo foo/bar
200197
'
201198

202-
test_expect_success REFFILES 'D/F conflict prevents delete long + add short' '
199+
test_expect_success 'D/F conflict prevents delete long + add short' '
203200
df_test refs/df-dl-as --del-add foo/bar foo
204201
'
205202

206-
test_expect_success REFFILES 'D/F conflict prevents delete short + add long' '
203+
test_expect_success 'D/F conflict prevents delete short + add long' '
207204
df_test refs/df-ds-al --del-add foo foo/bar
208205
'
209206

210-
test_expect_success REFFILES 'D/F conflict prevents add long + delete short packed' '
207+
test_expect_success 'D/F conflict prevents add long + delete short packed' '
211208
df_test refs/df-al-dsp --pack --add-del foo/bar foo
212209
'
213210

214-
test_expect_success REFFILES 'D/F conflict prevents add short + delete long packed' '
211+
test_expect_success 'D/F conflict prevents add short + delete long packed' '
215212
df_test refs/df-as-dlp --pack --add-del foo foo/bar
216213
'
217214

218-
test_expect_success REFFILES 'D/F conflict prevents delete long packed + add short' '
215+
test_expect_success 'D/F conflict prevents delete long packed + add short' '
219216
df_test refs/df-dlp-as --pack --del-add foo/bar foo
220217
'
221218

222-
test_expect_success REFFILES 'D/F conflict prevents delete short packed + add long' '
219+
test_expect_success 'D/F conflict prevents delete short packed + add long' '
223220
df_test refs/df-dsp-al --pack --del-add foo foo/bar
224221
'
225222

226223
# Try some combinations involving symbolic refs...
227224

228-
test_expect_success REFFILES 'D/F conflict prevents indirect add long + delete short' '
225+
test_expect_success 'D/F conflict prevents indirect add long + delete short' '
229226
df_test refs/df-ial-ds --sym-add --add-del foo/bar foo
230227
'
231228

232-
test_expect_success REFFILES 'D/F conflict prevents indirect add long + indirect delete short' '
229+
test_expect_success 'D/F conflict prevents indirect add long + indirect delete short' '
233230
df_test refs/df-ial-ids --sym-add --sym-del --add-del foo/bar foo
234231
'
235232

236-
test_expect_success REFFILES 'D/F conflict prevents indirect add short + indirect delete long' '
233+
test_expect_success 'D/F conflict prevents indirect add short + indirect delete long' '
237234
df_test refs/df-ias-idl --sym-add --sym-del --add-del foo foo/bar
238235
'
239236

240-
test_expect_success REFFILES 'D/F conflict prevents indirect delete long + indirect add short' '
237+
test_expect_success 'D/F conflict prevents indirect delete long + indirect add short' '
241238
df_test refs/df-idl-ias --sym-add --sym-del --del-add foo/bar foo
242239
'
243240

244-
test_expect_success REFFILES 'D/F conflict prevents indirect add long + delete short packed' '
241+
test_expect_success 'D/F conflict prevents indirect add long + delete short packed' '
245242
df_test refs/df-ial-dsp --sym-add --pack --add-del foo/bar foo
246243
'
247244

248-
test_expect_success REFFILES 'D/F conflict prevents indirect add long + indirect delete short packed' '
245+
test_expect_success 'D/F conflict prevents indirect add long + indirect delete short packed' '
249246
df_test refs/df-ial-idsp --sym-add --sym-del --pack --add-del foo/bar foo
250247
'
251248

252-
test_expect_success REFFILES 'D/F conflict prevents add long + indirect delete short packed' '
249+
test_expect_success 'D/F conflict prevents add long + indirect delete short packed' '
253250
df_test refs/df-al-idsp --sym-del --pack --add-del foo/bar foo
254251
'
255252

256-
test_expect_success REFFILES 'D/F conflict prevents indirect delete long packed + indirect add short' '
253+
test_expect_success 'D/F conflict prevents indirect delete long packed + indirect add short' '
257254
df_test refs/df-idlp-ias --sym-add --sym-del --pack --del-add foo/bar foo
258255
'
259256

t/t1405-main-ref-store.sh

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,6 @@ test_expect_success 'delete_refs(FOO, refs/tags/new-tag)' '
3333
test_must_fail git rev-parse refs/tags/new-tag --
3434
'
3535

36-
# In reftable, we keep the reflogs around for deleted refs.
37-
test_expect_success !REFFILES 'delete-reflog(FOO, refs/tags/new-tag)' '
38-
$RUN delete-reflog FOO &&
39-
$RUN delete-reflog refs/tags/new-tag
40-
'
41-
4236
test_expect_success 'rename_refs(main, new-main)' '
4337
git rev-parse main >expected &&
4438
$RUN rename-ref refs/heads/main refs/heads/new-main &&

t/t2011-checkout-invalid-head.sh

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -29,36 +29,33 @@ test_expect_success REFFILES 'checkout notices failure to lock HEAD' '
2929
test_must_fail git checkout -b other
3030
'
3131

32-
test_expect_success REFFILES 'create ref directory/file conflict scenario' '
32+
test_expect_success 'create ref directory/file conflict scenario' '
3333
git update-ref refs/heads/outer/inner main &&
34-
35-
# do not rely on symbolic-ref to get a known state,
36-
# as it may use the same code we are testing
3734
reset_to_df () {
38-
echo "ref: refs/heads/outer" >.git/HEAD
35+
git symbolic-ref HEAD refs/heads/outer
3936
}
4037
'
4138

42-
test_expect_success REFFILES 'checkout away from d/f HEAD (unpacked, to branch)' '
39+
test_expect_success 'checkout away from d/f HEAD (unpacked, to branch)' '
4340
reset_to_df &&
4441
git checkout main
4542
'
4643

47-
test_expect_success REFFILES 'checkout away from d/f HEAD (unpacked, to detached)' '
44+
test_expect_success 'checkout away from d/f HEAD (unpacked, to detached)' '
4845
reset_to_df &&
4946
git checkout --detach main
5047
'
5148

52-
test_expect_success REFFILES 'pack refs' '
49+
test_expect_success 'pack refs' '
5350
git pack-refs --all --prune
5451
'
5552

56-
test_expect_success REFFILES 'checkout away from d/f HEAD (packed, to branch)' '
53+
test_expect_success 'checkout away from d/f HEAD (packed, to branch)' '
5754
reset_to_df &&
5855
git checkout main
5956
'
6057

61-
test_expect_success REFFILES 'checkout away from d/f HEAD (packed, to detached)' '
58+
test_expect_success 'checkout away from d/f HEAD (packed, to detached)' '
6259
reset_to_df &&
6360
git checkout --detach main
6461
'

0 commit comments

Comments
 (0)