From 8151f4fe7e4bf36f2656ae849a4ffaf386708178 Mon Sep 17 00:00:00 2001 From: Pablo Sabater Date: Mon, 30 Mar 2026 13:18:22 +0200 Subject: receive-pack: use worktree HEAD for updateInstead When a bare repo has linked worktrees, and its HEAD points to an unborn branch, pushing to a wt branch with updateInstead fails and rejects the push, even if the wt is clean. This happens because HEAD is checked only for the bare repo context, instead of the wt. Remove head_has_history and check for worktree->head_oid which does have the correct HEAD of the wt. Update the test added by Runxi's patch to expect success. Signed-off-by: Pablo Sabater Signed-off-by: Junio C Hamano --- t/t5516-fetch-push.sh | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) (limited to 't') diff --git a/t/t5516-fetch-push.sh b/t/t5516-fetch-push.sh index c40f2790d8..117cfa051f 100755 --- a/t/t5516-fetch-push.sh +++ b/t/t5516-fetch-push.sh @@ -1817,11 +1817,7 @@ test_expect_success 'denyCurrentBranch and bare repository worktrees' ' test_must_fail git push --delete bare.git wt ' -# NEEDSWORK: updateInstead unexpectedly fails when bare HEAD points to unborn -# branch (or probably any ref that differs from the target worktree) despite -# the target worktree being clean. This seems to be because receive-pack.c -# diffs the target worktree index against the bare repository HEAD. -test_expect_failure 'updateInstead with bare repository worktree and unborn bare HEAD' ' +test_expect_success 'updateInstead with bare repository worktree and unborn bare HEAD' ' test_when_finished "rm -fr bare.git cloned" && git clone --bare . bare.git && git -C bare.git worktree add wt && -- cgit v1.3-5-g9baa