Merge branch 'ps/ref-tests-update'

Update ref-related tests.

* ps/ref-tests-update:
  t: mark several tests that assume the files backend with REFFILES
  t7900: assert the absence of refs via git-for-each-ref(1)
  t7300: assert exact states of repo
  t4207: delete replace references via git-update-ref(1)
  t1450: convert tests to remove worktrees via git-worktree(1)
  t: convert tests to not access reflog via the filesystem
  t: convert tests to not access symrefs via the filesystem
  t: convert tests to not write references via the filesystem
  t: allow skipping expected object ID in `ref-store update-ref`
This commit is contained in:
Junio C Hamano
2023-12-09 16:37:49 -08:00
17 changed files with 142 additions and 108 deletions

View File

@ -221,7 +221,9 @@ test_expect_success 'clone of empty repo propagates name of default branch' '
GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME= \
git -c init.defaultBranch=main -c protocol.version=2 \
clone "file://$(pwd)/file_empty_parent" file_empty_child &&
grep "refs/heads/mydefaultbranch" file_empty_child/.git/HEAD
echo refs/heads/mydefaultbranch >expect &&
git -C file_empty_child symbolic-ref HEAD >actual &&
test_cmp expect actual
'
test_expect_success '...but not if explicitly forbidden by config' '
@ -234,7 +236,9 @@ test_expect_success '...but not if explicitly forbidden by config' '
GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME= \
git -c init.defaultBranch=main -c protocol.version=2 \
clone "file://$(pwd)/file_empty_parent" file_empty_child &&
! grep "refs/heads/mydefaultbranch" file_empty_child/.git/HEAD
echo refs/heads/main >expect &&
git -C file_empty_child symbolic-ref HEAD >actual &&
test_cmp expect actual
'
test_expect_success 'bare clone propagates empty default branch' '
@ -247,7 +251,9 @@ test_expect_success 'bare clone propagates empty default branch' '
git -c init.defaultBranch=main -c protocol.version=2 \
clone --bare \
"file://$(pwd)/file_empty_parent" file_empty_child.git &&
grep "refs/heads/mydefaultbranch" file_empty_child.git/HEAD
echo "refs/heads/mydefaultbranch" >expect &&
git -C file_empty_child.git symbolic-ref HEAD >actual &&
test_cmp expect actual
'
test_expect_success 'clone propagates unborn HEAD from non-empty repo' '
@ -265,7 +271,9 @@ test_expect_success 'clone propagates unborn HEAD from non-empty repo' '
git -c init.defaultBranch=main -c protocol.version=2 \
clone "file://$(pwd)/file_unborn_parent" \
file_unborn_child 2>stderr &&
grep "refs/heads/mydefaultbranch" file_unborn_child/.git/HEAD &&
echo "refs/heads/mydefaultbranch" >expect &&
git -C file_unborn_child symbolic-ref HEAD >actual &&
test_cmp expect actual &&
grep "warning: remote HEAD refers to nonexistent ref" stderr
'
@ -295,7 +303,9 @@ test_expect_success 'bare clone propagates unborn HEAD from non-empty repo' '
git -c init.defaultBranch=main -c protocol.version=2 \
clone --bare "file://$(pwd)/file_unborn_parent" \
file_unborn_child.git 2>stderr &&
grep "refs/heads/mydefaultbranch" file_unborn_child.git/HEAD &&
echo "refs/heads/mydefaultbranch" >expect &&
git -C file_unborn_child.git symbolic-ref HEAD >actual &&
test_cmp expect actual &&
! grep "warning:" stderr
'
@ -315,7 +325,9 @@ test_expect_success 'defaulted HEAD uses remote branch if available' '
git -c init.defaultBranch=branchwithstuff -c protocol.version=2 \
clone "file://$(pwd)/file_unborn_parent" \
file_unborn_child 2>stderr &&
grep "refs/heads/branchwithstuff" file_unborn_child/.git/HEAD &&
echo "refs/heads/branchwithstuff" >expect &&
git -C file_unborn_child symbolic-ref HEAD >actual &&
test_cmp expect actual &&
test_path_is_file file_unborn_child/stuff.t &&
! grep "warning:" stderr
'