From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=103.168.172.157 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796192603; b=HjfrWu88lJtc0vUznkOWQ00wBV3F0LjvdZb0fsYhaBbtlotDxbnXj0EO1c87pvbuOLGL FK/rMDQMyRDzUht7LAnCoVviRtVttl546kxFVdb01gk7vsnbOVgs+gLKBja//FUMWDp9n 2WuYkl0p36TVIkiER1iEw3mKj2sxQEc3LjApE8G9LHiC1jfZcOYsZEnXqYVKHDjw1z2RU SFrM0Lvw2raIZm5VHuvBbRgr+UqLv6DKEfdlgKtMU2IIn/oRcrtS9iDirWs4YG/ReEBZ0 AzUsqYX24Ypa1m98axiODJBN9RaPnFVCrPQ00DI38V73ZeIC2kJ1wIn90LLNU/gy2ag== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796192603; h=DMARC-Filter:Received:Received:DKIM-Signature:DKIM-Signature: X-DKIM2-Info:DKIM2-Signature:X-DKIM2-Info:Message-Instance: X-ME-Sender:X-ME-Received:X-ME-Proxy-Cause:X-ME-Proxy:Feedback-ID: Received:Received:Date:From:To:Cc:Subject:Message-ID:References: MIME-Version:Content-Type:Content-Disposition:In-Reply-To; bh=J0wEsOAH9pRfoY1i+/lJB1AhDMwYb1Otml5rRKkcTss=; b=Trtm116WNFDRYYw3oazsNwidfKm9pc3xOcOgEyP20cJJqXu24YuSbUeFj/ZI3BMIFScD ZFNqjWlO7j7fQuWDCG/P+3dWmvykygE9mSAbEPufzATPic91EwPToGN89ylOXbytryQzV T2O4y+esCPJ0E5XtXWVMk3cIw1MmtgoHHf2Yvbsf1ZGHEVGAMh5UCvTtkqQKSEi7SD1gW zxuzgAgfrpYdr0byMo30ELd18PEwOVQ3hPRbpENAHg3MU5yKtnOSFdFklTqC7Vdu3scYU lY/kUyDqaXUZVxmeFY6QKyThDacuQhKX5ny+iDbHGPibuHCz16ZUkRGL9OukAg/oRPw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=pks.im; spf=pass smtp.mailfrom=pks.im; dkim=pass header.d=pks.im header.i=@pks.im header.a=rsa-sha256 header.s=fm3 header.b=lwHSfZtu; dkim=pass header.d=messagingengine.com header.i=@messagingengine.com header.a=rsa-sha256 header.s=fm3 header.b=EnLIgNUM; arc=none smtp.remote-ip=103.168.172.157 Received: from fhigh-a6-smtp.messagingengine.com (fhigh-a6-smtp.messagingengine.com [103.168.172.157]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C1B02606A31A for ; Wed, 2 Dec 2026 06:23:22 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org C1B02606A31A Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=pks.im Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=pks.im Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key, unprotected) header.d=pks.im header.i=@pks.im header.a=rsa-sha256 header.s=fm3 header.b=lwHSfZtu; dkim=pass (2048-bit key, unprotected) header.d=messagingengine.com header.i=@messagingengine.com header.a=rsa-sha256 header.s=fm3 header.b=EnLIgNUM Received: from phl-compute-03.internal (phl-compute-03.internal [10.202.2.43]) by mailfhigh.phl.internal (Postfix) with ESMTP id DEBA0140019E for ; Wed, 2 Dec 2026 01:23:21 -0500 (EST) Received: from phl-frontend-03 ([10.202.2.162]) by phl-compute-03.internal (MEProxy); Wed, 02 Dec 2026 01:23:21 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pks.im; h=cc:cc :content-type:content-type:date:date:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:subject :subject:to:to; s=fm3; t=1796192601; x=1796279001; bh=J0wEsOAH9p RfoY1i+/lJB1AhDMwYb1Otml5rRKkcTss=; b=lwHSfZtuTzvCbwwAyUZxdr38nl HsNQiL2H1Rtr6vTw8hXH9iIsHdtb5w7tkYyN6ZtF7huz6wmFr4TIZ4apU/H9oYZf KGmdTHpNt6FRD/i3z8u+lwquij5VduSPkeH5zEY0SppAJXGone+cMGw3qRYEy+IK cenV3d3I8RlcZaZdnaV9P758NwjtffXBPubriNmy02k2Nus1RUvlZqlV/btxGVDJ 8R0cebXTVwGJhoIlnXSCV4ao6qTeSH4Tn//5pEjy1QEQItffkkgXbsRC458HRKs8 OcAzChY2w64Yz5nflSeND39rTsmBUDkVfHeZZHYaag6bVo9D4UXN6LB2HdXg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type:content-type:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:subject:subject:to :to:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm3; t= 1796192601; x=1796279001; bh=J0wEsOAH9pRfoY1i+/lJB1AhDMwYb1Otml5 rRKkcTss=; b=EnLIgNUMJn6mkhe0dknKC98YP9y/7zBpiIhYcMlzzXXoJCQ8VaM X9RxhXdGQTmazfn81mfgwIWhcXQy/xMzujizv69jRNLUT9mUK0tCiyZfKhJPs4+Q sPDV0X3KChm601ENjdYrKy0j6F0Du0eQ64K2GOegjOZmxuEBEmvw270u7hwfuYi5 c43zfkQT9DSTC9X6pBcpeW2qVBE805wLPXeTcepE6AM4w7HdqZ9PbXQoXaqy72tt Tsqw9wkILzumFNTqsA3EcepvtMIdh5/rwYBE676EB+Pn1F3DLzsTVfZg68sgKkFZ 9Odzrx2XZGG1JmHjs0r2+56e0ad/yIjs3ZA== X-DKIM2-Info: draft=ietf-dkim-dkim2-spec-09; repo=github.com/dkim2wg/interop; date=2026-11-03; sw=lmtpprox; action=sign d=pks.im a=rsa-sha256; DKIM2-Signature: i=1; m=1; t=1796192601; d=pks.im; mf=PHBzQHBrcy5pbT4=; rt=PGdpdEB2Z2VyLmtlcm5lbC5vcmc+; s=fm3:rsa-sha256:XYU3BVmE7DfqT42fLPOdWDdaeJV70FAKHDDgLYdWu0KvdWF PJa+2NStsaXl29nKMg0O341fJUz8wXnLi4Q4y2duPA7kasUQExFF+SjJe17/qZlz OMHkQCjowk1g3zjtMc8sxYfJUdTxCBz8Wh/ELH8EUiWcanATy61SsPi4JODT6K7K nPlNFRWQMwXWX8jL8qrZSfugzg04xKd+PJj/sgQujmCM8ZWCzSvRxAZ6UDfxY+HC TkkmH9La6zMRef9lZPT/fCc4YOVhehUkqUasjR4A1ocJHgyBduvM1UwLh5z3U0rG fnf5k0atWRb0HCTchheKB5KVhW7nlt0k2+2dWiw==; X-DKIM2-Info: draft=ietf-dkim-dkim2-spec-09; repo=github.com/dkim2wg/interop; date=2026-11-03; sw=lmtpprox; action=mi-m=1; hc=12; hn=cc,content-disposition,content-type,date,feedback-id,from, in-reply-to,message-id,mime-version,references,subject,to; Message-Instance: m=1; h=sha256:VnszNRXk+wC6UD9jJZkWjuhdrE5TfLCQmF2C4pdQHg0=:3nH5ARhs0l8GMWI4o1De4Jn1GIbnSVhPlV/vFk5GDK0=; X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: dmFkZTFid7RnpTZSoZBqJ0vcf0TsnNPOrXWrz7PLqydCa3Bfa0nk7UtGJ24BdSNMjek7hX WHoaGSnAZjB3ZgnHCILKTUX2LvJuNc5msayMR1kwKTITYsbVmWSKUnzcQLwSd4184dVEpi EhhalYkWiOGDAMwZU8stBsqWDVDKtEtNROiLlxCtz9DECV2xil5x1YVEUo+bVbty8wTZSv B/0pMCRQ5PNTIYCkJEqRsdbhE7Lfjy9kBY3rKvv3w/w7PO+OrH4bMoigRcmRKXZYHvyBsV Jhwp3G1SxSkjRm+VqBvYj7ZLICwdmwgOWfjyF3SeWiZ0LM4y6Y5dzOj2alM6EoA1M9lnfP BkSQNx6Dom4wdt7/TmC5+XWDJ5qQYcP/M2JPlLH9ReOgFiu8f6MMUY9IbR/pwm9nhPkEwK 84ay9s9wbZB3hcN4Zb3+Scrkdprs1qP3V9covwyyvH9LZhTL9vMekxlSTUit/dBLjtm2yy 8wQTHizF+8fGjjug0/8bO9djN23j6oA3b4WvYIxfUevzY9CmSmH5J5Ol5Q7Bn408rUtUku KM7dDkOACnMDVNMWmcmnwbvOF9CaQcXFvqSUr4wkTJAcl/zrUUb7eNMvVjDx3xcDFUuT65 HNNqHxvQvHJecegy0KfbpoTbl6SZ87JbszM5xfov2VgyFOXoAXoiU0AQ3XOA X-ME-Proxy: Feedback-ID: i197146af:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Wed, 2 Dec 2026 01:23:19 -0500 (EST) Received: by mail (OpenSMTPD) with ESMTPSA id d9f41c9d (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO); Wed, 2 Dec 2026 06:23:17 +0000 (UTC) Date: Wed, 2 Dec 2026 07:23:14 +0100 From: Patrick Steinhardt To: phillip.wood@dunelm.org.uk Cc: Aniket Gupta , git@vger.kernel.org, Toon Claes , Junio C Hamano , Nikita Bobko Subject: Re: [PATCH v2] history: refuse to rewrite branches used by other worktrees Message-ID: References: <20261123103911.98860-1-aniketgupta3001@gmail.com> <20261127173252.7794-1-aniketgupta3001@gmail.com> <3d2e9653-87ce-48f4-a154-2b5a1a31a84c@gmail.com> X-Mailing-List: git@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <3d2e9653-87ce-48f4-a154-2b5a1a31a84c@gmail.com> On Tue, Dec 01, 2026 at 04:37:37PM +0000, Phillip Wood wrote: > Hi Patrick > > On 01/12/2026 13:18, Patrick Steinhardt wrote: > > > > I'm probably missing something, but the way we handle `head_target` > > seems weird to me. It is getting resolved to whatever we have checked > > out in the current worktree. But do we even care about whether the > > currently checked out branch is used anywhere else? > > It's confusing if HEAD gets updated in one worktree because a branch was > rewritten in a different worktree. That's why we have checks in "git rebase" > to avoid rewriting branches that are checked out in other worktrees. Yes, but we resolve `head_target` only for the current worktree, we don't ever resolve it for any of the other worktrees. That's what's confusing me. Each worktree has its own HEAD, so we'd need to verify each of them separately, don't we? After all, rewriting history may cause us to modify an arbitrary branch, and if such an arbitrary branch is what HEAD points to in the other worktree then we suffer from the same problem > > What I would have expected us to do is that we take the list of pending > > ref updates that we compute in `handle_reference_updates()` and verify > > that none of those refs that we're updating is checked out or being > > rebased/bisected. But as far as I can see, this check here comes before > > we have even computed those ref updates in the first place. > > We need to do the check before rewriting so that a user running "git history > reword" does not spend time editing the commit message, only for us to > refuse to update any refs. The only point in time where we _need_ to check is when doing the actual update, because this is where we may end up breaking the user's working trees. But I agree that we _should_ also check before performing any rewrites because that's simply a better UX. > > So we're verifying the pre-rewrite state, not the state after already > > having performed the history rewrite where the ref updates are now > > pending. And consequently, I think we don't reject some updates that may > > happen in worktrees. > > Ideally we'd find all the branches that we want to rewrite, write those to > "$GIT_DIR/history/ref-updates", then walk all the other worktrees checking > which branch is checked out, being rebased etc. and read each worktree's > "$GIT_DIR/history/ref-updates" to see if there is an active "git history" > command rewriting the same branch. If a branch that we want to rewrite is > being rewritten by a command running in another worktree we'd remove > "$GIT_DIR/history/ref-updates" and error out. "git checkout", "git rebase" > etc. would also check "$GIT_DIR/history/ref-updates" as well. By writing the > list of refs we want to update before checking if any other worktree is > updating them and removing the file after we've rewritten them, I think we > avoid races where two commands started at the same time try and update the > same branch. I don't think we necessarily need to implement that all at once > though, the checks added in this patch are a good first step. We can fully avoid the race by doing the checks when the ref transaction is prepared though, can't we? Well, with reftables at least its trivial. With the files backend it's a bit of a different story though, unfortunately. Patrick