From: Karthik Nayak Date: Mon, 12 Jan 2026 11:45:19 GMT Subject: Re: [PATCH v2 13/17] refs/reftable: fix consistency checks with worktrees Message-ID: In-Reply-To: <20260112-pks-refs-verify-fixes-v2-13-2e9e453bd6c3@pks.im> Patrick Steinhardt writes: > 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]