Hi All: This version updates the following things: 1. Update the commit message to incorporate the commit message that introduces the BUG to better explain. 2. Update the shell script to avoid hardcode gitdir path. 3. Change "rm -rf" to be "rmdir", which would be safer because we should delete an empty directory, which has a better semantics. Thanks, Jialuo shejialuo (1): fsck: ignore missing "refs" directory for linked worktrees refs/files-backend.c | 3 +++ t/t0602-reffiles-fsck.sh | 17 +++++++++++++++++ 2 files changed, 20 insertions(+) Range-diff against v1: 1: bfde11adb6 ! 1: d949a8a646 fsck: ignore missing "refs" directory for linked worktrees @@ Metadata ## Commit message ## fsck: ignore missing "refs" directory for linked worktrees - It is reported that "git refs verify" would fail when encountering - worktrees created on Git v2.43.0 or older versions. These versions - don't automatically create the "refs" directory, causing the error: + "git refs verify" doesn't work if there are worktrees created on Git + v2.43.0 or older versions. These versions don't automatically create the + "refs" directory, causing the error: error: cannot open directory .git/worktrees/<worktree name>/refs: No such file or directory Since 8f4c00de95 (builtin/worktree: create refdb via ref backend, 2024-01-08), we automatically create the "refs" directory for new - worktrees. However, the fsck code incorrectly assumes all linked - worktrees have this directory, thus introducing compatibility issue. + worktrees. And in 7c78d819e6 (ref: support multiple worktrees check for + refs, 2024-11-20), we assume that all linked worktrees have this + directory and would wrongly report an error to the user, thus + introducing compatibility issue. Check for ENOENT errno before reporting directory access errors for linked worktrees to maintain backward compatibility. @@ t/t0602-reffiles-fsck.sh: test_expect_success 'ref name check should be adapted + ( + cd repo && + test_commit initial && -+ + git worktree add --detach ./worktree && ++ ++ cd worktree && ++ worktree_refdir="$(git rev-parse --git-dir)/refs" && + # Simulate old directory layout -+ rm -rf ./git/worktrees/worktree/refs && ++ rmdir "$worktree_refdir" && + git refs verify 2>err && + test_must_be_empty err + ) -- 2.49.0