Merge branch 'sj/ref-contents-check-fix'

"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
This commit is contained in:
Junio C Hamano
2025-06-03 08:55:23 -07:00
2 changed files with 22 additions and 0 deletions

View File

@@ -3762,6 +3762,9 @@ static int files_fsck_refs_dir(struct ref_store *ref_store,
iter = dir_iterator_begin(sb.buf, 0);
if (!iter) {
if (errno == ENOENT && !is_main_worktree(wt))
goto out;
ret = error_errno(_("cannot open directory %s"), sb.buf);
goto out;
}

View File

@@ -110,6 +110,25 @@ test_expect_success 'ref name check should be adapted into fsck messages' '
)
'
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 &&