Re: [PATCH] refs/files: skip lock files during consistency checks
- From
Karthik Nayak <karthik.188@gmail.com>
- Date
- Apr 21, 2026, 16:04 UTC
- Message-ID
- <CAOLa=ZSZ=fFCjXt6bM3vojjtY+1imjbw5a7FASnGnDrPYoaBgA@mail.gmail.com>
- In-Reply-To
- <CAOLa=ZSj_fmDNo5bgtYeRs0piCq+QR4aydDtRsqK19nPnDFvbw@mail.gmail.com>
Karthik Nayak <karthik.188@gmail.com> writes:
Show 41 quoted lines
> Christian Couder <christian.couder@gmail.com> writes: > >> On Mon, Apr 20, 2026 at 5:21 PM Karthik Nayak <karthik.188@gmail.com> wrote: >> >>> @@ -3962,6 +3953,15 @@ static int files_fsck_refs_dir(struct ref_store *ref_store, >>> strbuf_addf(&refname, "worktrees/%s/", wt->id); >>> strbuf_addf(&refname, "refs/%s", iter->relative_path); >>> >>> + filename = basename((char *) iter->path.buf); >>> + >>> + /* >>> + * Ignore the files ending with ".lock" as they may be lock files >>> + * However, do not allow bare ".lock" files. >>> + */ >>> + if (filename[0] != '.' && ends_with(filename, ".lock")) >>> + continue; >>> + >>> if (files_fsck_ref(ref_store, o, refname.buf, >>> iter->path.buf, iter->st.st_mode) < 0) >>> ret = -1; >> >> This just moves code and associated comments, so the following are >> probably pre-existing issues, but still it seems to me that: >> >> - "do not allow" is not quite what is actually done. There is no ret = >> -1 set for example, so if files_fsck_ref() succeeds with the ".lock" >> file it could be allowed, or I am missing something? >> > > The intent was the same before too, we didn't want to ignore bare > '.lock' files. Then, we raised an error and we'll do the same now. 'do > not allow' is a bit confusing though, will amend it. > >> - a filename like ".stuff.lock" would be treated in the same way as >> ".lock". I wonder if it's what we want. >> > > Good catch, we only want to ignore reference lock files, these are files > which have a preceding text before the '.lock' text. We could simply > check the strlen of the path instead. >
Actually I'm wrong, the check is correct, since any refname starting with a '.' is considered incorrect so we do want to report such refs.