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
This commit is contained in:
Junio C Hamano 2018-06-01 15:06:41 +09:00
commit d6e5484208
11 changed files with 28 additions and 27 deletions

View File

@ -4,11 +4,11 @@ mkdir -p .git/refs/tags
>sed.script >sed.script
# Answer the sha1 has associated with the tag. The tag must exist in .git/refs/tags # Answer the sha1 has associated with the tag. The tag must exist under refs/tags
tag () { tag () {
_tag=$1 _tag=$1
test -f ".git/refs/tags/$_tag" || error "tag: \"$_tag\" does not exist" git rev-parse --verify "refs/tags/$_tag" ||
cat ".git/refs/tags/$_tag" error "tag: \"$_tag\" does not exist"
} }
# Generate a commit using the text specified to make it unique and the tree # Generate a commit using the text specified to make it unique and the tree

View File

@ -65,7 +65,7 @@ reset_to_sane
test_expect_success 'symbolic-ref fails to delete real ref' ' test_expect_success 'symbolic-ref fails to delete real ref' '
echo "fatal: Cannot delete refs/heads/foo, not a symbolic ref" >expect && echo "fatal: Cannot delete refs/heads/foo, not a symbolic ref" >expect &&
test_must_fail git symbolic-ref -d refs/heads/foo >actual 2>&1 && test_must_fail git symbolic-ref -d refs/heads/foo >actual 2>&1 &&
test_path_is_file .git/refs/heads/foo && git rev-parse --verify refs/heads/foo &&
test_cmp expect actual test_cmp expect actual
' '
reset_to_sane reset_to_sane

View File

@ -234,34 +234,34 @@ test_expect_success 'git branch -M master2 master2 should work when master is ch
test_expect_success 'git branch -v -d t should work' ' test_expect_success 'git branch -v -d t should work' '
git branch t && git branch t &&
test_path_is_file .git/refs/heads/t && git rev-parse --verify refs/heads/t &&
git branch -v -d t && git branch -v -d t &&
test_path_is_missing .git/refs/heads/t test_must_fail git rev-parse --verify refs/heads/t
' '
test_expect_success 'git branch -v -m t s should work' ' test_expect_success 'git branch -v -m t s should work' '
git branch t && git branch t &&
test_path_is_file .git/refs/heads/t && git rev-parse --verify refs/heads/t &&
git branch -v -m t s && git branch -v -m t s &&
test_path_is_missing .git/refs/heads/t && test_must_fail git rev-parse --verify refs/heads/t &&
test_path_is_file .git/refs/heads/s && git rev-parse --verify refs/heads/s &&
git branch -d s git branch -d s
' '
test_expect_success 'git branch -m -d t s should fail' ' test_expect_success 'git branch -m -d t s should fail' '
git branch t && git branch t &&
test_path_is_file .git/refs/heads/t && git rev-parse refs/heads/t &&
test_must_fail git branch -m -d t s && test_must_fail git branch -m -d t s &&
git branch -d t && git branch -d t &&
test_path_is_missing .git/refs/heads/t test_must_fail git rev-parse refs/heads/t
' '
test_expect_success 'git branch --list -d t should fail' ' test_expect_success 'git branch --list -d t should fail' '
git branch t && git branch t &&
test_path_is_file .git/refs/heads/t && git rev-parse refs/heads/t &&
test_must_fail git branch --list -d t && test_must_fail git branch --list -d t &&
git branch -d t && git branch -d t &&
test_path_is_missing .git/refs/heads/t test_must_fail git rev-parse refs/heads/t
' '
test_expect_success 'git branch --list -v with --abbrev' ' test_expect_success 'git branch --list -v with --abbrev' '

View File

@ -726,7 +726,7 @@ test_expect_success 'store updates stash ref and reflog' '
git reset --hard && git reset --hard &&
! grep quux bazzy && ! grep quux bazzy &&
git stash store -m quuxery $STASH_ID && git stash store -m quuxery $STASH_ID &&
test $(cat .git/refs/stash) = $STASH_ID && test $(git rev-parse stash) = $STASH_ID &&
git reflog --format=%H stash| grep $STASH_ID && git reflog --format=%H stash| grep $STASH_ID &&
git stash pop && git stash pop &&
grep quux bazzy grep quux bazzy

View File

@ -30,7 +30,7 @@ add () {
test_tick && test_tick &&
commit=$(echo "$text" | git commit-tree $tree $parents) && commit=$(echo "$text" | git commit-tree $tree $parents) &&
eval "$name=$commit; export $name" && eval "$name=$commit; export $name" &&
echo $commit > .git/refs/heads/$branch && git update-ref "refs/heads/$branch" "$commit" &&
eval ${branch}TIP=$commit eval ${branch}TIP=$commit
} }
@ -45,10 +45,10 @@ pull_to_client () {
case "$heads" in case "$heads" in
*A*) *A*)
echo $ATIP > .git/refs/heads/A;; git update-ref refs/heads/A "$ATIP";;
esac && esac &&
case "$heads" in *B*) case "$heads" in *B*)
echo $BTIP > .git/refs/heads/B;; git update-ref refs/heads/B "$BTIP";;
esac && esac &&
git symbolic-ref HEAD refs/heads/$(echo $heads \ git symbolic-ref HEAD refs/heads/$(echo $heads \
| sed -e "s/^\(.\).*$/\1/") && | sed -e "s/^\(.\).*$/\1/") &&
@ -92,8 +92,8 @@ test_expect_success 'setup' '
cur=$(($cur+1)) cur=$(($cur+1))
done && done &&
add B1 $A1 && add B1 $A1 &&
echo $ATIP > .git/refs/heads/A && git update-ref refs/heads/A "$ATIP" &&
echo $BTIP > .git/refs/heads/B && git update-ref refs/heads/B "$BTIP" &&
git symbolic-ref HEAD refs/heads/B git symbolic-ref HEAD refs/heads/B
' '

View File

@ -63,7 +63,7 @@ test_expect_success "fetch test" '
git commit -a -m "updated by origin" && git commit -a -m "updated by origin" &&
cd two && cd two &&
git fetch && git fetch &&
test -f .git/refs/heads/one && git rev-parse --verify refs/heads/one &&
mine=$(git rev-parse refs/heads/one) && mine=$(git rev-parse refs/heads/one) &&
his=$(cd ../one && git rev-parse refs/heads/master) && his=$(cd ../one && git rev-parse refs/heads/master) &&
test "z$mine" = "z$his" test "z$mine" = "z$his"
@ -73,8 +73,8 @@ test_expect_success "fetch test for-merge" '
cd "$D" && cd "$D" &&
cd three && cd three &&
git fetch && git fetch &&
test -f .git/refs/heads/two && git rev-parse --verify refs/heads/two &&
test -f .git/refs/heads/one && git rev-parse --verify refs/heads/one &&
master_in_two=$(cd ../two && git rev-parse master) && master_in_two=$(cd ../two && git rev-parse master) &&
one_in_two=$(cd ../two && git rev-parse one) && one_in_two=$(cd ../two && git rev-parse one) &&
{ {

View File

@ -34,7 +34,7 @@ doit () {
commit=$(echo $NAME | git commit-tree $T $PARENTS) && commit=$(echo $NAME | git commit-tree $T $PARENTS) &&
echo $commit >.git/refs/tags/$NAME && git update-ref "refs/tags/$NAME" "$commit" &&
echo $commit echo $commit
} }

View File

@ -65,7 +65,7 @@ test_expect_success setup '
test_expect_success "checkout from non-existing branch" ' test_expect_success "checkout from non-existing branch" '
git checkout -b delete-me master && git checkout -b delete-me master &&
rm .git/refs/heads/delete-me && git update-ref -d --no-deref refs/heads/delete-me &&
test refs/heads/delete-me = "$(git symbolic-ref HEAD)" && test refs/heads/delete-me = "$(git symbolic-ref HEAD)" &&
git checkout master && git checkout master &&
test refs/heads/master = "$(git symbolic-ref HEAD)" test refs/heads/master = "$(git symbolic-ref HEAD)"

View File

@ -215,7 +215,8 @@ test_expect_success "multi-fetch continues to work" "
" "
test_expect_success "multi-fetch works off a 'clean' repository" ' test_expect_success "multi-fetch works off a 'clean' repository" '
rm -r "$GIT_DIR/svn" "$GIT_DIR/refs/remotes" "$GIT_DIR/logs" && rm -rf "$GIT_DIR/svn" "$GIT_DIR/refs/remotes" &&
git reflog expire --all --expire=all &&
mkdir "$GIT_DIR/svn" && mkdir "$GIT_DIR/svn" &&
git svn multi-fetch git svn multi-fetch
' '

View File

@ -181,7 +181,7 @@ test_expect_success '__git_find_repo_path - cwd is a .git directory' '
test_expect_success '__git_find_repo_path - parent is a .git directory' ' test_expect_success '__git_find_repo_path - parent is a .git directory' '
echo "$ROOT/.git" >expected && echo "$ROOT/.git" >expected &&
( (
cd .git/refs/heads && cd .git/objects &&
__git_find_repo_path && __git_find_repo_path &&
echo "$__git_repo_path" >"$actual" echo "$__git_repo_path" >"$actual"
) && ) &&

View File

@ -148,7 +148,7 @@ test_expect_success 'prompt - inside .git directory' '
test_expect_success 'prompt - deep inside .git directory' ' test_expect_success 'prompt - deep inside .git directory' '
printf " (GIT_DIR!)" >expected && printf " (GIT_DIR!)" >expected &&
( (
cd .git/refs/heads && cd .git/objects &&
__git_ps1 >"$actual" __git_ps1 >"$actual"
) && ) &&
test_cmp expected "$actual" test_cmp expected "$actual"