aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2025-06-03 08:55:23 -0700
committerJunio C Hamano <gitster@pobox.com>2025-06-03 08:55:23 -0700
commitc38b74f28618d71cf4987aa215d1f7c432a318ac (patch)
tree204e5d7d0da9eb81daf2d450e60e9a52d45473a8
parentA bit more before -rc1 (diff)
parentfsck: ignore missing "refs" directory for linked worktrees (diff)
downloadgit-c38b74f28618d71cf4987aa215d1f7c432a318ac.tar.gz
git-c38b74f28618d71cf4987aa215d1f7c432a318ac.zip
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
-rw-r--r--refs/files-backend.c3
-rwxr-xr-xt/t0602-reffiles-fsck.sh19
2 files changed, 22 insertions, 0 deletions
diff --git a/refs/files-backend.c b/refs/files-backend.c
index 4d1f65a57a..bf6f89b1d1 100644
--- a/refs/files-backend.c
+++ b/refs/files-backend.c
@@ -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;
}
diff --git a/t/t0602-reffiles-fsck.sh b/t/t0602-reffiles-fsck.sh
index f671ac4d3a..0ef483659d 100755
--- a/t/t0602-reffiles-fsck.sh
+++ b/t/t0602-reffiles-fsck.sh
@@ -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 &&