Skip to content

Commit c38b74f

Browse files
committed
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
2 parents b07857f + d5b3c38 commit c38b74f

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

refs/files-backend.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3762,6 +3762,9 @@ static int files_fsck_refs_dir(struct ref_store *ref_store,
37623762

37633763
iter = dir_iterator_begin(sb.buf, 0);
37643764
if (!iter) {
3765+
if (errno == ENOENT && !is_main_worktree(wt))
3766+
goto out;
3767+
37653768
ret = error_errno(_("cannot open directory %s"), sb.buf);
37663769
goto out;
37673770
}

t/t0602-reffiles-fsck.sh

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,25 @@ test_expect_success 'ref name check should be adapted into fsck messages' '
110110
)
111111
'
112112

113+
test_expect_success 'no refs directory of worktree should not cause problems' '
114+
test_when_finished "rm -rf repo" &&
115+
git init repo &&
116+
(
117+
cd repo &&
118+
test_commit initial &&
119+
git worktree add --detach ./worktree &&
120+
121+
(
122+
cd worktree &&
123+
worktree_refdir="$(git rev-parse --git-dir)/refs" &&
124+
# Simulate old directory layout
125+
rmdir "$worktree_refdir" &&
126+
git refs verify 2>err &&
127+
test_must_be_empty err
128+
)
129+
)
130+
'
131+
113132
test_expect_success 'ref name check should work for multiple worktrees' '
114133
test_when_finished "rm -rf repo" &&
115134
git init repo &&

0 commit comments

Comments
 (0)