]> git.ipfire.org Git - thirdparty/git.git/commitdiff
Merge branch 'sj/ref-contents-check-fix'
authorJunio C Hamano <gitster@pobox.com>
Tue, 3 Jun 2025 15:55:23 +0000 (08:55 -0700)
committerJunio C Hamano <gitster@pobox.com>
Tue, 3 Jun 2025 15:55:23 +0000 (08:55 -0700)
"git verify-refs" (and hence "git fsck --reference") started
erroring out in a repository in which secondary worktrees were
prepared with Git 2.43 or lower.

* sj/ref-contents-check-fix:
  fsck: ignore missing "refs" directory for linked worktrees

1  2 
refs/files-backend.c
t/t0602-reffiles-fsck.sh

Simple merge
index f671ac4d3aba1a66029bd61fcec006eab32f5077,a7f25c96057bf93fcf53f5aa1c075c70e5d463e5..0ef483659d561f737b8d27716e098d148fb7ac92
@@@ -91,25 -89,42 +91,44 @@@ test_expect_success 'ref name check sho
        test_when_finished "rm -rf repo" &&
        git init repo &&
        branch_dir_prefix=.git/refs/heads &&
 -      cd repo &&
 -      git commit --allow-empty -m initial &&
 -      git checkout -b branch-1 &&
 -
 -      cp $branch_dir_prefix/branch-1 $branch_dir_prefix/.branch-1 &&
 -      git -c fsck.badRefName=warn refs verify 2>err &&
 -      cat >expect <<-EOF &&
 -      warning: refs/heads/.branch-1: badRefName: invalid refname format
 -      EOF
 -      rm $branch_dir_prefix/.branch-1 &&
 -      test_cmp expect err &&
 -
 -      cp $branch_dir_prefix/branch-1 $branch_dir_prefix/.branch-1 &&
 -      git -c fsck.badRefName=ignore refs verify 2>err &&
 -      test_must_be_empty err
 +      (
 +              cd repo &&
 +              git commit --allow-empty -m initial &&
 +              git checkout -b branch-1 &&
 +
 +              cp $branch_dir_prefix/branch-1 $branch_dir_prefix/.branch-1 &&
 +              git -c fsck.badRefName=warn refs verify 2>err &&
 +              cat >expect <<-EOF &&
 +              warning: refs/heads/.branch-1: badRefName: invalid refname format
 +              EOF
 +              rm $branch_dir_prefix/.branch-1 &&
 +              test_cmp expect err &&
 +
 +              cp $branch_dir_prefix/branch-1 $branch_dir_prefix/.branch-1 &&
 +              git -c fsck.badRefName=ignore refs verify 2>err &&
 +              test_must_be_empty err
 +      )
  '
  
+ test_expect_success 'no refs directory of worktree should not cause problems' '
+       test_when_finished "rm -rf repo" &&
+       git init repo &&
+       (
+               cd repo &&
+               test_commit initial &&
+               git worktree add --detach ./worktree &&
+               (
+                       cd worktree &&
+                       worktree_refdir="$(git rev-parse --git-dir)/refs" &&
+                       # Simulate old directory layout
+                       rmdir "$worktree_refdir" &&
+                       git refs verify 2>err &&
+                       test_must_be_empty err
+               )
+       )
+ '
  test_expect_success 'ref name check should work for multiple worktrees' '
        test_when_finished "rm -rf repo" &&
        git init repo &&