diff options
| author | shejialuo <shejialuo@gmail.com> | 2025-06-02 22:41:35 +0800 |
|---|---|---|
| committer | Junio C Hamano <gitster@pobox.com> | 2025-06-02 11:20:19 -0700 |
| commit | d5b3c38b8a1356921a87cc3d435e6de91a9fbff1 (patch) | |
| tree | c2cc928d10138607523cd279c10a46b5da8bff35 /refs/files-backend.c | |
| parent | d50a5e8939abfc07c2ff97ae72e9330939b36ee0 (diff) | |
fsck: ignore missing "refs" directory for linked worktrees
"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. 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.
Reported-by: Kristoffer Haugsbakk <code@khaugsbakk.name>
Signed-off-by: shejialuo <shejialuo@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'refs/files-backend.c')
| -rw-r--r-- | refs/files-backend.c | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/refs/files-backend.c b/refs/files-backend.c index 6c6e67dc1c..7fd9d49c87 100644 --- a/refs/files-backend.c +++ b/refs/files-backend.c @@ -3772,6 +3772,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; } |
