Skip to content

Commit d6e5484

Browse files
committed
Merge branch 'cc/tests-without-assuming-ref-files-backend'
Quite a many tests assumed that newly created refs are made as loose refs using the files backend, which have been updated to use proper plumbing like rev-parse and update-ref, to avoid breakage once we start using different ref backends. * cc/tests-without-assuming-ref-files-backend: t990X: use '.git/objects' as 'deep inside .git' path t: make many tests depend less on the refs being files
2 parents ba928e9 + 5340d47 commit d6e5484

11 files changed

+28
-27
lines changed

t/lib-t6000.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@ mkdir -p .git/refs/tags
44

55
>sed.script
66

7-
# Answer the sha1 has associated with the tag. The tag must exist in .git/refs/tags
7+
# Answer the sha1 has associated with the tag. The tag must exist under refs/tags
88
tag () {
99
_tag=$1
10-
test -f ".git/refs/tags/$_tag" || error "tag: \"$_tag\" does not exist"
11-
cat ".git/refs/tags/$_tag"
10+
git rev-parse --verify "refs/tags/$_tag" ||
11+
error "tag: \"$_tag\" does not exist"
1212
}
1313

1414
# Generate a commit using the text specified to make it unique and the tree

t/t1401-symbolic-ref.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ reset_to_sane
6565
test_expect_success 'symbolic-ref fails to delete real ref' '
6666
echo "fatal: Cannot delete refs/heads/foo, not a symbolic ref" >expect &&
6767
test_must_fail git symbolic-ref -d refs/heads/foo >actual 2>&1 &&
68-
test_path_is_file .git/refs/heads/foo &&
68+
git rev-parse --verify refs/heads/foo &&
6969
test_cmp expect actual
7070
'
7171
reset_to_sane

t/t3200-branch.sh

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -234,34 +234,34 @@ test_expect_success 'git branch -M master2 master2 should work when master is ch
234234

235235
test_expect_success 'git branch -v -d t should work' '
236236
git branch t &&
237-
test_path_is_file .git/refs/heads/t &&
237+
git rev-parse --verify refs/heads/t &&
238238
git branch -v -d t &&
239-
test_path_is_missing .git/refs/heads/t
239+
test_must_fail git rev-parse --verify refs/heads/t
240240
'
241241

242242
test_expect_success 'git branch -v -m t s should work' '
243243
git branch t &&
244-
test_path_is_file .git/refs/heads/t &&
244+
git rev-parse --verify refs/heads/t &&
245245
git branch -v -m t s &&
246-
test_path_is_missing .git/refs/heads/t &&
247-
test_path_is_file .git/refs/heads/s &&
246+
test_must_fail git rev-parse --verify refs/heads/t &&
247+
git rev-parse --verify refs/heads/s &&
248248
git branch -d s
249249
'
250250

251251
test_expect_success 'git branch -m -d t s should fail' '
252252
git branch t &&
253-
test_path_is_file .git/refs/heads/t &&
253+
git rev-parse refs/heads/t &&
254254
test_must_fail git branch -m -d t s &&
255255
git branch -d t &&
256-
test_path_is_missing .git/refs/heads/t
256+
test_must_fail git rev-parse refs/heads/t
257257
'
258258

259259
test_expect_success 'git branch --list -d t should fail' '
260260
git branch t &&
261-
test_path_is_file .git/refs/heads/t &&
261+
git rev-parse refs/heads/t &&
262262
test_must_fail git branch --list -d t &&
263263
git branch -d t &&
264-
test_path_is_missing .git/refs/heads/t
264+
test_must_fail git rev-parse refs/heads/t
265265
'
266266

267267
test_expect_success 'git branch --list -v with --abbrev' '

t/t3903-stash.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -726,7 +726,7 @@ test_expect_success 'store updates stash ref and reflog' '
726726
git reset --hard &&
727727
! grep quux bazzy &&
728728
git stash store -m quuxery $STASH_ID &&
729-
test $(cat .git/refs/stash) = $STASH_ID &&
729+
test $(git rev-parse stash) = $STASH_ID &&
730730
git reflog --format=%H stash| grep $STASH_ID &&
731731
git stash pop &&
732732
grep quux bazzy

t/t5500-fetch-pack.sh

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ add () {
3030
test_tick &&
3131
commit=$(echo "$text" | git commit-tree $tree $parents) &&
3232
eval "$name=$commit; export $name" &&
33-
echo $commit > .git/refs/heads/$branch &&
33+
git update-ref "refs/heads/$branch" "$commit" &&
3434
eval ${branch}TIP=$commit
3535
}
3636

@@ -45,10 +45,10 @@ pull_to_client () {
4545
4646
case "$heads" in
4747
*A*)
48-
echo $ATIP > .git/refs/heads/A;;
48+
git update-ref refs/heads/A "$ATIP";;
4949
esac &&
5050
case "$heads" in *B*)
51-
echo $BTIP > .git/refs/heads/B;;
51+
git update-ref refs/heads/B "$BTIP";;
5252
esac &&
5353
git symbolic-ref HEAD refs/heads/$(echo $heads \
5454
| sed -e "s/^\(.\).*$/\1/") &&
@@ -92,8 +92,8 @@ test_expect_success 'setup' '
9292
cur=$(($cur+1))
9393
done &&
9494
add B1 $A1 &&
95-
echo $ATIP > .git/refs/heads/A &&
96-
echo $BTIP > .git/refs/heads/B &&
95+
git update-ref refs/heads/A "$ATIP" &&
96+
git update-ref refs/heads/B "$BTIP" &&
9797
git symbolic-ref HEAD refs/heads/B
9898
'
9999

t/t5510-fetch.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ test_expect_success "fetch test" '
6363
git commit -a -m "updated by origin" &&
6464
cd two &&
6565
git fetch &&
66-
test -f .git/refs/heads/one &&
66+
git rev-parse --verify refs/heads/one &&
6767
mine=$(git rev-parse refs/heads/one) &&
6868
his=$(cd ../one && git rev-parse refs/heads/master) &&
6969
test "z$mine" = "z$his"
@@ -73,8 +73,8 @@ test_expect_success "fetch test for-merge" '
7373
cd "$D" &&
7474
cd three &&
7575
git fetch &&
76-
test -f .git/refs/heads/two &&
77-
test -f .git/refs/heads/one &&
76+
git rev-parse --verify refs/heads/two &&
77+
git rev-parse --verify refs/heads/one &&
7878
master_in_two=$(cd ../two && git rev-parse master) &&
7979
one_in_two=$(cd ../two && git rev-parse one) &&
8080
{

t/t6010-merge-base.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ doit () {
3434

3535
commit=$(echo $NAME | git commit-tree $T $PARENTS) &&
3636

37-
echo $commit >.git/refs/tags/$NAME &&
37+
git update-ref "refs/tags/$NAME" "$commit" &&
3838
echo $commit
3939
}
4040

t/t7201-co.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ test_expect_success setup '
6565
test_expect_success "checkout from non-existing branch" '
6666
6767
git checkout -b delete-me master &&
68-
rm .git/refs/heads/delete-me &&
68+
git update-ref -d --no-deref refs/heads/delete-me &&
6969
test refs/heads/delete-me = "$(git symbolic-ref HEAD)" &&
7070
git checkout master &&
7171
test refs/heads/master = "$(git symbolic-ref HEAD)"

t/t9104-git-svn-follow-parent.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,8 @@ test_expect_success "multi-fetch continues to work" "
215215
"
216216

217217
test_expect_success "multi-fetch works off a 'clean' repository" '
218-
rm -r "$GIT_DIR/svn" "$GIT_DIR/refs/remotes" "$GIT_DIR/logs" &&
218+
rm -rf "$GIT_DIR/svn" "$GIT_DIR/refs/remotes" &&
219+
git reflog expire --all --expire=all &&
219220
mkdir "$GIT_DIR/svn" &&
220221
git svn multi-fetch
221222
'

t/t9902-completion.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ test_expect_success '__git_find_repo_path - cwd is a .git directory' '
181181
test_expect_success '__git_find_repo_path - parent is a .git directory' '
182182
echo "$ROOT/.git" >expected &&
183183
(
184-
cd .git/refs/heads &&
184+
cd .git/objects &&
185185
__git_find_repo_path &&
186186
echo "$__git_repo_path" >"$actual"
187187
) &&

0 commit comments

Comments
 (0)