🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.git
Article #2746

Re: [PATCH v4 2/4] doc: for-each-ref: say how to read %(worktreepath) safely

#2746
From: Junio C Hamano
Date: Mon, 09 Nov 2026 20:17
37 lines
14310 bytes
Ben Knoble <ben.knoble@gmail.com> writes:

>>> I was under the impression a branch could not be checked out in
>>> multiple worktrees due to possible races from each worktree performing
>>> updates; or at least, that the porcelain would refuse to create such
>>> worktrees.

Phillip's answer covers everything, but I am not sure if "possible
races" is a good explanation to describe the reason this is
strongly discouraged.

You checkout 'main' in worktree A and worktree B, so their working
tree files and their index files all match what is recorded at the
commit pointed at by 'main'.

You then make changes and commit your changes in worktree A.  The
'main' branch now points at a newly created commit, and the working
tree files and the index in worktree A are in sync with the new
commit (note: unlike the initial state, I am not saying "all match"
in this case, as this commit may have been a partial one.  The
important thing is that from the end-user's perspective who has been
working in worktree A, things are consistent without any unexpected
change).

In the meantime, if worktree B weren't doing anything, its index and
the working tree files have not changed since the beginning.  Yet
because 'main' (hence HEAD) moved, "git status" in worktree B
reports as if it reverted the change made in the updated 'main'.

That would be a grave confusion, and that is what we want to avoid
by forbidding a single branch from being checked out in multiple
worktrees.  But given that worktree B was doing absolutely nothing
while worktree A was doing its own thing, I would not call this a
"race".  It is something else.

Thanks.
Technical Details
Message-ID: <xmqqpkwdyd21.fsf@gitster.g>
Path: mbox-mo1.pugleaf.net!news-lax.pugleaf.net!news-can.pugleaf.net!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!git+bounces-74974-linux-kernel-git=dewy.ru
References: <3b97401f-5579-456e-ba62-c7a0fdb88d23@gmail.com> <4B1D5AB6-7E40-4633-B804-752257DD0B67@gmail.com>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-lax.pugleaf.net!news-can.pugleaf.net!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!git+bounces-74974-linux-kernel-git=dewy.ru
From: gitster@pobox.com (Junio C Hamano)
Newsgroups: linux.kernel.git
Subject: Re: [PATCH v4 2/4] doc: for-each-ref: say how to read
 %(worktreepath) safely
Date: Mon, 09 Nov 2026 12:17:42 -0800
Organization: Usenet Network
Message-ID: <xmqqpkwdyd21.fsf@gitster.g>
References: <3b97401f-5579-456e-ba62-c7a0fdb88d23@gmail.com>
	<4B1D5AB6-7E40-4633-B804-752257DD0B67@gmail.com>
MIME-Version: 1.0
Content-Type: text/plain
Injection-Info: usenet.network;
	logging-data="442683"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:/Tvp6ROk98Rrhss6LI6xxCVIpKU= sha256:eQo6NrV8GBoQSF906rSFlGQrFMBF3uSmX0e8lX8fQV0=
	sha1:t1y8vtfPSis0h8Z+GB8klzFymvg= sha256:Wc2hWMgUWvX/ZQJE2GrVNDroS1DGRRC5vAu+Y/PqFk0=
List-ID: <git.vger.kernel.org>
X-Mailpost-Empty-Hdrs: X-Spam-Level
X-Received: from localhost (localhost [127.0.0.1])
	by mail.dewy.ru (Postfix) with ESMTP id DD5C4113910; Mon,  9 Nov 2026 23:22:11 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.051
X-Spam-Status: No, score=-3.051 tagged_above=-9999 required=6.31
	tests=[DCC_REPUT_70_89=0.1, DKIM_SIGNED=0.1, DKIM_VALID=-0.1,
	DKIM_VALID_AU=-0.1, HEADER_FROM_DIFFERENT_DOMAINS=0.249,
	MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001,
	SPF_PASS=-0.001] autolearn=ham autolearn_force=no
X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key)
	header.d=pobox.com header.b=bdLx5Yzb; dkim=pass (2048-bit key)
	header.d=messagingengine.com header.b=ixO71Unk
X-Received: from mail.dewy.ru ([127.0.0.1])
	by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024)
	with ESMTP id 192Ce9sH7Rq4;
	Mon,  9 Nov 2026 23:22:04 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=git+bounces-74974-linux-kernel-git=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> 
X-Authentication-Results: OpenDMARC; dmarc=fail (p=none dis=none) header.from=pobox.com
X-Received: from sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10])
	by mail.dewy.ru (Postfix) with ESMTPS id 8D2361138C2; Mon,  9 Nov 2026 23:21:49 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
	by sea.lore.kernel.org (Postfix) with ESMTP id 359F0328D9; Mon,  9 Nov 2026 20:17:48 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass;
	t=1794255466;
	b=G+YktPIWuwOZ0ZOU2FHlan46BU9Iz+1nAXvWZu+e3nmtR7VA6nKZS0h+lEAb2G5Gs9Qz
	 vggZZdMdG9NaqvbQAekUKNu119DPu+SGIJ8ZmmiiG9JBHmZ6vvmzbA0V055V7f6Rf1f0x
	 vmKChZ0QniQ1AInGDT8o/p3g4dxEtIfWVMhYCPmkdKjKBFtZ6dMX7Z7yGahV04q3IHf08
	 nvV8CIpAuyWapjxA4gTWPOuLzJaX3DCT4Y+Qu6D2k7cfPOrOTFYoa1O+aA/3ijUxD8OxH
	 VszpAYDsZrzJCLcrzza3529M/OJ5wDm3BDkS/ZEEgtGpPNN/LuRpf9LzqZmS9mXsuLQ==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1794255466;
	h=X-Original-To:Received: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:From:To:Cc:Subject:In-Reply-To:
	 References:Date:Message-ID:User-Agent:X-Mailing-List:List-Id:
	 List-Post:List-Help:List-Subscribe:List-Unsubscribe:List-Owner:
	 Precedence:MIME-Version:Content-Type;
	bh=WrY1wXw694MdVeSk9Vh+Xaq6swC4kIavKhtM0pmo9cA=;
	b=rlaBwIxte9oRz9wUsVVAfRRyhMMWDM9XgZ0IrdP3ZKZpSB3ts+/hqHX+6NGI3UEU78QJ
	 J6FcZoWJhg1F3Ir6H4/SD1PEgZtv2x8Ft6jMkOPqZNY2uo8sNPjOefXgXx/WNet9T0fNe
	 vg6l7MBVveiIPjzCwFDHa6nCHovax7gilSESr6IIFXxORjF0wpcjrodx27uGx0NFjPt2X
	 pnTksfieSrzVYOyMSw++MCQDtVERrTCk+iSQieao0186kYLaM661+V+AD5eHTY2QVQKvx
	 pSrbcv9BG5h55z8vyQunIJ8o184iGtmVM81xdK83MQ4vR68u6cI2S2cnBrqrIA0/IyQ==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; 
	dkim=pass header.d=pobox.com header.i=@pobox.com header.a=rsa-sha256 header.s=fm2 header.b=bdLx5Yzb;
	dkim=pass header.d=messagingengine.com header.i=@messagingengine.com header.a=rsa-sha256 header.s=fm3 header.b=ixO71Unk;
	dmarc=pass header.from=pobox.com;
	spf=pass smtp.mailfrom=pobox.com;
	arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-Received: from localhost.localdomain (localhost [127.0.0.1])
	by smtp.subspace.kernel.org (Postfix) with ESMTP id 9B427606A33C;
	Mon,  9 Nov 2026 20:17:46 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
	dkim=pass (2048-bit key, unprotected) header.d=pobox.com header.i=@pobox.com header.a=rsa-sha256 header.s=fm2 header.b=bdLx5Yzb;
	dkim=pass (2048-bit key, unprotected) header.d=messagingengine.com header.i=@messagingengine.com header.a=rsa-sha256 header.s=fm3 header.b=ixO71Unk
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=103.168.172.157
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
	t=1794255465;
	b=JYLrKRy83okKkfJiFvjEzcyvOqOR7Rsolo8L5ZJZDkWQej87FNAUinbg6SQ6c0btAE4+
	 cxmgN7YJJKhkWf8+b2AeHoVNKVkcLxgOMPCLyKmSi7aaxKURdno3BGonbzX6XN6eziiEE
	 BgJo+o4JQ3ddIrSWS0TP7SvRQnEdNhfn/dNv1+Ob3xT6roZkVt/rKDB5qGSVMo1jiHZVV
	 qR/OESFleCKQ9Hg86RCr6b8iu5bEjkSutrBvcW3pVeriaDkrFJ16GZ0x+u8yIznnLPN3r
	 qNqV2DLhXvzbgFp48/9zpq8EEIA4x/njFRuVQ0d/qvpFZPBFOi90hozX223aG4rFNqw==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1794255465;
	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:From:To:Cc:Subject:In-Reply-To:References:Date:Message-ID:
	 User-Agent:MIME-Version:Content-Type;
	bh=WrY1wXw694MdVeSk9Vh+Xaq6swC4kIavKhtM0pmo9cA=;
	b=N+3lrV+EPRk802+TjuOqVVsaUrN59ajAj51P99pD6sG5b8KxlEqvKi7C/VfU8pNMLOft
	 rD+OLuld6AMR49aVR+Pm0Zfjtt9r3Kd2Kwl9fMBXDKey5v7cb2e5pMO0JkGrShVn90W7K
	 ZYPS79qWmycIPgt1Ule1kvb2BV0aQEyQAQCbSjJPiYcsqu1htBBxqB4ix/j+7+gxLUKl7
	 9kttuxAasOcJTnfA86x2zg+aN2p9tgVmAZDzs1XkoYg8InhPJbKSGDqxq2UWBCW1jDfzI
	 uK3DDj4AEC0EsqefzAyM8p++vuKxjU5KFJcup+VrBc9XMyoh42dKcHBruseOM/B98BA==
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; 
	dmarc=pass header.from=pobox.com;
	spf=pass smtp.mailfrom=pobox.com;
	dkim=pass header.d=pobox.com header.i=@pobox.com header.a=rsa-sha256 header.s=fm2 header.b=bdLx5Yzb;
	dkim=pass header.d=messagingengine.com header.i=@messagingengine.com header.a=rsa-sha256 header.s=fm3 header.b=ixO71Unk;
	arc=none smtp.remote-ip=103.168.172.157
X-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) server-digest SHA256)
	(No client certificate requested)
	by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4F6B0606A334
	for <git@vger.kernel.org>; Mon,  9 Nov 2026 20:17:45 +0000 (UTC)
X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 4F6B0606A334
X-Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=pobox.com
X-Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=pobox.com
X-Received: from phl-compute-04.internal (phl-compute-04.internal [10.202.2.44])
	by mailfhigh.phl.internal (Postfix) with ESMTP id 9C5BB14001A8
	for <git@vger.kernel.org>; Mon,  9 Nov 2026 15:17:44 -0500 (EST)
X-Received: from phl-frontend-02 ([10.202.2.161])
  by phl-compute-04.internal (MEProxy); Mon, 09 Nov 2026 15:17:44 -0500
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pobox.com; 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=fm2; t=1794255464; x=1794341864; bh=WrY1wXw694
	MdVeSk9Vh+Xaq6swC4kIavKhtM0pmo9cA=; b=bdLx5YzbDu+kGutq9+cmNGSoAT
	1/XB2iZDc41rjZ61wUlPQ1g5Yioi22qwSaM71Ab4Hh6ShaXY3yCufCTeRzD7u6IP
	dUf1SEIwehbkClnP+RfXCaydToy6LRf7Fw7Xc1rxhnl4TFSM0ZfsU5lffnijGgl/
	+rvAj2ATNjacBgoybGKURr+VIQELwafJ2UXhlIAegem87CIZmLlkUaRsicOx0rpc
	bsieWgPZcDn6mzY9tYxcdzkWvZl1ORmMAIDpqNvrljXYwYYD8twgUYAkOGHQHLr8
	9OAJdYt0IYPNOGUM9u8vNhZmJ2F16W813S0jW5hjPxCz2Uwna3hQr+/gHK/A==
X-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=
	1794255464; x=1794341864; bh=WrY1wXw694MdVeSk9Vh+Xaq6swC4kIavKht
	M0pmo9cA=; b=ixO71Unk3gUukHuhOVtUKNmJOjEOTv9uUnDrhfKuu0gf8oVmEZB
	6WBNiQsGP4j/tbCzawKmnU7IZxU6CMLojWKcuve+SDMfFAJ2WrJmIa/LGtLgvT2P
	iIuIGA50r+SXVDHTo59D1aK/pphJVERPqET9qqIjgt9EpF9e/7xPYRog61kJVrW4
	TLKv/QaLbrbHGQE+vuApd/xt3tnV3hLXnkFqXQumD6L4pOMa1v75GJGufvjk88u7
	W29BGL3PiWYaYoF/Xp85+zlcTlNMuurmlSUO4c4SwFuhzvRulUUVPJEt2VqLqcOc
	dfXFsSssWNzZhKQHYfvlbYBvEJdSgaqjYkg==
X-DKIM2-Info: draft=ietf-dkim-dkim2-spec-09;
	repo=github.com/dkim2wg/interop; date=2026-11-03; sw=lmtpprox;
	action=sign d=pobox.com a=rsa-sha256;
X-DKIM2-Signature: i=1; m=1; t=1794255464; d=pobox.com;
	mf=PGdpdHN0ZXJAcG9ib3guY29tPg==;
	rt=PGdpdEB2Z2VyLmtlcm5lbC5vcmc+;
	s=fm2:rsa-sha256:D9l6dCjwCBeaV9UQA7eFB10kNxegR1mwc+m6EcQFgfB1NYm
	ZyU12xhV7+cSMaKM9BX/csyJr3kF3e23cDV/kfGSUePNN3jZLmMQeidebkJwfQeH
	s4Do7MFhsWp7971/ol3NEmaMhtae+TpDa6IG9jbVMKXuEfHOVCsrFBnbB110tDBE
	AQRKwZfsD90ZTmmzRQGag9L5Y5Ku8GOSwNRCVdVFKM7+srNig1URJKs8+sl4RvGC
	EzvPzCv45i8VdogJdjftYX3eq69EmNvHkk3VRD5PkKD3R+f+iYNEnc44sSpm6Ks0
	3pw+r/pSf1+wnnnAbZ7guzvQ/heIml7BKnnnHDQ==;
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-type,date,feedback-id,from,in-reply-to,message-id,
	mime-version,references,subject,to,user-agent;
X-Message-Instance: m=1; h=sha256:vDIsABzzMoCAzcLycQomL7dX4NnGJ8fXxHTtt57AbdE=:CuwnGsQWgsbEf2JltIiuoNYoSt9nDdYOj8QAKPkznRg=;
X-ME-Sender: <xms:ZyryaoYS2WDP-8EYTOTXO5gSG_qzqO_yuQd_UmRcl7-MA3_zyWk0Gg>
    <xme:ZyryatZkgv9BPg0IhZvhXd6pmNjQlo0gGrZHZtfHLlQIdoxc1la2JVAt9Wu5VmEq9
    66AZoC36d12JtZMvMQOVH-OVhD7US7HG-rTovKLUg9DZw_JbI91YKE>
X-ME-Received: <xmr:ZyryapnBo6LTeERkh8lRM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CryaqA-S9gH_-0kM2-WXqGgaNR09ihKY6fsv9ItqxIm1P9c0Qk6KQvU>
X-Feedback-ID: if26b431b:Fastmail
X-Received: by mail.messagingengine.com (Postfix) with ESMTPA; Mon,
 9 Nov 2026 15:17:43 -0500 (EST)
X-Cc: phillip.wood@dunelm.org.uk,  Jasper Mayone <me@jaspermayone.com>,
  git@vger.kernel.org,  sunshine@sunshineco.com,
  kristofferhaugsbakk@fastmail.com,  haraldnordgren@gmail.com
X-In-Reply-To: <4B1D5AB6-7E40-4633-B804-752257DD0B67@gmail.com> (Ben Knoble's
	message of "Mon, 9 Nov 2026 12:27:49 -0500")
X-User-Agent: Gnus/5.13 (Gnus v5.13)
X-Mailing-List: git@vger.kernel.org
X-List-Post: <mailto:git@vger.kernel.org>
X-List-Help: <mailto:git+help@vger.kernel.org>
X-List-Subscribe: <mailto:git+subscribe@vger.kernel.org>
X-List-Unsubscribe: <mailto:git+unsubscribe@vger.kernel.org>
X-List-Owner: <mailto:git+owner@vger.kernel.org>
X-Precedence: list