From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.222.176 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796196539; b=H+rqWnhN34yOqxACP1XVEO29f1MzIYHctxpyLmyGxmJW9+Lob2QFAVVhRhCng+AYDjI3 aUDax4T9BgqwezraDqpQVXkCmkEotyrXjESxxwHBA1+wjy/IW/i88nVFXULh5FbtJzOCO U4NzJCS4aYBDaPGUd+Pn6ydiC5ePLHxat/8GvmpbYh9MPiynUedGjyINo1cyl4U79Ggsp 6Q8/Q3fV5VgwhRQwxfr5GvkKVyHx1u7WOEI3vSmMIRwGbMmwn67j9LQ8eGuLEWD98HhUO f6IsJgxSapeKa7EliqJdfB52eLyAvIzf4jOYouqseJmg6E/Rulz56Upky9BwAejN34Q== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796196539; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Gm-Message-State:X-Gm-Gg:X-Received:Received:From:To:Cc:Subject: Date:Message-ID:X-Mailer:In-Reply-To:References:MIME-Version: Content-Transfer-Encoding; bh=ha1iS5MVJtTrl7n+2rsqliKQJHQul1FVZ/YwsQu8eSc=; b=REASxI5BDu7eHRwm6srGJ3c70YMoTtLOwLaQiBUo1DU2IqLfmOxE4VDj39QnTt1zjgVQ 2HxcRrEaCZ6qP5xAwUuPkf50KgBjEVTorNO4ybrj4wPUjMPj3NjZBMhentcYKyIMk+ACO tpQ0b3P0woPGaxjYAOQo162QseOmicKFVqM9H/YMLVSGuW39vnRibdScLkkQSJFPv9FBD PHraeZbXrnp1mRvlLZokR3OEJ0YYysy5OA3I0MNq57nRTSRQe1k8RXdJM86pWH+PRe6KZ pHdz8twgcDKWTPwQUIRWC9nC/PVXEIb1Sqk83viSJBEz/t5IERwM+bRQBVv8xznOE5w== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=jaspermayone.com; spf=pass smtp.mailfrom=singlefeather.com; dkim=pass header.d=jaspermayone.com header.i=@jaspermayone.com header.a=rsa-sha256 header.s=google header.b=baEIzVCT; arc=none smtp.remote-ip=209.85.222.176 Received: from mail-qk1-f176.google.com (mail-qk1-f176.google.com [209.85.222.176]) (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 94F8D606A335 for ; Wed, 2 Dec 2026 07:28:58 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 94F8D606A335 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=jaspermayone.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=singlefeather.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=jaspermayone.com header.i=@jaspermayone.com header.a=rsa-sha256 header.s=google header.b=baEIzVCT Received: by mail-qk1-f176.google.com with SMTP id af79cd13be357-9496577d4c4so1429788885a.1 for ; Tue, 01 Dec 2026 23:28:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=jaspermayone.com; s=google; t=1796196537; x=1796801337; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=ha1iS5MVJtTrl7n+2rsqliKQJHQul1FVZ/YwsQu8eSc=; b=baEIzVCTcybf/6Aq1NxL+KSbYPuWSH165TnoZDDwgLJlfgIJhYW5xQACRZLOQoQj+U P8PYODwbp/qQdnkxSCkts/AFMftJa7NK1iF3uOchPeeBJ3Dq10IG00QFcDFQu5pJzz21 pi3fNsI/YXz/I+zmepA+Zy+H8S9FfD+pGZZ44qEutn/pStEG5f9dgsRgLOBvRpwQ/dbY /Uj60QXQfY9Ia9H8hBut3LhRyt/bI68aOD4ED+Ds778hTSN4CuL+/EYokR5gtnZIJI9d O5n0JCnId8N12fosThdkr332ktCZpGYujh5bkqXnvL6yIhgz1tSsvPqApw4W5yqWA9TH uPDw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796196537; x=1796801337; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=ha1iS5MVJtTrl7n+2rsqliKQJHQul1FVZ/YwsQu8eSc=; b=fmTnY8LZfyeKCmA/QLOLOZIvSDoS21DdGVk1rtk4IommMhbNWryJzdm8/JNL8tJQ2H 62EYE8kmILsgUi2LOZW6QPEzQrT9neE+a9RVgwY40aF9K9slJVR9xw3gmBacatYNv0Eg wvsdE6qNzFb6tGZKJoTfJWgiGhmQQIzZii8f2N2uF49onM+JU1E+aUrSKqtkPkHYB7xx wy4uZWpMf5/VsHPiWQPZBHJeG96nsx2vCJRVw6klvcGJ5M38tQUwfjBx9zQUu2ABpfzs vyDoZ/lNz9EqKSTeEc/0hbVtti+KDPgJjQJUkzIeLILQxfda4XDGJ36uRc+fioW+OK8f vvpg== X-Gm-Message-State: APuU4Z+6/j7Z8R3TtDywlaQoh78uOUTg0wJMksT51PIhIE57Qb1IwkhF krQQpVpQHR08GJ+/cdAhp9WKQx676xjgoWzmnQL/ef2FW/eadNAlyles9vfbWpDrs2u4qf1BCaO AbAj+Wrh+bVmKSJnqcl1CiqZxc0AxFXwxXSTi81SqulYxJ8aTJ2BtLSLAQPLSr00dDw8tccJFuL AE+kXVAyOJnJhqvZ8bZhP+JBNlRNci/lDRs7PgeMlXkhldwNFUvk7Q9bz//VIqW2qK5Lk+aaeV+ EWypL1BhvY6pVUFKtrPmsv14MsI3mP0tuMpbHMQMNXv/Q== X-Gm-Gg: AZFdTZeB1YJfn7aYayH3s7maO5pntjspAdak1ptT9+KrsRy4fLECdWNNqFh8URYJiwR zWgGU+xrX2iAvRytOEspH/sDyIFGFdMoAKW34ycANmlAso73oezkpO0mt103MOmxs8YuBa7HH8X iRClkWffFa+GFUxXZUEfh9fZFF/ijqhxdbNP8WlLV586TxiBiOREo+EvSrvQLDVi+3CI5puSn85 MNMCz2PI1v4dWgrcLRx20OLK23dmIDgUklpr8MOWo6sZ7yfJwSm0/3ko/8KjgIdsreDyxOFszb7 B4BxELkMmBHlw+dnzBXq77p4SKDzkrq+bImLxyQSTDnfYP09mERHBy8WytRxZFohb+fXX6IhYBj FAc50ANOqyeO++QeGTm8/h/IyBBVh+yH6pSWuMiI7plURE2GaRDzw0YCQTBu7ISrY6jZUNi57ee rHLtRIILaFl5vPvWR6KY5lk6tG5mqIbbzGQUPG3ldmG8f6fpVUrDHa0VsOkHATXJIT3r8039TLb lZGlfDqi2d/+C1X4gjNodUrvnpqAEiziCfOckNN1FLV9tdEfW9Hya3ItseqjzTxyHW1NReDLmtT JiL5NzS7s4vCtP0cT6i2aO9FklEZCtZ/hmw5Tm3/I/vC0uyFpz480Sl7dNytqWckDyaW/KFp3ik A2D2MTbiG6sNT7lBQLmphIO/St/LUS030KNBU0QqPlGIydL3/uMcAvo7AwboT+A/KZicMTnfdCL 80vILuZYAb9PSmyC0arLeKHCr4EMBL9MiIeYGRll22XdMXG6W8V+UZ0Mpm9eDOxiIriPlKts9sQ DLYa1GEGhVbzKa4b1zQymeKuaWI8zpoQ7NuHBK289QYTC+Q X-Received: by 2002:a05:620a:4409:b0:949:5f22:e849 with SMTP id af79cd13be357-949b37208dbmr7147229885a.35.1796196537521; Tue, 01 Dec 2026 23:28:57 -0800 (PST) Received: from remus.wildebeest-stargazer.ts.net ([69.43.65.112]) by smtp.gmail.com with ESMTPSA id af79cd13be357-949bb35005dsm3021240685a.11.2026.12.01.23.28.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Dec 2026 23:28:56 -0800 (PST) From: Jasper Mayone To: git@vger.kernel.org Cc: gitster@pobox.com, phillip.wood123@gmail.com, sunshine@sunshineco.com, kristofferhaugsbakk@fastmail.com, ben.knoble@gmail.com, haraldnordgren@gmail.com, Jasper Mayone Subject: [PATCH v6 2/3] doc: for-each-ref: say how to read %(worktreepath) safely Date: Wed, 2 Dec 2026 02:28:49 -0500 Message-ID: <20261202072850.1555-3-me@jaspermayone.com> X-Mailer: git-send-email 2.56.0 In-Reply-To: <20261202072850.1555-1-me@jaspermayone.com> References: <20261111152811.99986-1-me@jaspermayone.com> <20261202072850.1555-1-me@jaspermayone.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-Transfer-Encoding: 8bit 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. Suggested-by: Phillip Wood Signed-off-by: Jasper Mayone --- 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:`:: Two integers, separated by a space, demonstrating the number of -- 2.56.0