From: Runxi Yu Date: Tue, 24 Feb 2026 04:33:34 GMT Subject: Re: [PATCH git] t5516: test updateInstead with worktree and unborn bare HEAD Message-ID: In-Reply-To: On Tue Feb 24, 2026 at 3:15 AM CST, Junio C Hamano wrote: > Did it ever worked before? When did it regress? Not that I know of. Unfortunately it's a bit difficult to build older versions, but the same logic was present in this commit and in main: > commit 9fdf4f1db422cc259e4a3ce0023a255102c6fa3b > Author: Anders Kaseorg > Date: Wed Dec 1 14:15:46 2021 -0800 > > receive-pack: protect current branch for bare repository worktree > > A bare repository won’t have a working tree at "..", but it may still > have separate working trees created with git worktree. We should protect > the current branch of such working trees from being updated or deleted, > according to receive.denyCurrentBranch. > > Signed-off-by: Anders Kaseorg > Signed-off-by: Junio C Hamano update finds the destination linked worktree correctly update_worktree sets GIT_DIR push_to_deploy decides whether to diff against HEAD or the empty tree by calling head_has_history but head_has_history uses the bare repo's HEAD rather than the destination worktree head_has_history used get_oid before vs repo_get_oid now, but they still both seem to use the bare repo instead of the worktree's HEAD. So if the bare repo's own HEAD is unborn, in both current main and 9fdf4f1db42, we would be incorrectly choosing the empty tree for the 'has staged changes' check's base, and report failure, even though the linked worktree is clean Well, by regression test, I don't mean that this was a previous regression; I just mean that, this was a way to reproduce this bug that sounds reasonable and could serve as a future regression test.