Re: [PATCH v2 13/17] refs/reftable: fix consistency checks with worktrees
- From
Karthik Nayak <karthik.188@gmail.com>
- Date
- Jan 12, 2026, 11:45 UTC
- Message-ID
- <CAOLa=ZTDTqpWgKW7=X70ofFJEK66mfOEOgQy-PpMHo_n6kyS=Q@mail.gmail.com>
- In-Reply-To
- <20260112-pks-refs-verify-fixes-v2-13-2e9e453bd6c3@pks.im>
Patrick Steinhardt <ps@pks.im> writes:
Show 20 quoted lines
> The ref consistency checks are driven via `cmd_refs_verify()`. That > function loops through all worktrees (including the main worktree) and > then checks the ref store for each of them individually. It follows that > the backend is expected to only verify refs that belong to the specified > worktree. > > While the "files" backend handles this correctly, the "reftable" backend > doesn't. In fact, it completely ignores the passed worktree and instead > verifies refs of _all_ worktrees. The consequence is that we'll end up > every ref store N times, where N is the number of worktrees. > > Or rather, that would be the case if we actually iterated through the > worktree reftable stacks correctly. But we use `strmap_for_each_entry()` > to iterate through the stacks, but the map is in fact not even properly > populated. So instead of checking stacks N^2 times, we actually only end > up checking the reftable stack of the main worktree. > > Fix this bug by only verifying the stack of the passed-in worktree and > constructing the backends via `backend_for_worktree()`. >
Ah, I was the author of this, I didn't know that the fsck function gets called per worktree, so thanks for fixing it!
[snip]