Re: [PATCH] fsck: ignore missing "refs" directory for linked worktrees
- From
- phillip.wood123@gmail.com <phillip.wood123@gmail.com>
- Date
- Jun 2, 2025, 13:50 UTC
- Message-ID
- <f5c517b6-955c-49d8-9f05-d47c24925eb8@gmail.com>
- In-Reply-To
- <aD176UYWKEbmhiaw@pks.im>
On 02/06/2025 11:24, Patrick Steinhardt wrote:
Show 31 quoted lines
> On Mon, Jun 02, 2025 at 10:53:50AM +0100, Phillip Wood wrote:
>> Hi Shejialuo
>>
>> On 31/05/2025 04:39, shejialuo wrote:
>>> 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;
>>> }
>>
>> I think it would be clearer to write this as
>>
>> if (is_main_worktree(wt) || errno != ENOENT)
>> ret = error_errno(_("cannot open directory %s"), sb.buf);
>> goto out;
>>
>> so that the condition that triggers the error message is explicit rather
>> than having to mentally invert the condition to figure out when we return an
>> error
>
> The downside though is that this mandates that `is_main_worktree()` must
> never set `errno` itself. So while it may be clearer, the original
> version feels safer to me.Oh good point. We could save errno and then check the saved version but it maybe it is not worth changing it.
Best Wishes
Phillip>
> Patrick