Skip to content

Commit 276bc63

Browse files
committed
Merge branch 'hn/refs-test-cleanup'
A handful of tests that assumed implementation details of files backend for refs have been cleaned up. * hn/refs-test-cleanup: t6001: avoid direct file system access t6500: use "ls -1" to snapshot ref database state t7064: use update-ref -d to remove upstream branch t1410: mark test as REFFILES t1405: mark test for 'git pack-refs' as REFFILES t1405: use 'git reflog exists' to check reflog existence t2402: use ref-store test helper to create broken symlink t3320: use git-symbolic-ref rather than filesystem access t6120: use git-update-ref rather than filesystem access t1503: mark symlink test as REFFILES t6050: use git-update-ref rather than filesystem access
2 parents 08ac213 + 977f8ac commit 276bc63

10 files changed

+35
-24
lines changed

t/t1405-main-ref-store.sh

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,18 @@ export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
99

1010
RUN="test-tool ref-store main"
1111

12-
test_expect_success 'pack_refs(PACK_REFS_ALL | PACK_REFS_PRUNE)' '
13-
test_commit one &&
12+
13+
test_expect_success 'setup' '
14+
test_commit one
15+
'
16+
17+
test_expect_success REFFILES 'pack_refs(PACK_REFS_ALL | PACK_REFS_PRUNE)' '
1418
N=`find .git/refs -type f | wc -l` &&
1519
test "$N" != 0 &&
16-
$RUN pack-refs 3 &&
17-
N=`find .git/refs -type f | wc -l`
20+
ALL_OR_PRUNE_FLAG=3 &&
21+
$RUN pack-refs ${ALL_OR_PRUNE_FLAG} &&
22+
N=`find .git/refs -type f` &&
23+
test -z "$N"
1824
'
1925

2026
test_expect_success 'create_symref(FOO, refs/heads/main)' '
@@ -98,12 +104,12 @@ test_expect_success 'reflog_exists(HEAD)' '
98104

99105
test_expect_success 'delete_reflog(HEAD)' '
100106
$RUN delete-reflog HEAD &&
101-
! test -f .git/logs/HEAD
107+
test_must_fail git reflog exists HEAD
102108
'
103109

104110
test_expect_success 'create-reflog(HEAD)' '
105111
$RUN create-reflog HEAD 1 &&
106-
test -f .git/logs/HEAD
112+
git reflog exists HEAD
107113
'
108114

109115
test_expect_success 'delete_ref(refs/heads/foo)' '

t/t1410-reflog.sh

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -374,7 +374,9 @@ test_expect_failure 'reflog with non-commit entries displays all entries' '
374374
test_line_count = 3 actual
375375
'
376376

377-
test_expect_success 'reflog expire operates on symref not referrent' '
377+
# This test takes a lock on an individual ref; this is not supported in
378+
# reftable.
379+
test_expect_success REFFILES 'reflog expire operates on symref not referrent' '
378380
git branch --create-reflog the_symref &&
379381
git branch --create-reflog referrent &&
380382
git update-ref referrent HEAD &&

t/t1503-rev-parse-verify.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ test_expect_success 'main@{n} for various n' '
142142
test_must_fail git rev-parse --verify main@{$Np1}
143143
'
144144

145-
test_expect_success SYMLINKS 'ref resolution not confused by broken symlinks' '
145+
test_expect_success SYMLINKS,REFFILES 'ref resolution not confused by broken symlinks' '
146146
ln -s does-not-exist .git/refs/heads/broken &&
147147
test_must_fail git rev-parse --verify broken
148148
'

t/t2402-worktree-list.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ test_expect_success 'broken main worktree still at the top' '
230230
EOF
231231
cd linked &&
232232
echo "worktree $(pwd)" >expected &&
233-
echo "ref: .broken" >../.git/HEAD &&
233+
(cd ../ && test-tool ref-store main create-symref HEAD .broken ) &&
234234
git worktree list --porcelain >out &&
235235
head -n 3 out >actual &&
236236
test_cmp ../expected actual &&

t/t3320-notes-merge-worktrees.sh

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,9 @@ test_expect_success 'create some new worktrees' '
4646
test_expect_success 'merge z into y fails and sets NOTES_MERGE_REF' '
4747
git config core.notesRef refs/notes/y &&
4848
test_must_fail git notes merge z &&
49-
echo "ref: refs/notes/y" >expect &&
50-
test_cmp expect .git/NOTES_MERGE_REF
49+
echo "refs/notes/y" >expect &&
50+
git symbolic-ref NOTES_MERGE_REF >actual &&
51+
test_cmp expect actual
5152
'
5253

5354
test_expect_success 'merge z into y while mid-merge in another workdir fails' '
@@ -57,7 +58,7 @@ test_expect_success 'merge z into y while mid-merge in another workdir fails' '
5758
test_must_fail git notes merge z 2>err &&
5859
test_i18ngrep "a notes merge into refs/notes/y is already in-progress at" err
5960
) &&
60-
test_path_is_missing .git/worktrees/worktree/NOTES_MERGE_REF
61+
test_must_fail git -C worktree symbolic-ref NOTES_MERGE_REF
6162
'
6263

6364
test_expect_success 'merge z into x while mid-merge on y succeeds' '
@@ -68,8 +69,9 @@ test_expect_success 'merge z into x while mid-merge on y succeeds' '
6869
test_i18ngrep "Automatic notes merge failed" out &&
6970
grep -v "A notes merge into refs/notes/x is already in-progress in" out
7071
) &&
71-
echo "ref: refs/notes/x" >expect &&
72-
test_cmp expect .git/worktrees/worktree2/NOTES_MERGE_REF
72+
echo "refs/notes/x" >expect &&
73+
git -C worktree2 symbolic-ref NOTES_MERGE_REF >actual &&
74+
test_cmp expect actual
7375
'
7476

7577
test_done

t/t6001-rev-list-graft.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@ test_expect_success setup '
2323
git commit -a -m "Third in one history." &&
2424
A2=$(git rev-parse --verify HEAD) &&
2525
26-
rm -f .git/refs/heads/main .git/index &&
26+
git update-ref -d refs/heads/main &&
27+
rm -f .git/index &&
2728
2829
echo >fileA fileA again &&
2930
echo >subdir/fileB fileB again &&

t/t6050-replace.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ tagger T A Gger <> 0 +0000
132132
EOF
133133

134134
test_expect_success 'tag replaced commit' '
135-
git mktag <tag.sig >.git/refs/tags/mytag
135+
git update-ref refs/tags/mytag $(git mktag <tag.sig)
136136
'
137137

138138
test_expect_success '"git fsck" works' '

t/t6120-describe.sh

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,8 @@ test_expect_success 'describe --contains defaults to HEAD without commit-ish' '
107107
check_describe tags/A --all A^0
108108

109109
test_expect_success 'renaming tag A to Q locally produces a warning' "
110-
mv .git/refs/tags/A .git/refs/tags/Q &&
110+
git update-ref refs/tags/Q $(git rev-parse refs/tags/A) &&
111+
git update-ref -d refs/tags/A &&
111112
git describe HEAD 2>err >out &&
112113
cat >expected <<-\EOF &&
113114
warning: tag 'Q' is externally known as 'A'
@@ -135,7 +136,8 @@ test_expect_success 'abbrev=0 will not break misplaced tag (2)' '
135136
'
136137

137138
test_expect_success 'rename tag Q back to A' '
138-
mv .git/refs/tags/Q .git/refs/tags/A
139+
git update-ref refs/tags/A $(git rev-parse refs/tags/Q) &&
140+
git update-ref -d refs/tags/Q
139141
'
140142

141143
test_expect_success 'pack tag refs' 'git pack-refs'

t/t6500-gc.sh

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ test_expect_success 'background auto gc respects lock for all operations' '
241241
242242
# create a ref whose loose presence we can use to detect a pack-refs run
243243
git update-ref refs/heads/should-be-loose HEAD &&
244-
test_path_is_file .git/refs/heads/should-be-loose &&
244+
(ls -1 .git/refs/heads .git/reftable >expect || true) &&
245245
246246
# now fake a concurrent gc that holds the lock; we can use our
247247
# shell pid so that it looks valid.
@@ -258,7 +258,8 @@ test_expect_success 'background auto gc respects lock for all operations' '
258258
259259
# our gc should exit zero without doing anything
260260
run_and_wait_for_auto_gc &&
261-
test_path_is_file .git/refs/heads/should-be-loose
261+
(ls -1 .git/refs/heads .git/reftable >actual || true) &&
262+
test_cmp expect actual
262263
'
263264

264265
# DO NOT leave a detached auto gc process running near the end of the

t/t7064-wtstatus-pv2.sh

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -373,10 +373,7 @@ test_expect_success 'verify upstream fields in branch header' '
373373
374374
## Test upstream-gone case. Fake this by pointing
375375
## origin/initial-branch at a non-existing commit.
376-
OLD=$(git rev-parse origin/initial-branch) &&
377-
NEW=$ZERO_OID &&
378-
mv .git/packed-refs .git/old-packed-refs &&
379-
sed "s/$OLD/$NEW/g" <.git/old-packed-refs >.git/packed-refs &&
376+
git update-ref -d refs/remotes/origin/initial-branch &&
380377
381378
HUF=$(git rev-parse HEAD) &&
382379

0 commit comments

Comments
 (0)