From: Junio C Hamano Date: Sun, 10 Dec 2023 00:37:49 +0000 (-0800) Subject: Merge branch 'ps/ref-tests-update' X-Git-Tag: v2.44.0-rc0~150 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=340581bcf11bd6e85f87af1d732c898885929e90;p=thirdparty%2Fgit.git 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` --- 340581bcf11bd6e85f87af1d732c898885929e90 diff --cc t/t1400-update-ref.sh index 9ac4b7036b,70a760ba37..6d1810c358 --- a/t/t1400-update-ref.sh +++ b/t/t1400-update-ref.sh @@@ -431,10 -434,11 +434,11 @@@ test_expect_success 'Query "main@{2005- git rev-parse --verify "main@{2005-05-28}" >o 2>e && echo "$D" >expect && test_cmp expect o && - test_i18ngrep -F "warning: log for ref $m unexpectedly ended on $ld" e + test_grep -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 --cc t/t1450-fsck.sh index 0e3e87d37a,50b15bd7fc..8a456b1142 --- a/t/t1450-fsck.sh +++ b/t/t1450-fsck.sh @@@ -115,15 -116,15 +116,15 @@@ test_expect_success 'zlib corrupt loos ' 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_grep "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_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 test_must_fail env GIT_DIR=.git git fsck 2>out && @@@ -131,27 -132,25 +132,25 @@@ ' 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 && - echo "ref: refs/funny/place" >.git/HEAD && + test_when_finished "git update-ref --no-deref HEAD $orig_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 + test_grep "HEAD points to something strange" out ' - 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 "rm -rf .git/worktrees 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 && - 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 && - test_i18ngrep "main-worktree/HEAD: detached HEAD points" out + test_grep "main-worktree/HEAD: detached HEAD points" out ' - test_expect_success 'other worktree HEAD link pointing at a funny object' ' - test_when_finished "rm -rf .git/worktrees other" && + 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 && test_must_fail git fsck 2>out && @@@ -159,19 -158,20 +158,20 @@@ ' 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 && - 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 + test_grep "worktrees/other/HEAD: invalid sha1 pointer" out ' 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 && - 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 + test_grep "worktrees/other/HEAD points to something strange" out ' test_expect_success 'commit with multiple signatures is okay' ' @@@ -391,10 -391,10 +391,10 @@@ test_expect_success 'tag pointing to no 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 + test_grep "broken link" out ' test_expect_success 'tag pointing to something else than its type' ' @@@ -452,10 -452,10 +452,10 @@@ test_expect_success 'tag with bad tagge 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 + test_grep "error in tag .*: invalid author/committer" out ' test_expect_success 'tag with NUL in header' ' @@@ -471,10 -471,10 +471,10 @@@ 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 + test_grep "error in tag $tag.*unterminated header: NUL at offset" out ' test_expect_success 'cleaned up' ' diff --cc t/t3400-rebase.sh index 24a539c662,435943a089..57f1392926 --- a/t/t3400-rebase.sh +++ b/t/t3400-rebase.sh @@@ -421,10 -421,10 +421,10 @@@ test_expect_success 'refuse to switch t git checkout main && git worktree add wt && test_must_fail git -C wt rebase main main 2>err && - test_i18ngrep "already used by worktree at" err + test_grep "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 --cc t/t4202-log.sh index 708636671a,57b298a4e2..ddd205f98a --- a/t/t4202-log.sh +++ b/t/t4202-log.sh @@@ -2265,11 -2265,11 +2265,11 @@@ test_expect_success REFFILES 'log diagn 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_grep broken stderr && test_must_fail git -C empty log --default totally-bogus 2>stderr && - test_i18ngrep broken stderr + test_grep broken stderr ' test_expect_success 'log does not default to HEAD when rev input is given' '