Article View: linux.kernel.git
Article #2719Re: [PATCH v4 2/4] doc: for-each-ref: say how to read %(worktreepath) safely
From: Phillip Wood
Date: Mon, 09 Nov 2026 15:10
Date: Mon, 09 Nov 2026 15:10
59 lines
13475 bytes
13475 bytes
Hi Ben On 09/11/2026 12:36, D. Ben Knoble wrote: > On Mon, Nov 2, 2026 at 1:29 PM Jasper Mayone <me@jaspermayone.com> wrote: >> >> The path that %(worktreepath) gives can contain a newline, which >> breaks a script that reads one record per line. Say how to avoid >> that: use a quoting option, or end the atom with %00 and look for the >> NUL before the LF that ends the record. >> >> Also say that only one worktree is shown when a branch is checked out >> in more than one worktree. > > 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. > > Has that limitation been lifted recently? No, it is not encouraged, but it is possible to checkout the same branch in more than one worktree with "git worktree add --force", or "git checkout --ignore-other-worktrees". Those options have existed for some time. It's also possible to bypass the checks by using "git symbolic-ref". Thanks Phillip >> Suggested-by: Phillip Wood <phillip.wood123@gmail.com> >> Signed-off-by: Jasper Mayone <me@jaspermayone.com> >> --- >> Documentation/git-for-each-ref.adoc | 7 ++++++- >> 1 file changed, 6 insertions(+), 1 deletion(-) >> >> diff --git a/Documentation/git-for-each-ref.adoc b/Documentation/git-for-each-ref.adoc >> index a7b31e8aaf..9247737aa7 100644 >> --- a/Documentation/git-for-each-ref.adoc >> +++ b/Documentation/git-for-each-ref.adoc >> @@ -183,7 +183,12 @@ but if used together the last option is selected. >> `worktreepath`:: >> The absolute path to the worktree in which the ref is checked >> out, if it is checked out in any linked worktree. Empty string >> - otherwise. >> + otherwise. If the ref is checked out in more than one worktree, >> + only one of them is shown. The path can contain a newline, so >> + use one of the quoting options such as `--shell`, or follow >> + `%(worktreepath)` with `%00` and parse the output by looking for >> + the `NUL` after the path and then for the `LF` that ends each >> + record. >> >> `ahead-behind:<commit-ish>`:: >> Two integers, separated by a space, demonstrating the number of >> -- >> 2.56.0 >> > >
Technical Details
Message-ID:
<3b97401f-5579-456e-ba62-c7a0fdb88d23@gmail.com>Path:
mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!git+bounces-74938-linux-kernel-git=dewy.ruReferences:
<20261030142137.54750-1-me@jaspermayone.com> <20261102182930.3511-1-me@jaspermayone.com> <20261102182930.3511-3-me@jaspermayone.com> <CALnO6CAjWNsj=X4fp5rst+yCTo2FNVH6g=xt4V=b+pwG68gVXg@mail.gmail.com>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!git+bounces-74938-linux-kernel-git=dewy.ru
From: phillip.wood123@gmail.com (Phillip Wood)
Newsgroups: linux.kernel.git
Subject: Re: [PATCH v4 2/4] doc: for-each-ref: say how to read %(worktreepath)
safely
Date: Mon, 9 Nov 2026 15:10:17 +0000
Organization: Usenet Network
Message-ID: <3b97401f-5579-456e-ba62-c7a0fdb88d23@gmail.com>
References: <20261030142137.54750-1-me@jaspermayone.com>
<20261102182930.3511-1-me@jaspermayone.com>
<20261102182930.3511-3-me@jaspermayone.com>
<CALnO6CAjWNsj=X4fp5rst+yCTo2FNVH6g=xt4V=b+pwG68gVXg@mail.gmail.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
logging-data="384917"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:3G4TRkAMvy/ndoSegw8h/wF3O18= sha256:Y3m02g6TEFrk1+Lv5N49DeUxwcudYX0XqXrcFZ50W2s=
sha1:5yC0v1CuDtRhvNi7OaMKo7b/ufI= sha256:iP+q6onKFPG9tNHKJzAAAopjFbJ4g2IIO3Z8uhZokao=
Content-Language: en-US
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 4FEA3113845; Mon, 9 Nov 2026 18:13:11 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.049
X-Spam-Status: No, score=-3.049 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, FREEMAIL_FORGED_FROMDOMAIN=0.001,
FREEMAIL_FROM=0.001, 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=gmail.com
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 YVPxDdeVPJWY;
Mon, 9 Nov 2026 18:13:07 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=git+bounces-74938-linux-kernel-git=dewy.ru@vger.kernel.org; receiver=<UNKNOWN>
X-Authentication-Results: OpenDMARC; dmarc=fail (p=none dis=none) header.from=gmail.com
X-Received: from sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10])
by mail.dewy.ru (Postfix) with ESMTPS id 8C0B211370E; Mon, 9 Nov 2026 18:12:59 +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 02194E71D7; Mon, 9 Nov 2026 15:10:28 +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=1794237027;
b=YFdBseVmKANcyCRZVDv2GJ/TbgAIAqwJQn4CRSp4N4ATWKE9Xv+Xv+1lwF1yT1sYEFKs
5L+QlZuIE4S2Vn62+jXCX8ajnYPIYEjChMzkMKmzb2WGybTPNv5Nc0bZ3gFYy516bQTC8
hI1OvI7KUSIztUoOjsRoLt1UXuaVhq9u1i8JG7cjWU3BQleW2IeDYrgWaa/kOozJBsodj
giTOiuFmAAmZCHGqCiXlSauenm6Tsvas+tsworcm17dkX4hgOG0YrN6F02g8vmf9e8SPY
oAso+AECgLyxhGCzXZeckCwXFK8sD2UxZBCBWSBe6Q88gfoyjWlwKoR20bR4szpr8Hg==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
a=rsa-sha256; c=relaxed/relaxed; t=1794237027;
h=X-Original-To:Received:DMARC-Filter:Received:DKIM-Signature:
X-Google-DKIM-Signature:X-Gm-Message-State:X-Gm-Gg:X-Received:
Received:Message-ID:Date:X-Mailing-List:List-Id:List-Post:List-Help:
List-Subscribe:List-Unsubscribe:List-Owner:Precedence:MIME-Version:
User-Agent:Reply-To:Subject:To:Cc:References:From:Content-Language:
In-Reply-To:Content-Type:Content-Transfer-Encoding;
bh=AayIHd7AQ/NyA99rv55CkOu4+HrkNHIa9jN6EX8W3g0=;
b=VN1bWWaiqGmZVjAXgdL8L1pBsytJhc9YxtXEAM+lC3w7ew/ME6ZRVCH6Lm80VLESLPkT
q9m66e5lwESunIFic7PoQsoExA2c3GMnQICGuJhYqIuEnkdrCnMn6O+5WxPgE5VlEPGAl
y4WQiqE/xHVXuTearhXecGSikvD7kNWNcvfMNDiC8i+l7dOISCZfx/AeRXXbgn+D7vSSD
W+WMOW03xZASowSxG9SBXFPXqN2x2NYx+VVrtK6I/rhxc6N4JRO5gR0RdHvMKqtlszpgN
gF5/RSW5eNcZ3bU2HmCXLebwgYzYXm54pWe0xXhs+FWr/TigacUsGDyC3cv6QRxT2Pw==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org;
dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=UFbhOq5s;
dmarc=pass header.from=gmail.com;
spf=pass smtp.mailfrom=gmail.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 3E66E606A32A;
Mon, 9 Nov 2026 15:10:27 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=UFbhOq5s
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.218.42
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
t=1794237026;
b=NBX39WyXoVSHcFnJQF4uG1C1N7NTw9X9gd3c9h4q6Q1ETNfoLscCy30N2BJYSJNBAeh8
FfKYDluPOjYhVkzZYn+cualrvBhkoIytek3LVuc70a2rsc21JIQAxTy+ekIo4JKOPNz91
KnYbuDc55fo1/L/fFXxlKD2TcdvbEqwt7PUb16tVj+1uWCfalWFRAR7uMXlLL8Dy8pB9h
cjbSIvWy2EUpLJwm7x56oMHxzSB+WIX3o1RnfisAXdEidp+3qA1MHU5ZE9hCEG5iiEKZE
7x6sEIwLo+z6+WcKgFBE3qemKB4Kj98Txj9qqx71G7ESxYi9AWmxnnjnOctvjKOnfkw==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
a=rsa-sha256; c=relaxed/relaxed; t=1794237026;
h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature:
X-Gm-Message-State:X-Gm-Gg:X-Received:Received:Message-ID:Date:
MIME-Version:User-Agent:Reply-To:Subject:To:Cc:References:From:
Content-Language:In-Reply-To:Content-Type:Content-Transfer-Encoding;
bh=AayIHd7AQ/NyA99rv55CkOu4+HrkNHIa9jN6EX8W3g0=;
b=f+iQfda1TLVkzdeo56oR2rkPUR/UqvtzN6ZxkMetixgC+7tIIfRk10ZUSyGu6rAmkvy5
Yqh0K7V/QfQeGShi5BZxjGngr3WZFdTE+R8sAs4ivNw2XmFKJHfjgIJh+OPBv0kBk3cdr
mphM9ZMt5Blorxj7xB8B+Rk7Sq5fSeWCSdYkVvXCT38qkSzmF/P0XUBVpjBQZIDe/kD2/
N8151zZqRPWmF36pkyEPtMI3u1F5LsHjIuvB5Sf9oVbpzVGRlXJZ53p8TwlO6nbT3BShR
xXjYdso8Uyd0JX0InduhqYD7Ihvwg9D+0PCZjuzMdi/IZtgOIvNiejnoQBPOvLBH4+w==
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org;
dmarc=pass header.from=gmail.com;
spf=pass smtp.mailfrom=gmail.com;
dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=UFbhOq5s;
arc=none smtp.remote-ip=209.85.218.42
X-Received: from mail-ej1-f42.google.com (mail-ej1-f42.google.com [209.85.218.42])
(using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)
key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256)
(No client certificate requested)
by smtp.subspace.kernel.org (Postfix) with ESMTPS id 09F52606A325
for <git@vger.kernel.org>; Mon, 9 Nov 2026 15:10:25 +0000 (UTC)
X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 09F52606A325
X-Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com
X-Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com
X-Received: by mail-ej1-f42.google.com with SMTP id a640c23a62f3a-c4322d310e7so136044366b.0
for <git@vger.kernel.org>; Mon, 09 Nov 2026 07:10:25 -0800 (PST)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=gmail.com; s=20260707; t=1794237024; x=1794841824; darn=vger.kernel.org;
h=content-transfer-encoding:content-type:in-reply-to:content-language
:from:references:cc:to:subject:reply-to:user-agent:mime-version:date
:message-id:from:to:cc:subject:date:message-id:reply-to:content-type;
bh=AayIHd7AQ/NyA99rv55CkOu4+HrkNHIa9jN6EX8W3g0=;
b=UFbhOq5sDvragUbOYgtoZCO0RoSID2GQ0kyOFk/ZD75joDkE4qx+yMzQ/QWoagAG4c
heg5Z06Fq8Af0e7Xt560Z7eY8wCFS2ztlj0B5SYFxel9rM+mYiw4QW5y2C4/fVNUg3xw
akKuZFwPkWYMt/tNd2TBy7X8DGJq/5S8PCWftpK+bkJJy2MXQx54sozQZszib771/pyl
qmdYiMqFKYp4FnoMcKhYI6dv9SMfulS/Msba3vRWkjq3V9M2aflaxKE/yI8GV70n0Ejp
ztQnWz4LuulAoL7kVUFeg2NhfO/dCefFhWJqnPzYVCcIbRH7JxzK2KldUlEYseinhzTg
c58g==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=1e100.net; s=20260707; t=1794237024; x=1794841824;
h=content-transfer-encoding:content-type:in-reply-to:content-language
:from:references:cc:to:subject:reply-to:user-agent:mime-version:date
:message-id:x-gm-gg:x-gm-message-state:from:to:cc:subject:date
:message-id:reply-to:content-type;
bh=AayIHd7AQ/NyA99rv55CkOu4+HrkNHIa9jN6EX8W3g0=;
b=mprz4z7Dq0v6bqxQbu4EQ/azDa1WirGXD2pehp6D1sDg5eeldrb1tab36nJYkFwLnu
Fr9S1lmKExTF0u+mvDBjLOu4/B+wgMc+5g5wiF1o/e2Sm74XgctvdLWNSaPIiNbyo6m7
uLITVkzviDvJ1sN2kXUqG/dsJy4WnPnr3aV4ry3tu1u7GAD+1+SGWImz/O4eTcAB71uR
Tofk8GWFrDSWU9WkJy46aZaufAMY54R7JF+vyyIcaVsNcmb7LlFlHHXAF7g8vtnzDH6p
vAdrnYRoR1B6a15olzOoMp7h9UyXtZuOCknQ2D3IWdvUWVHVZ+eDI+Epk9O1tbTHnp3D
wjiA==
X-Gm-Message-State: APuU4Z9YWUXU9ZvZyFALRNHwTRHvM4flfCEFrjtdyewPXBIszHBr886z
R0uGSjNLyiEkqakDtxgyPOr6j8RSwT/F+J9DlLdZyjbUxFZtF1Do577P
X-Gm-Gg: AYBFou24bUJcwciZhXjculhUFNNi5aCJ36NWApFtucSx5JodHnEBgbjJ+uWS3ptQ5tw
A/DVQt4BPwhFgruK8OaiCq4fxSJJIdTiKY44Iu2ZGxaI6M2Olcke7xF7FFR7oGuBiMqBSXRAASR
gHcx0gQmFnF1pHGv49WBMBzrUkbLKsdYkyIX2wpuNWUSUNWi+Z8HMu/uuleYelYU7QseCwz0jwu
9FZ2JO+b1LaZ3kUtb9qqS2w6ZyWCZQA/NfLFA6FZpDti6Eh+77Ii5wj23nKFrQ+3ONhLjcLeHnn
JoFrEwE0JKRksr89g4u/6G47hYfcmEdGk8pnbP9w2QDkVQaRlPhiLnPYtP61VowoO+lnpHv6Xu0
//bou8pvaSQ1ggfmO9lE9lCLfZygvVI/UXCF/aZ3pXg9qwm7uoumYuYtq/YkdUl9+L+oOhZc0ge
p43Pe+3RcSXKmHSF9+xxdThpSyBSTp/yW+5wKwZAz0BEaPCbdAfgMudiuf98NBr2DeQW8c4D26a
qpDRt2zoyRO8xvg/kJvKavc3HNVMF4bokegsYqcW4w1MI4IoxPfCriMbHvjOu04tDZYOZsBiFTU
Igiiow89bfvlHaFNP6+VufVwL8EW1jNNoVmpb0qEZpxfzx1HiYhS5cJoeDNN2ECcuxIgNqFAmh/
MwKsPuA==
X-Received: by 2002:a17:907:c1f:b0:c43:bf29:1517 with SMTP id a640c23a62f3a-c4d6d4a202fmr290177266b.12.1794237024257;
Mon, 09 Nov 2026 07:10:24 -0800 (PST)
X-Received: from ?IPV6:2a0a:ef40:724:6601:f3ff:aebc:61f8:d91f? ([2a0a:ef40:724:6601:f3ff:aebc:61f8:d91f])
by smtp.gmail.com with ESMTPSA id a640c23a62f3a-c4d68d52c49sm185320166b.12.2026.11.09.07.10.22
(version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128);
Mon, 09 Nov 2026 07:10:23 -0800 (PST)
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
X-User-Agent: Mozilla Thunderbird
X-Reply-To: phillip.wood@dunelm.org.uk
X-Cc: git@vger.kernel.org, gitster@pobox.com, sunshine@sunshineco.com,
kristofferhaugsbakk@fastmail.com, haraldnordgren@gmail.com
X-In-Reply-To: <CALnO6CAjWNsj=X4fp5rst+yCTo2FNVH6g=xt4V=b+pwG68gVXg@mail.gmail.com>