]> git.ipfire.org Git - thirdparty/git.git/commitdiff
Merge branch 'ps/ref-tests-update'
authorJunio C Hamano <gitster@pobox.com>
Sun, 10 Dec 2023 00:37:49 +0000 (16:37 -0800)
committerJunio C Hamano <gitster@pobox.com>
Sun, 10 Dec 2023 00:37:49 +0000 (16:37 -0800)
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`

1  2 
t/t1400-update-ref.sh
t/t1430-bad-ref-name.sh
t/t1450-fsck.sh
t/t3200-branch.sh
t/t3400-rebase.sh
t/t3404-rebase-interactive.sh
t/t4013-diff-various.sh
t/t4202-log.sh
t/t5702-protocol-v2.sh
t/t7300-clean.sh
t/t7900-maintenance.sh

index 9ac4b7036bf7ec8fe0befca6f08797c83a72c4b0,70a760ba378dce237f51732cafe930bafa9a6246..6d1810c358ffaf9c592befe946183ce3a70f04a4
@@@ -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 &&
Simple merge
diff --cc t/t1450-fsck.sh
index 0e3e87d37a1d52417e91ff1fc51fc86a468f0c89,50b15bd7fc064df9d627bc07a664d17aae8909d3..8a456b1142d1cc463f97c5e8809bcfc83ffa1e96
@@@ -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 &&
  '
  
  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 &&
  '
  
  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 <invalid-tag) &&
        test_when_finished "remove_object $tag" &&
-       echo $tag >.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 <wrong-tag) &&
        test_when_finished "remove_object $tag" &&
-       echo $tag >.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' '
  
        tag=$(git hash-object --literally -t tag -w --stdin <tag-NUL-header) &&
        test_when_finished "remove_object $tag" &&
-       echo $tag >.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' '
Simple merge
index 24a539c662f6c1f941e4f8c2949cfdc07d3cf2e5,435943a08913bcbfed438d011f3c0e350d6bdda9..57f13929260e70865fbb8f31e89ba7ff197afeaa
@@@ -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" &&
Simple merge
Simple merge
diff --cc t/t4202-log.sh
index 708636671a3fd1dd8b63b34335dbe4535d7c58bb,57b298a4e22aa3d207698fff3e1ea909c0be5461..ddd205f98abf7f8d58555761eaf20006bb8433e8
@@@ -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' '
Simple merge
Simple merge
Simple merge