From 9ddd5b883b0221d80392a914eb621ea680476e75 Mon Sep 17 00:00:00 2001 From: Patrick Steinhardt Date: Thu, 2 Nov 2023 09:46:41 +0100 Subject: [PATCH 1/9] t: allow skipping expected object ID in `ref-store update-ref` We require the caller to pass both the old and new expected object ID to our `test-tool ref-store update-ref` helper. When trying to update a symbolic reference though it's impossible to specify the expected object ID, which means that the test would instead have to force-update the reference. This is currently impossible though. Update the helper to optionally skip verification of the old object ID in case the test passes in an empty old object ID as input. Signed-off-by: Patrick Steinhardt Signed-off-by: Junio C Hamano --- t/helper/test-ref-store.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/t/helper/test-ref-store.c b/t/helper/test-ref-store.c index 48552e6a9e..702ec1f128 100644 --- a/t/helper/test-ref-store.c +++ b/t/helper/test-ref-store.c @@ -298,16 +298,19 @@ static int cmd_update_ref(struct ref_store *refs, const char **argv) const char *new_sha1_buf = notnull(*argv++, "new-sha1"); const char *old_sha1_buf = notnull(*argv++, "old-sha1"); unsigned int flags = arg_flags(*argv++, "flags", transaction_flags); - struct object_id old_oid; + struct object_id old_oid, *old_oid_ptr = NULL; struct object_id new_oid; - if (get_oid_hex(old_sha1_buf, &old_oid)) - die("cannot parse %s as %s", old_sha1_buf, the_hash_algo->name); + if (*old_sha1_buf) { + if (get_oid_hex(old_sha1_buf, &old_oid)) + die("cannot parse %s as %s", old_sha1_buf, the_hash_algo->name); + old_oid_ptr = &old_oid; + } if (get_oid_hex(new_sha1_buf, &new_oid)) die("cannot parse %s as %s", new_sha1_buf, the_hash_algo->name); return refs_update_ref(refs, msg, refname, - &new_oid, &old_oid, + &new_oid, old_oid_ptr, flags, UPDATE_REFS_DIE_ON_ERR); } From 1c6667cb9dab6f90dcc3381676b50b1f131aeda5 Mon Sep 17 00:00:00 2001 From: Patrick Steinhardt Date: Thu, 2 Nov 2023 09:46:45 +0100 Subject: [PATCH 2/9] t: convert tests to not write references via the filesystem Some of our tests manually create, update or delete references by writing the respective new values into the filesystem directly. While this works with the current files reference backend, this will break once we have a second reference backend implementation in our codebase. Refactor these tests to instead use git-update-ref(1) or our `ref-store` test tool. The latter is required in some cases where safety checks of git-update-ref(1) would otherwise reject a reference update. While at it, refactor some of the tests to schedule the cleanup command via `test_when_finished` before modifying the repository. Signed-off-by: Patrick Steinhardt Signed-off-by: Junio C Hamano --- t/t1400-update-ref.sh | 17 ++++++++--------- t/t1450-fsck.sh | 26 +++++++++++++------------- t/t3404-rebase-interactive.sh | 2 +- t/t5526-fetch-submodules.sh | 2 +- 4 files changed, 23 insertions(+), 24 deletions(-) diff --git a/t/t1400-update-ref.sh b/t/t1400-update-ref.sh index 4d66cd7f4a..91cc6dff72 100755 --- a/t/t1400-update-ref.sh +++ b/t/t1400-update-ref.sh @@ -9,8 +9,6 @@ test_description='Test git update-ref and basic ref logging' Z=$ZERO_OID m=refs/heads/main -n_dir=refs/heads/gu -n=$n_dir/fixes outside=refs/foo bare=bare-repo @@ -62,10 +60,10 @@ test_expect_success "delete $m without oldvalue verification" ' test_must_fail git show-ref --verify -q $m ' -test_expect_success "fail to create $n" ' - test_when_finished "rm -f .git/$n_dir" && - touch .git/$n_dir && - test_must_fail git update-ref $n $A +test_expect_success "fail to create $n due to file/directory conflict" ' + test_when_finished "git update-ref -d refs/heads/gu" && + git update-ref refs/heads/gu $A && + test_must_fail git update-ref refs/heads/gu/fixes $A ' test_expect_success "create $m (by HEAD)" ' @@ -221,16 +219,16 @@ test_expect_success 'delete symref without dereference when the referred ref is ' test_expect_success 'update-ref -d is not confused by self-reference' ' + test_when_finished "test-tool ref-store main delete-refs REF_NO_DEREF refs/heads/self" && git symbolic-ref refs/heads/self refs/heads/self && - test_when_finished "rm -f .git/refs/heads/self" && test_path_is_file .git/refs/heads/self && test_must_fail git update-ref -d refs/heads/self && test_path_is_file .git/refs/heads/self ' test_expect_success 'update-ref --no-deref -d can delete self-reference' ' + test_when_finished "test-tool ref-store main delete-refs REF_NO_DEREF refs/heads/self" && git symbolic-ref refs/heads/self refs/heads/self && - test_when_finished "rm -f .git/refs/heads/self" && test_path_is_file .git/refs/heads/self && git update-ref --no-deref -d refs/heads/self && test_must_fail git show-ref --verify -q refs/heads/self @@ -434,7 +432,8 @@ test_expect_success 'Query "main@{2005-05-28}" (past end of history)' ' test_i18ngrep -F "warning: log for ref $m unexpectedly ended on $ld" e ' -rm -f .git/$m .git/logs/$m expect +rm -f expect +git update-ref -d $m test_expect_success 'creating initial files' ' test_when_finished rm -f M && diff --git a/t/t1450-fsck.sh b/t/t1450-fsck.sh index 10a539158c..f55b539b08 100755 --- a/t/t1450-fsck.sh +++ b/t/t1450-fsck.sh @@ -15,6 +15,7 @@ test_expect_success setup ' git config --unset i18n.commitencoding && git checkout HEAD^0 && test_commit B fileB two && + orig_head=$(git rev-parse HEAD) && git tag -d A B && git reflog expire --expire=now --all ' @@ -115,15 +116,15 @@ test_expect_success 'zlib corrupt loose object output ' ' ' test_expect_success 'branch pointing to non-commit' ' - git rev-parse HEAD^{tree} >.git/refs/heads/invalid && + tree_oid=$(git rev-parse --verify HEAD^{tree}) && test_when_finished "git update-ref -d refs/heads/invalid" && + test-tool ref-store main update-ref msg refs/heads/invalid $tree_oid $ZERO_OID REF_SKIP_OID_VERIFICATION && test_must_fail git fsck 2>out && test_i18ngrep "not a commit" out ' test_expect_success 'HEAD link pointing at a funny object' ' - test_when_finished "mv .git/SAVED_HEAD .git/HEAD" && - mv .git/HEAD .git/SAVED_HEAD && + test_when_finished "git update-ref HEAD $orig_head" && echo $ZERO_OID >.git/HEAD && # avoid corrupt/broken HEAD from interfering with repo discovery test_must_fail env GIT_DIR=.git git fsck 2>out && @@ -131,8 +132,7 @@ test_expect_success 'HEAD link pointing at a funny object' ' ' test_expect_success 'HEAD link pointing at a funny place' ' - test_when_finished "mv .git/SAVED_HEAD .git/HEAD" && - mv .git/HEAD .git/SAVED_HEAD && + test_when_finished "git update-ref --no-deref HEAD $orig_head" && echo "ref: refs/funny/place" >.git/HEAD && # avoid corrupt/broken HEAD from interfering with repo discovery test_must_fail env GIT_DIR=.git git fsck 2>out && @@ -140,10 +140,9 @@ test_expect_success 'HEAD link pointing at a funny place' ' ' test_expect_success 'HEAD link pointing at a funny object (from different wt)' ' - test_when_finished "mv .git/SAVED_HEAD .git/HEAD" && + test_when_finished "git update-ref HEAD $orig_head" && test_when_finished "rm -rf .git/worktrees wt" && git worktree add wt && - mv .git/HEAD .git/SAVED_HEAD && echo $ZERO_OID >.git/HEAD && # avoid corrupt/broken HEAD from interfering with repo discovery test_must_fail git -C wt fsck 2>out && @@ -161,7 +160,8 @@ test_expect_success 'other worktree HEAD link pointing at a funny object' ' test_expect_success 'other worktree HEAD link pointing at missing object' ' test_when_finished "rm -rf .git/worktrees other" && git worktree add other && - echo "Contents missing from repo" | git hash-object --stdin >.git/worktrees/other/HEAD && + object_id=$(echo "Contents missing from repo" | git hash-object --stdin) && + test-tool -C other ref-store main update-ref msg HEAD $object_id "" REF_NO_DEREF,REF_SKIP_OID_VERIFICATION && test_must_fail git fsck 2>out && test_i18ngrep "worktrees/other/HEAD: invalid sha1 pointer" out ' @@ -391,7 +391,7 @@ test_expect_success 'tag pointing to nonexistent' ' tag=$(git hash-object -t tag -w --stdin .git/refs/tags/invalid && + git update-ref refs/tags/invalid $tag && test_when_finished "git update-ref -d refs/tags/invalid" && test_must_fail git fsck --tags >out && test_i18ngrep "broken link" out @@ -411,7 +411,7 @@ test_expect_success 'tag pointing to something else than its type' ' tag=$(git hash-object -t tag -w --stdin .git/refs/tags/wrong && + git update-ref refs/tags/wrong $tag && test_when_finished "git update-ref -d refs/tags/wrong" && test_must_fail git fsck --tags ' @@ -428,7 +428,7 @@ test_expect_success 'tag with incorrect tag name & missing tagger' ' tag=$(git hash-object --literally -t tag -w --stdin .git/refs/tags/wrong && + git update-ref refs/tags/wrong $tag && test_when_finished "git update-ref -d refs/tags/wrong" && git fsck --tags 2>out && @@ -452,7 +452,7 @@ test_expect_success 'tag with bad tagger' ' tag=$(git hash-object --literally -t tag -w --stdin .git/refs/tags/wrong && + git update-ref refs/tags/wrong $tag && test_when_finished "git update-ref -d refs/tags/wrong" && test_must_fail git fsck --tags 2>out && test_i18ngrep "error in tag .*: invalid author/committer" out @@ -471,7 +471,7 @@ test_expect_success 'tag with NUL in header' ' tag=$(git hash-object --literally -t tag -w --stdin .git/refs/tags/wrong && + git update-ref refs/tags/wrong $tag && test_when_finished "git update-ref -d refs/tags/wrong" && test_must_fail git fsck --tags 2>out && test_i18ngrep "error in tag $tag.*unterminated header: NUL at offset" out diff --git a/t/t3404-rebase-interactive.sh b/t/t3404-rebase-interactive.sh index 8ea2bf1302..d2a7a91f17 100755 --- a/t/t3404-rebase-interactive.sh +++ b/t/t3404-rebase-interactive.sh @@ -2160,7 +2160,7 @@ test_expect_success '--update-refs: check failed ref update' ' # recorded in the update-refs file. We will force-update the # "second" ref, but "git branch -f" will not work because of # the lock in the update-refs file. - git rev-parse third >.git/refs/heads/second && + git update-ref refs/heads/second third && test_must_fail git rebase --continue 2>err && grep "update_ref failed for ref '\''refs/heads/second'\''" err && diff --git a/t/t5526-fetch-submodules.sh b/t/t5526-fetch-submodules.sh index 26e933f93a..7ab220fa31 100755 --- a/t/t5526-fetch-submodules.sh +++ b/t/t5526-fetch-submodules.sh @@ -771,7 +771,7 @@ test_expect_success 'fetching submodule into a broken repository' ' git -C dst fetch --recurse-submodules && # Break the receiving submodule - rm -f dst/sub/.git/HEAD && + test-tool -C dst/sub ref-store main delete-refs REF_NO_DEREF msg HEAD && # NOTE: without the fix the following tests will recurse forever! # They should terminate with an error. From 239371168173da9a9556617fced1e053ac618a85 Mon Sep 17 00:00:00 2001 From: Patrick Steinhardt Date: Thu, 2 Nov 2023 09:46:49 +0100 Subject: [PATCH 3/9] t: convert tests to not access symrefs via the filesystem Some of our tests access symbolic references via the filesystem directly. While this works with the current files reference backend, it this will break once we have a second reference backend in our codebase. Refactor these tests to instead use git-symbolic-ref(1) or our `ref-store` test tool. The latter is required in some cases where safety checks of git-symbolic-ref(1) would otherwise reject writing a symbolic reference. Signed-off-by: Patrick Steinhardt Signed-off-by: Junio C Hamano --- t/t1400-update-ref.sh | 8 ++++---- t/t1430-bad-ref-name.sh | 12 ++++++------ t/t1450-fsck.sh | 4 ++-- t/t3200-branch.sh | 9 ++++++--- t/t4013-diff-various.sh | 2 +- t/t4202-log.sh | 2 +- t/t5605-clone-local.sh | 2 +- t/t5702-protocol-v2.sh | 24 ++++++++++++++++++------ t/t9133-git-svn-nested-git-repo.sh | 2 +- 9 files changed, 40 insertions(+), 25 deletions(-) diff --git a/t/t1400-update-ref.sh b/t/t1400-update-ref.sh index 91cc6dff72..51a8d0bba9 100755 --- a/t/t1400-update-ref.sh +++ b/t/t1400-update-ref.sh @@ -221,15 +221,15 @@ test_expect_success 'delete symref without dereference when the referred ref is test_expect_success 'update-ref -d is not confused by self-reference' ' test_when_finished "test-tool ref-store main delete-refs REF_NO_DEREF refs/heads/self" && git symbolic-ref refs/heads/self refs/heads/self && - test_path_is_file .git/refs/heads/self && + git symbolic-ref --no-recurse refs/heads/self && test_must_fail git update-ref -d refs/heads/self && - test_path_is_file .git/refs/heads/self + git symbolic-ref --no-recurse refs/heads/self ' test_expect_success 'update-ref --no-deref -d can delete self-reference' ' test_when_finished "test-tool ref-store main delete-refs REF_NO_DEREF refs/heads/self" && git symbolic-ref refs/heads/self refs/heads/self && - test_path_is_file .git/refs/heads/self && + git symbolic-ref --no-recurse refs/heads/self && git update-ref --no-deref -d refs/heads/self && test_must_fail git show-ref --verify -q refs/heads/self ' @@ -239,7 +239,7 @@ test_expect_success 'update-ref --no-deref -d can delete reference to bad ref' ' test_when_finished "rm -f .git/refs/heads/bad" && git symbolic-ref refs/heads/ref-to-bad refs/heads/bad && test_when_finished "git update-ref -d refs/heads/ref-to-bad" && - test_path_is_file .git/refs/heads/ref-to-bad && + git symbolic-ref --no-recurse refs/heads/ref-to-bad && git update-ref --no-deref -d refs/heads/ref-to-bad && test_must_fail git show-ref --verify -q refs/heads/ref-to-bad ' diff --git a/t/t1430-bad-ref-name.sh b/t/t1430-bad-ref-name.sh index 7b7d6953c6..5debb91f7b 100755 --- a/t/t1430-bad-ref-name.sh +++ b/t/t1430-bad-ref-name.sh @@ -164,9 +164,9 @@ test_expect_success 'rev-parse skips symref pointing to broken name' ' test_expect_success 'for-each-ref emits warnings for broken names' ' test-tool ref-store main update-ref msg "refs/heads/broken...ref" $main_sha1 $ZERO_OID REF_SKIP_REFNAME_VERIFICATION && test_when_finished "test-tool ref-store main delete-refs REF_NO_DEREF msg refs/heads/broken...ref" && - printf "ref: refs/heads/broken...ref\n" >.git/refs/heads/badname && + test-tool ref-store main create-symref refs/heads/badname refs/heads/broken...ref && test_when_finished "test-tool ref-store main delete-refs REF_NO_DEREF msg refs/heads/badname" && - printf "ref: refs/heads/main\n" >.git/refs/heads/broken...symref && + test-tool ref-store main create-symref refs/heads/broken...symref refs/heads/main && test_when_finished "test-tool ref-store main delete-refs REF_NO_DEREF msg refs/heads/broken...symref" && git for-each-ref >output 2>error && ! grep -e "broken\.\.\.ref" output && @@ -257,7 +257,7 @@ test_expect_success 'update-ref -d can delete broken name through symref' ' ' test_expect_success 'update-ref --no-deref -d can delete symref with broken name' ' - printf "ref: refs/heads/main\n" >.git/refs/heads/broken...symref && + test-tool ref-store main create-symref refs/heads/broken...symref refs/heads/main && test_when_finished "test-tool ref-store main delete-refs REF_NO_DEREF msg refs/heads/broken...symref" && test_ref_exists refs/heads/broken...symref && git update-ref --no-deref -d refs/heads/broken...symref >output 2>error && @@ -267,7 +267,7 @@ test_expect_success 'update-ref --no-deref -d can delete symref with broken name ' test_expect_success 'branch -d can delete symref with broken name' ' - printf "ref: refs/heads/main\n" >.git/refs/heads/broken...symref && + test-tool ref-store main create-symref refs/heads/broken...symref refs/heads/main && test_when_finished "test-tool ref-store main delete-refs REF_NO_DEREF msg refs/heads/broken...symref" && test_ref_exists refs/heads/broken...symref && git branch -d broken...symref >output 2>error && @@ -277,7 +277,7 @@ test_expect_success 'branch -d can delete symref with broken name' ' ' test_expect_success 'update-ref --no-deref -d can delete dangling symref with broken name' ' - printf "ref: refs/heads/idonotexist\n" >.git/refs/heads/broken...symref && + test-tool ref-store main create-symref refs/heads/broken...symref refs/heads/idonotexist && test_when_finished "test-tool ref-store main delete-refs REF_NO_DEREF msg refs/heads/broken...symref" && test_ref_exists refs/heads/broken...symref && git update-ref --no-deref -d refs/heads/broken...symref >output 2>error && @@ -287,7 +287,7 @@ test_expect_success 'update-ref --no-deref -d can delete dangling symref with br ' test_expect_success 'branch -d can delete dangling symref with broken name' ' - printf "ref: refs/heads/idonotexist\n" >.git/refs/heads/broken...symref && + test-tool ref-store main create-symref refs/heads/broken...symref refs/heads/idonotexist && test_when_finished "test-tool ref-store main delete-refs REF_NO_DEREF msg refs/heads/broken...symref" && test_ref_exists refs/heads/broken...symref && git branch -d broken...symref >output 2>error && diff --git a/t/t1450-fsck.sh b/t/t1450-fsck.sh index f55b539b08..a3c97b9c7f 100755 --- a/t/t1450-fsck.sh +++ b/t/t1450-fsck.sh @@ -133,7 +133,7 @@ test_expect_success 'HEAD link pointing at a funny object' ' test_expect_success 'HEAD link pointing at a funny place' ' test_when_finished "git update-ref --no-deref HEAD $orig_head" && - echo "ref: refs/funny/place" >.git/HEAD && + test-tool ref-store main create-symref HEAD refs/funny/place && # avoid corrupt/broken HEAD from interfering with repo discovery test_must_fail env GIT_DIR=.git git fsck 2>out && test_i18ngrep "HEAD points to something strange" out @@ -169,7 +169,7 @@ test_expect_success 'other worktree HEAD link pointing at missing object' ' test_expect_success 'other worktree HEAD link pointing at a funny place' ' test_when_finished "rm -rf .git/worktrees other" && git worktree add other && - echo "ref: refs/funny/place" >.git/worktrees/other/HEAD && + git -C other symbolic-ref HEAD refs/funny/place && test_must_fail git fsck 2>out && test_i18ngrep "worktrees/other/HEAD points to something strange" out ' diff --git a/t/t3200-branch.sh b/t/t3200-branch.sh index 964bc36514..1197a44fca 100755 --- a/t/t3200-branch.sh +++ b/t/t3200-branch.sh @@ -215,10 +215,13 @@ test_expect_success 'git branch -M should leave orphaned HEAD alone' ' cd orphan && test_commit initial && git checkout --orphan lonely && - grep lonely .git/HEAD && + git symbolic-ref HEAD >expect && + echo refs/heads/lonely >actual && + test_cmp expect actual && test_ref_missing refs/head/lonely && git branch -M main mistress && - grep lonely .git/HEAD + git symbolic-ref HEAD >expect && + test_cmp expect actual ) ' @@ -809,7 +812,7 @@ test_expect_success 'deleting a symref' ' test_expect_success 'deleting a dangling symref' ' git symbolic-ref refs/heads/dangling-symref nowhere && - test_path_is_file .git/refs/heads/dangling-symref && + git symbolic-ref --no-recurse refs/heads/dangling-symref && echo "Deleted branch dangling-symref (was nowhere)." >expect && git branch -d dangling-symref >actual && test_ref_missing refs/heads/dangling-symref && diff --git a/t/t4013-diff-various.sh b/t/t4013-diff-various.sh index 4b47480831..fc8a0588ac 100755 --- a/t/t4013-diff-various.sh +++ b/t/t4013-diff-various.sh @@ -522,7 +522,7 @@ test_expect_success 'log -S requires an argument' ' ' test_expect_success 'diff --cached on unborn branch' ' - echo ref: refs/heads/unborn >.git/HEAD && + git symbolic-ref HEAD refs/heads/unborn && git diff --cached >result && process_diffs result >actual && process_diffs "$TEST_DIRECTORY/t4013/diff.diff_--cached" >expected && diff --git a/t/t4202-log.sh b/t/t4202-log.sh index af4a123cd2..57b298a4e2 100755 --- a/t/t4202-log.sh +++ b/t/t4202-log.sh @@ -2265,7 +2265,7 @@ test_expect_success REFFILES 'log diagnoses bogus HEAD hash' ' test_expect_success REFFILES 'log diagnoses bogus HEAD symref' ' git init empty && - echo "ref: refs/heads/invalid.lock" > empty/.git/HEAD && + test-tool -C empty ref-store main create-symref HEAD refs/heads/invalid.lock && test_must_fail git -C empty log 2>stderr && test_i18ngrep broken stderr && test_must_fail git -C empty log --default totally-bogus 2>stderr && diff --git a/t/t5605-clone-local.sh b/t/t5605-clone-local.sh index 946c575188..bedd29d055 100755 --- a/t/t5605-clone-local.sh +++ b/t/t5605-clone-local.sh @@ -65,7 +65,7 @@ test_expect_success 'Even without -l, local will make a hardlink' ' ' test_expect_success 'local clone of repo with nonexistent ref in HEAD' ' - echo "ref: refs/heads/nonexistent" > a.git/HEAD && + git -C a.git symbolic-ref HEAD refs/heads/nonexistent && git clone a d && (cd d && git fetch && diff --git a/t/t5702-protocol-v2.sh b/t/t5702-protocol-v2.sh index 6af5c2062f..dcc4cd95fe 100755 --- a/t/t5702-protocol-v2.sh +++ b/t/t5702-protocol-v2.sh @@ -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 ' diff --git a/t/t9133-git-svn-nested-git-repo.sh b/t/t9133-git-svn-nested-git-repo.sh index d8d536269c..8ca24670ac 100755 --- a/t/t9133-git-svn-nested-git-repo.sh +++ b/t/t9133-git-svn-nested-git-repo.sh @@ -11,7 +11,7 @@ test_expect_success 'setup repo with a git repo inside it' ' ( cd s && git init && - test -f .git/HEAD && + git symbolic-ref HEAD && > .git/a && echo a > a && svn_cmd add .git a && From 668e31c690b821b9aba0fc6d11f483b1d154682a Mon Sep 17 00:00:00 2001 From: Patrick Steinhardt Date: Thu, 2 Nov 2023 09:46:53 +0100 Subject: [PATCH 4/9] t: convert tests to not access reflog via the filesystem Some of our tests reach directly into the filesystem in order to both read or modify the reflog, which will break once we have a second reference backend in our codebase that stores reflogs differently. Refactor these tests to either use git-reflog(1) or the ref-store test helper. Note that the refactoring to use git-reflog(1) also requires us to adapt our expectations in some cases where we previously verified the exact on-disk log entries. This seems like an acceptable tradeoff though to ensure that different backends have the same user-visible behaviour as any user would typically use git-reflog(1) anyway to access the logs. Any backend-specific verification of the written on-disk format should be implemented in a separate, backend-specific test. Signed-off-by: Patrick Steinhardt Signed-off-by: Junio C Hamano --- t/t1400-update-ref.sh | 17 +++++++++++------ t/t3200-branch.sh | 24 ++++++++++++------------ 2 files changed, 23 insertions(+), 18 deletions(-) diff --git a/t/t1400-update-ref.sh b/t/t1400-update-ref.sh index 51a8d0bba9..b7d1e5deed 100755 --- a/t/t1400-update-ref.sh +++ b/t/t1400-update-ref.sh @@ -90,7 +90,8 @@ test_expect_success "deleting current branch adds message to HEAD's log" ' git symbolic-ref HEAD $m && git update-ref -m delete-$m -d $m && test_must_fail git show-ref --verify -q $m && - grep "delete-$m$" .git/logs/HEAD + test-tool ref-store main for-each-reflog-ent HEAD >actual && + grep "delete-$m$" actual ' test_expect_success "deleting by HEAD adds message to HEAD's log" ' @@ -99,7 +100,8 @@ test_expect_success "deleting by HEAD adds message to HEAD's log" ' git symbolic-ref HEAD $m && git update-ref -m delete-by-head -d HEAD && test_must_fail git show-ref --verify -q $m && - grep "delete-by-head$" .git/logs/HEAD + test-tool ref-store main for-each-reflog-ent HEAD >actual && + grep "delete-by-head$" actual ' test_expect_success 'update-ref does not create reflogs by default' ' @@ -130,7 +132,7 @@ test_expect_success 'creates no reflog in bare repository' ' test_expect_success 'core.logAllRefUpdates=true creates reflog in bare repository' ' test_when_finished "git -C $bare config --unset core.logAllRefUpdates && \ - rm $bare/logs/$m" && + test-tool ref-store main delete-reflog $m" && git -C $bare config core.logAllRefUpdates true && git -C $bare update-ref $m $bareB && git -C $bare rev-parse $bareB >expect && @@ -263,7 +265,10 @@ test_expect_success "(not) changed .git/$m" ' ! test $B = $(git show-ref -s --verify $m) ' -rm -f .git/logs/refs/heads/main +test_expect_success "clean up reflog" ' + test-tool ref-store main delete-reflog $m +' + test_expect_success "create $m (logged by touch)" ' test_config core.logAllRefUpdates false && GIT_COMMITTER_DATE="2005-05-26 23:30" \ @@ -316,7 +321,7 @@ $A $B $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> 1117150260 +0000 Switch $B $A $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> 1117150860 +0000 EOF test_expect_success "verifying $m's log (logged by touch)" ' - test_when_finished "git update-ref -d $m && rm -rf .git/logs actual expect" && + test_when_finished "git update-ref -d $m && git reflog expire --expire=all --all && rm -rf actual expect" && test-tool ref-store main for-each-reflog-ent $m >actual && test_cmp actual expect ' @@ -346,7 +351,7 @@ $A $B $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> 1117150380 +0000 Switch $B $A $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> 1117150980 +0000 EOF test_expect_success "verifying $m's log (logged by config)" ' - test_when_finished "git update-ref -d $m && rm -rf .git/logs actual expect" && + test_when_finished "git update-ref -d $m && git reflog expire --expire=all --all && rm -rf actual expect" && test-tool ref-store main for-each-reflog-ent $m >actual && test_cmp actual expect ' diff --git a/t/t3200-branch.sh b/t/t3200-branch.sh index 1197a44fca..30fb0dee6b 100755 --- a/t/t3200-branch.sh +++ b/t/t3200-branch.sh @@ -76,14 +76,14 @@ test_expect_success 'git branch HEAD should fail' ' ' cat >expect < 1117150200 +0000 branch: Created from main +$HEAD refs/heads/d/e/f@{0}: branch: Created from main EOF test_expect_success 'git branch --create-reflog d/e/f should create a branch and a log' ' GIT_COMMITTER_DATE="2005-05-26 23:30" \ git -c core.logallrefupdates=false branch --create-reflog d/e/f && test_ref_exists refs/heads/d/e/f && - test_path_is_file .git/logs/refs/heads/d/e/f && - test_cmp expect .git/logs/refs/heads/d/e/f + git reflog show --no-abbrev-commit refs/heads/d/e/f >actual && + test_cmp expect actual ' test_expect_success 'git branch -d d/e/f should delete a branch and a log' ' @@ -203,10 +203,9 @@ test_expect_success 'git branch -M baz bam should succeed when baz is checked ou test $(git rev-parse --abbrev-ref HEAD) = bam ' -test_expect_success 'git branch -M baz bam should add entries to .git/logs/HEAD' ' - msg="Branch: renamed refs/heads/baz to refs/heads/bam" && - grep " $ZERO_OID.*$msg$" .git/logs/HEAD && - grep "^$ZERO_OID.*$msg$" .git/logs/HEAD +test_expect_success 'git branch -M baz bam should add entries to HEAD reflog' ' + git reflog show HEAD >actual && + grep "HEAD@{0}: Branch: renamed refs/heads/baz to refs/heads/bam" actual ' test_expect_success 'git branch -M should leave orphaned HEAD alone' ' @@ -228,7 +227,7 @@ test_expect_success 'git branch -M should leave orphaned HEAD alone' ' test_expect_success 'resulting reflog can be shown by log -g' ' oid=$(git rev-parse HEAD) && cat >expect <<-EOF && - HEAD@{0} $oid $msg + HEAD@{0} $oid Branch: renamed refs/heads/baz to refs/heads/bam HEAD@{2} $oid checkout: moving from foo to baz EOF git log -g --format="%gd %H %gs" -2 HEAD >actual && @@ -702,7 +701,8 @@ test_expect_success 'git branch -C c1 c2 should succeed when c1 is checked out' test_expect_success 'git branch -C c1 c2 should never touch HEAD' ' msg="Branch: copied refs/heads/c1 to refs/heads/c2" && - ! grep "$msg$" .git/logs/HEAD + git reflog HEAD >actual && + ! grep "$msg$" actual ' test_expect_success 'git branch -C main should work when main is checked out' ' @@ -1143,14 +1143,14 @@ test_expect_success '--set-upstream-to notices an error to set branch as own ups # Keep this test last, as it changes the current branch cat >expect < 1117150200 +0000 branch: Created from main +$HEAD refs/heads/g/h/i@{0}: branch: Created from main EOF test_expect_success 'git checkout -b g/h/i -l should create a branch and a log' ' GIT_COMMITTER_DATE="2005-05-26 23:30" \ git checkout -b g/h/i -l main && test_ref_exists refs/heads/g/h/i && - test_path_is_file .git/logs/refs/heads/g/h/i && - test_cmp expect .git/logs/refs/heads/g/h/i + git reflog show --no-abbrev-commit refs/heads/g/h/i >actual && + test_cmp expect actual ' test_expect_success 'checkout -b makes reflog by default' ' From c603138e3d5bae3991fcf2ba98f09b0ea3beb056 Mon Sep 17 00:00:00 2001 From: Patrick Steinhardt Date: Thu, 2 Nov 2023 09:46:57 +0100 Subject: [PATCH 5/9] t1450: convert tests to remove worktrees via git-worktree(1) Some of our tests in t1450 create worktrees and then corrupt them. As it is impossible to delete such worktrees via a normal call to `git worktree remove`, we instead opt to remove them manually by calling rm(1) instead. This is ultimately unnecessary though as we can use the `-f` switch to remove the worktree. Let's convert the tests to do so such that we don't have to reach into internal implementation details of worktrees. Signed-off-by: Patrick Steinhardt Signed-off-by: Junio C Hamano --- t/t1450-fsck.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/t/t1450-fsck.sh b/t/t1450-fsck.sh index a3c97b9c7f..a6af550867 100755 --- a/t/t1450-fsck.sh +++ b/t/t1450-fsck.sh @@ -141,7 +141,7 @@ test_expect_success 'HEAD link pointing at a funny place' ' test_expect_success 'HEAD link pointing at a funny object (from different wt)' ' test_when_finished "git update-ref HEAD $orig_head" && - test_when_finished "rm -rf .git/worktrees wt" && + test_when_finished "git worktree remove -f wt" && git worktree add wt && echo $ZERO_OID >.git/HEAD && # avoid corrupt/broken HEAD from interfering with repo discovery @@ -150,7 +150,7 @@ test_expect_success 'HEAD link pointing at a funny object (from different wt)' ' ' test_expect_success 'other worktree HEAD link pointing at a funny object' ' - test_when_finished "rm -rf .git/worktrees other" && + test_when_finished "git worktree remove -f other" && git worktree add other && echo $ZERO_OID >.git/worktrees/other/HEAD && test_must_fail git fsck 2>out && @@ -158,7 +158,7 @@ test_expect_success 'other worktree HEAD link pointing at a funny object' ' ' test_expect_success 'other worktree HEAD link pointing at missing object' ' - test_when_finished "rm -rf .git/worktrees other" && + test_when_finished "git worktree remove -f other" && git worktree add other && object_id=$(echo "Contents missing from repo" | git hash-object --stdin) && test-tool -C other ref-store main update-ref msg HEAD $object_id "" REF_NO_DEREF,REF_SKIP_OID_VERIFICATION && @@ -167,7 +167,7 @@ test_expect_success 'other worktree HEAD link pointing at missing object' ' ' test_expect_success 'other worktree HEAD link pointing at a funny place' ' - test_when_finished "rm -rf .git/worktrees other" && + test_when_finished "git worktree remove -f other" && git worktree add other && git -C other symbolic-ref HEAD refs/funny/place && test_must_fail git fsck 2>out && From c6429fb86765714ef35d789905c1c15f50c4de91 Mon Sep 17 00:00:00 2001 From: Patrick Steinhardt Date: Thu, 2 Nov 2023 09:47:01 +0100 Subject: [PATCH 6/9] t4207: delete replace references via git-update-ref(1) In t4207 we set up a set of replace objects via git-replace(1). Because these references should not be impacting subsequent tests we also set up some cleanup logic that deletes the replacement references via a call to `rm -rf`. This reaches into the internal implementation details of the reference backend and will thus break when we grow an alternative refdb implementation. Refactor the tests to delete the replacement refs via Git commands so that we become independent of the actual refdb that's in use. As we don't have a nice way to delete all replacements or all references in a certain namespace, we opt for a combination of git-for-each-ref(1) and git-update-ref(1)'s `--stdin` mode. Signed-off-by: Patrick Steinhardt Signed-off-by: Junio C Hamano --- t/t4207-log-decoration-colors.sh | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/t/t4207-log-decoration-colors.sh b/t/t4207-log-decoration-colors.sh index 21986a866d..73ea9e5155 100755 --- a/t/t4207-log-decoration-colors.sh +++ b/t/t4207-log-decoration-colors.sh @@ -70,8 +70,14 @@ ${c_tag}tag: ${c_reset}${c_tag}A${c_reset}${c_commit})${c_reset} A cmp_filtered_decorations ' +remove_replace_refs () { + git for-each-ref 'refs/replace*/**' --format='delete %(refname)' >in && + git update-ref --stdin Date: Thu, 2 Nov 2023 09:47:06 +0100 Subject: [PATCH 7/9] t7300: assert exact states of repo Some of the tests in t7300 verify that git-clean(1) doesn't touch repositories that are embedded into the main repository. This is done by asserting a small set of substructures that are assumed to always exist, like the "refs/", "objects/" or "HEAD". This has the downside that we need to assume a specific repository structure that may be subject to change when new backends for the refdb land. At the same time, we don't thoroughly assert that git-clean(1) really didn't end up cleaning any files in the repository either. Convert the tests to instead assert that all files continue to exist after git-clean(1) by comparing a file listing via find(1) before and after executing clean. This makes our actual assertions stricter while having to care less about the repository's actual on-disk format. Signed-off-by: Patrick Steinhardt Signed-off-by: Junio C Hamano --- t/t7300-clean.sh | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/t/t7300-clean.sh b/t/t7300-clean.sh index 0ef7b78457..d7d9202f37 100755 --- a/t/t7300-clean.sh +++ b/t/t7300-clean.sh @@ -517,8 +517,12 @@ test_expect_success 'nested (empty) git should be kept' ' git init empty_repo && mkdir to_clean && >to_clean/should_clean.this && + # Note that we put the expect file in the .git directory so that it + # does not get cleaned. + find empty_repo | sort >.git/expect && git clean -f -d && - test_path_is_file empty_repo/.git/HEAD && + find empty_repo | sort >actual && + test_cmp .git/expect actual && test_path_is_missing to_clean ' @@ -559,10 +563,10 @@ test_expect_success 'giving path in nested git work tree will NOT remove it' ' mkdir -p bar/baz && test_commit msg bar/baz/hello.world ) && + find repo | sort >expect && git clean -f -d repo/bar/baz && - test_path_is_file repo/.git/HEAD && - test_path_is_dir repo/bar/ && - test_path_is_file repo/bar/baz/hello.world + find repo | sort >actual && + test_cmp expect actual ' test_expect_success 'giving path to nested .git will not remove it' ' @@ -573,10 +577,10 @@ test_expect_success 'giving path to nested .git will not remove it' ' git init && test_commit msg hello.world ) && + find repo | sort >expect && git clean -f -d repo/.git && - test_path_is_file repo/.git/HEAD && - test_path_is_dir repo/.git/refs && - test_path_is_dir repo/.git/objects && + find repo | sort >actual && + test_cmp expect actual && test_path_is_dir untracked/ ' @@ -588,9 +592,10 @@ test_expect_success 'giving path to nested .git/ will NOT remove contents' ' git init && test_commit msg hello.world ) && + find repo | sort >expect && git clean -f -d repo/.git/ && - test_path_is_dir repo/.git && - test_path_is_file repo/.git/HEAD && + find repo | sort >actual && + test_cmp expect actual && test_path_is_dir untracked/ ' From 170ba45acf4db996a58ce849e6901a65c13b94d6 Mon Sep 17 00:00:00 2001 From: Patrick Steinhardt Date: Thu, 2 Nov 2023 09:47:10 +0100 Subject: [PATCH 8/9] t7900: assert the absence of refs via git-for-each-ref(1) We're asserting that a prefetch of remotes via git-maintenance(1) doesn't write any references in refs/remotes by validating that the directory ".git/refs/remotes" is missing. This is quite roundabout: we don't care about the directory existing, we care about the references not existing, and the way these are stored is on the behest of the reference database. Convert the test to instead check via git-for-each-ref(1) whether any remote reference exist. Signed-off-by: Patrick Steinhardt Signed-off-by: Junio C Hamano --- t/t7900-maintenance.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/t/t7900-maintenance.sh b/t/t7900-maintenance.sh index e56f5980dc..cefecee732 100755 --- a/t/t7900-maintenance.sh +++ b/t/t7900-maintenance.sh @@ -157,7 +157,8 @@ test_expect_success 'prefetch multiple remotes' ' fetchargs="--prefetch --prune --no-tags --no-write-fetch-head --recurse-submodules=no --quiet" && test_subcommand git fetch remote1 $fetchargs actual && + test_must_be_empty actual && git log prefetch/remotes/remote1/one && git log prefetch/remotes/remote2/two && git fetch --all && From a6f43364e3dc1eedf18b241f41bbd4abfd640fb4 Mon Sep 17 00:00:00 2001 From: Patrick Steinhardt Date: Thu, 2 Nov 2023 09:47:14 +0100 Subject: [PATCH 9/9] t: mark several tests that assume the files backend with REFFILES Add the REFFILES prerequisite to several tests that assume we're using the files backend. There are various reasons why we cannot easily convert those tests to be backend-independent, where the most common one is that we have no way to write corrupt references into the refdb via our tooling. We may at a later point in time grow the tooling to make this possible, but for now we just mark these tests as requiring the files backend. Signed-off-by: Patrick Steinhardt Signed-off-by: Junio C Hamano --- t/t1400-update-ref.sh | 8 ++++---- t/t1450-fsck.sh | 6 +++--- t/t2011-checkout-invalid-head.sh | 16 ++++++++-------- t/t3200-branch.sh | 8 ++++---- t/t3400-rebase.sh | 2 +- t/t5605-clone-local.sh | 2 +- 6 files changed, 21 insertions(+), 21 deletions(-) diff --git a/t/t1400-update-ref.sh b/t/t1400-update-ref.sh index b7d1e5deed..70a760ba37 100755 --- a/t/t1400-update-ref.sh +++ b/t/t1400-update-ref.sh @@ -236,7 +236,7 @@ test_expect_success 'update-ref --no-deref -d can delete self-reference' ' test_must_fail git show-ref --verify -q refs/heads/self ' -test_expect_success 'update-ref --no-deref -d can delete reference to bad ref' ' +test_expect_success REFFILES 'update-ref --no-deref -d can delete reference to bad ref' ' >.git/refs/heads/bad && test_when_finished "rm -f .git/refs/heads/bad" && git symbolic-ref refs/heads/ref-to-bad refs/heads/bad && @@ -288,7 +288,7 @@ test_expect_success "set $m (logged by touch)" ' test $A = $(git show-ref -s --verify $m) ' -test_expect_success 'empty directory removal' ' +test_expect_success REFFILES 'empty directory removal' ' git branch d1/d2/r1 HEAD && git branch d1/r2 HEAD && test_path_is_file .git/refs/heads/d1/d2/r1 && @@ -300,7 +300,7 @@ test_expect_success 'empty directory removal' ' test_path_is_file .git/logs/refs/heads/d1/r2 ' -test_expect_success 'symref empty directory removal' ' +test_expect_success REFFILES 'symref empty directory removal' ' git branch e1/e2/r1 HEAD && git branch e1/r2 HEAD && git checkout e1/e2/r1 && @@ -1639,7 +1639,7 @@ test_expect_success PIPE 'transaction flushes status updates' ' test_cmp expected actual ' -test_expect_success 'directory not created deleting packed ref' ' +test_expect_success REFFILES 'directory not created deleting packed ref' ' git branch d1/d2/r1 HEAD && git pack-refs --all && test_path_is_missing .git/refs/heads/d1/d2 && diff --git a/t/t1450-fsck.sh b/t/t1450-fsck.sh index a6af550867..50b15bd7fc 100755 --- a/t/t1450-fsck.sh +++ b/t/t1450-fsck.sh @@ -123,7 +123,7 @@ test_expect_success 'branch pointing to non-commit' ' test_i18ngrep "not a commit" out ' -test_expect_success 'HEAD link pointing at a funny object' ' +test_expect_success REFFILES 'HEAD link pointing at a funny object' ' test_when_finished "git update-ref HEAD $orig_head" && echo $ZERO_OID >.git/HEAD && # avoid corrupt/broken HEAD from interfering with repo discovery @@ -139,7 +139,7 @@ test_expect_success 'HEAD link pointing at a funny place' ' test_i18ngrep "HEAD points to something strange" out ' -test_expect_success 'HEAD link pointing at a funny object (from different wt)' ' +test_expect_success REFFILES 'HEAD link pointing at a funny object (from different wt)' ' test_when_finished "git update-ref HEAD $orig_head" && test_when_finished "git worktree remove -f wt" && git worktree add wt && @@ -149,7 +149,7 @@ test_expect_success 'HEAD link pointing at a funny object (from different wt)' ' test_i18ngrep "main-worktree/HEAD: detached HEAD points" out ' -test_expect_success 'other worktree HEAD link pointing at a funny object' ' +test_expect_success REFFILES 'other worktree HEAD link pointing at a funny object' ' test_when_finished "git worktree remove -f other" && git worktree add other && echo $ZERO_OID >.git/worktrees/other/HEAD && diff --git a/t/t2011-checkout-invalid-head.sh b/t/t2011-checkout-invalid-head.sh index d9997e7b6b..3c8135831b 100755 --- a/t/t2011-checkout-invalid-head.sh +++ b/t/t2011-checkout-invalid-head.sh @@ -18,18 +18,18 @@ test_expect_success 'checkout should not start branch from a tree' ' test_must_fail git checkout -b newbranch main^{tree} ' -test_expect_success 'checkout main from invalid HEAD' ' +test_expect_success REFFILES 'checkout main from invalid HEAD' ' echo $ZERO_OID >.git/HEAD && git checkout main -- ' -test_expect_success 'checkout notices failure to lock HEAD' ' +test_expect_success REFFILES 'checkout notices failure to lock HEAD' ' test_when_finished "rm -f .git/HEAD.lock" && >.git/HEAD.lock && test_must_fail git checkout -b other ' -test_expect_success 'create ref directory/file conflict scenario' ' +test_expect_success REFFILES 'create ref directory/file conflict scenario' ' git update-ref refs/heads/outer/inner main && # do not rely on symbolic-ref to get a known state, @@ -39,26 +39,26 @@ test_expect_success 'create ref directory/file conflict scenario' ' } ' -test_expect_success 'checkout away from d/f HEAD (unpacked, to branch)' ' +test_expect_success REFFILES 'checkout away from d/f HEAD (unpacked, to branch)' ' reset_to_df && git checkout main ' -test_expect_success 'checkout away from d/f HEAD (unpacked, to detached)' ' +test_expect_success REFFILES 'checkout away from d/f HEAD (unpacked, to detached)' ' reset_to_df && git checkout --detach main ' -test_expect_success 'pack refs' ' +test_expect_success REFFILES 'pack refs' ' git pack-refs --all --prune ' -test_expect_success 'checkout away from d/f HEAD (packed, to branch)' ' +test_expect_success REFFILES 'checkout away from d/f HEAD (packed, to branch)' ' reset_to_df && git checkout main ' -test_expect_success 'checkout away from d/f HEAD (packed, to detached)' ' +test_expect_success REFFILES 'checkout away from d/f HEAD (packed, to detached)' ' reset_to_df && git checkout --detach main ' diff --git a/t/t3200-branch.sh b/t/t3200-branch.sh index 30fb0dee6b..f0624ba3bb 100755 --- a/t/t3200-branch.sh +++ b/t/t3200-branch.sh @@ -28,7 +28,7 @@ test_expect_success 'git branch --help should not have created a bogus branch' ' test_ref_missing refs/heads/--help ' -test_expect_success 'branch -h in broken repository' ' +test_expect_success REFFILES 'branch -h in broken repository' ' mkdir broken && ( cd broken && @@ -245,7 +245,7 @@ test_expect_success 'git branch -M baz bam should succeed when baz is checked ou git worktree prune ' -test_expect_success 'git branch -M fails if updating any linked working tree fails' ' +test_expect_success REFFILES 'git branch -M fails if updating any linked working tree fails' ' git worktree add -b baz bazdir1 && git worktree add -f bazdir2 baz && touch .git/worktrees/bazdir1/HEAD.lock && @@ -836,14 +836,14 @@ test_expect_success 'renaming a symref is not allowed' ' test_ref_missing refs/heads/new-topic ' -test_expect_success SYMLINKS 'git branch -m u v should fail when the reflog for u is a symlink' ' +test_expect_success SYMLINKS,REFFILES 'git branch -m u v should fail when the reflog for u is a symlink' ' git branch --create-reflog u && mv .git/logs/refs/heads/u real-u && ln -s real-u .git/logs/refs/heads/u && test_must_fail git branch -m u v ' -test_expect_success SYMLINKS 'git branch -m with symlinked .git/refs' ' +test_expect_success SYMLINKS,REFFILES 'git branch -m with symlinked .git/refs' ' test_when_finished "rm -rf subdir" && git init --bare subdir && diff --git a/t/t3400-rebase.sh b/t/t3400-rebase.sh index d3df19a51f..435943a089 100755 --- a/t/t3400-rebase.sh +++ b/t/t3400-rebase.sh @@ -424,7 +424,7 @@ test_expect_success 'refuse to switch to branch checked out elsewhere' ' test_i18ngrep "already used by worktree at" err ' -test_expect_success MINGW,SYMLINKS_WINDOWS 'rebase when .git/logs is a symlink' ' +test_expect_success REFFILES,MINGW,SYMLINKS_WINDOWS 'rebase when .git/logs is a symlink' ' git checkout main && mv .git/logs actual_logs && cmd //c "mklink /D .git\logs ..\actual_logs" && diff --git a/t/t5605-clone-local.sh b/t/t5605-clone-local.sh index bedd29d055..a3055869bc 100755 --- a/t/t5605-clone-local.sh +++ b/t/t5605-clone-local.sh @@ -157,7 +157,7 @@ test_expect_success 'cloning locally respects "-u" for fetching refs' ' test_must_fail git clone --bare -u false a should_not_work.git ' -test_expect_success 'local clone from repo with corrupt refs fails gracefully' ' +test_expect_success REFFILES 'local clone from repo with corrupt refs fails gracefully' ' git init corrupt && test_commit -C corrupt one && echo a >corrupt/.git/refs/heads/topic &&