Article View: linux.kernel.git
Article #829Re: [PATCH 3/5] completion: fix Zsh handling of stash names
From: Ben Knoble
Date: Mon, 19 Oct 2026 19:56
Date: Mon, 19 Oct 2026 19:56
63 lines
12990 bytes
12990 bytes
> Le 16 oct. 2026 à 04:01, Patrick Steinhardt <ps@pks.im> a écrit :
>
> On Mon, Oct 12, 2026 at 01:48:29PM -0400, D. Ben Knoble wrote:
>> When Git completes stashes for Zsh, it eventually invokes something like
>> this (via our redefinition of __gitcomp_nl):
>>
>> compadd -Q -S " " -p "" -- 'stash@{0}' 'stash@{1}' && _ret=0
>>
>> Because of -Q, the braces are unquoted, and Zsh will leave us at (for
>> example)
>>
>> git stash show stash@{
>> cursor ^
>>
>> From here, the list-choices widget (on Ctrl-D by default) will show
>> stash@{0} and stash@{1}, but the complete-word widget (Tab) will just
>> add another brace. Zsh things we're trying to do a brace expansion, I
>
> s/things/thinks/
Will fix!
>> think! Interestingly, using menu-complete (Ctrl-N) does cycle through
>> matches, since it's taking a slightly different completion path in Zsh.
>>
>> We might try to fix this by passing surrounding single quotes (using the
>> -S/-p arguments of compadd, which we can do via __gitcomp_nl's other
>> parameters), and indeed Zsh will generate
>>
>> git stash show 'stash@{
>> cursor ^
>>
>> but completing here won't find anything, and I'm not totally sure why.
>>
>> Instead, though, we can let Zsh quote metacharacters (removing -Q) and
>> everything "just works." It changes the output format a bit (users see
>> stash@\{0\}, for example), but I find this an improvement over not being
>> able to complete names at all. menu-complete is unchanged aside from the
>> extra backslashes.
>>
>> So, override stash listing completion in Zsh with a working version.
>
> Hm. I assume you tried finding a variant that works for both Bash and
> Zsh so that we don't have to carry this override?
Actually, no. I assumed Bash was working and haven’t tested it either way.
Presumably we’d have a report from someone if it were doing what Zsh does?
Many Zsh users, OTOH, use the Zsh-distributed completions,
which stackoverflow for me (and anyway I prefer ours).
I won’t have time to see if Bash is also Brien here, but this shouldn’t
change Bash’s behavior at least.
Oh, re-reading: yes, I looked for something that was compatible
with existing code. I mentioned one such attempt (single quotes).
No luck, though.
Technical Details
Message-ID:
<841E7396-646B-4667-84C8-A51BDD7371F2@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-72441-linux-kernel-git=dewy.ruReferences:
<atHZvexnI0Ia7Xjr@pks.im>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-72441-linux-kernel-git=dewy.ru
From: ben.knoble@gmail.com (Ben Knoble)
Newsgroups: linux.kernel.git
Subject: Re: [PATCH 3/5] completion: fix Zsh handling of stash names
Date: Mon, 19 Oct 2026 15:56:18 -0400
Organization: Usenet Network
Message-ID: <841E7396-646B-4667-84C8-A51BDD7371F2@gmail.com>
References: <atHZvexnI0Ia7Xjr@pks.im>
MIME-Version: 1.0 (1.0)
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable
Injection-Info: usenet.network;
logging-data="3702404"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:inpVyUwT0BI866dv4uid7LL4g6Q= sha256:dhD0boMtTYNWrrJHlYAdk6zRkqbK8Xd/mCjsJUP5qP8=
sha1:zT9q17x7ujf5olidWKSDQZD4bSY= sha256:xtj89FuErdYqnZvEyWUahRPnW9XxCy3gY5TjoY/RUXs=
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 5443B110B04; Mon, 19 Oct 2026 23:02:51 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -1.948
X-Spam-Status: No, score=-1.948 tagged_above=-9999 required=6.31
tests=[DCC_CHECK=1.1, 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.25,
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 ineMUQlEHggx;
Mon, 19 Oct 2026 23:02:48 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=git+bounces-72441-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 5CF71110AD4; Mon, 19 Oct 2026 23:02:40 +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 8FB266822B; Mon, 19 Oct 2026 19:56:58 +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=1792439792;
b=3KvhVWwWiulgwISqja1MPn1Lm+XNrrWfdcgliKQw87sp/1ICKeHxNMYOyA2/MfO34KUu
xry3pCw2YMH6odBgt7ORtdT9w54m/eQikC9guvNcsEXURCzHL8zdelQKznnK7RzvTLN3z
rBzWpvXRMfg3S4JqBAAVUFt2eMTPysco2KrhI8fVSGBSEg+gBwBsxbxdSZHj3OMGa+6fE
NnU0j9W+i0QK2GqOPnu9Hz/s+B6cN6Xaw+MWPSMQSqcO69YlKXwm5THAp74Sv/UOKtIq9
jeoyt4ics84OAePfSMDpDNCNMm4xSmj/DnlP442FEDNlhGd7KuGXqhmOgeUmPC7viOQ==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
a=rsa-sha256; c=relaxed/relaxed; t=1792439792;
h=X-Original-To:Received:DMARC-Filter:Received:DKIM-Signature:
X-Google-DKIM-Signature:X-Gm-Message-State:X-Gm-Gg:X-Received:
Received:Content-Type:Content-Transfer-Encoding:From:X-Mailing-List:
List-Id:List-Post:List-Help:List-Subscribe:List-Unsubscribe:
List-Owner:Precedence:Mime-Version:Subject:Date:Message-Id:References:
Cc:In-Reply-To:To:X-Mailer;
bh=H7n7iSF32ZNaqFLMwFNXhezSTYu/0N6YfeP3+x5D5AM=;
b=sL1FMn1Pj34K3vo8uJR+L3844zw9HuWdYKb1ijcUEnhJPbS8Jl1Dr2AzDg3QHcMhqVta
I3ZNqePaPY2dY88LWukYk2sa7BQGIbXsDEqK4HeuMJpV5WR/7D8VOc/ijMrDXcWud8Eq9
dRS/bSwKFDKivBx0wsHfkZ87Y3ZLtl+v/PRG3LPfMBkRmNuj+yTmG2gN7VLeLY+Ea43DS
3b8+cN8/moxuAqzuXMLDyLZ2EDY99C1N1MJk3KWAsAcRiWhC7/U2rwFklKfhlGbwh07Oz
dRrYut3TfEzbTvFfNX4q8jJmEHY+K9SbOePSrpmiv4jO4xSkWiRs4sBXbfnpN9ERuTQ==
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=20251104 header.b=mKHfxxjT;
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 820C760A262F;
Mon, 19 Oct 2026 19:56:32 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
dkim=pass (2048-bit key, unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20251104 header.b=mKHfxxjT
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=74.125.224.53
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
t=1792439791;
b=G/pJXent4KUjOokAUQzNhl9PPaskiwVOGAdQma2xlSM4CMYkLkjqRfUUaBEIBYBVP8Dv
6VT3A6Hxrc4AVTzZdrSf+ymD3Cf3dLc0n6mf6h3qFTE3xsDeyTh0FNjmEKcpUDTAI5Aq1
j/hbgCjL9w2bXval63whX6q2ROhEUyHNx7SdLETOPDIZJwIR9Dq8HrbxJRs1sD4KfT5Gv
evpacE90BJvRisHQEQ66Vl/dea6DW6W55r1MacLl56O/C8O+EO+DZhyQwHnbSZQtw88CD
Yr/A1qI5pjnBd1999yxLSKz7jF9Ia0RHrKzzNit3LgiBLU9DAZTq1d2dx3mph6FMyow==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
a=rsa-sha256; c=relaxed/relaxed; t=1792439791;
h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature:
X-Gm-Message-State:X-Gm-Gg:X-Received:Received:Content-Type:
Content-Transfer-Encoding:From:Mime-Version:Subject:Date:Message-Id:
References:Cc:In-Reply-To:To:X-Mailer;
bh=H7n7iSF32ZNaqFLMwFNXhezSTYu/0N6YfeP3+x5D5AM=;
b=O0tzME/GgVZ2mj5QbmLamgF689MpO/pmFgQe9bVpOFVtaOq725ODF36g6tUh/tn1+nhQ
ryUKa4+41Xx7wJU7j8wQLmQycfkXC0samH0vWI29zwmBGv6UOe2n+qwHn8zFVnz/EMJal
LFSyXfHOCQYiM6V54kzek70/3qbSja/arHIy6XaN8XfhcB/d+8ol56xN/hrbvu243cHxa
DON9/+PMSDBNo4GP/1GQnTDmkeOumBAEr9p/Z2GEqUnXkifDkWvlk683aWcmEFF7kAqXH
a2067Jj4l/yalB33qLgxF64CxzGaNEbQClX31imv2QESEDQB9ny0YwRP6LXTQl452TQ==
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=20251104 header.b=mKHfxxjT;
arc=none smtp.remote-ip=74.125.224.53
X-Received: from mail-yx1-f53.google.com (mail-yx1-f53.google.com [74.125.224.53])
(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 5449660A2628
for <git@vger.kernel.org>; Mon, 19 Oct 2026 19:56:31 +0000 (UTC)
X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 5449660A2628
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-yx1-f53.google.com with SMTP id 956f58d0204a3-67990a45e02so2246272d50.3
for <git@vger.kernel.org>; Mon, 19 Oct 2026 12:56:31 -0700 (PDT)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=gmail.com; s=20251104; t=1792439790; x=1793044590; darn=vger.kernel.org;
h=to:in-reply-to:cc:references:message-id:date:subject:mime-version
:from:content-transfer-encoding:content-type:from:to:cc:subject:date
:message-id:reply-to:content-type;
bh=H7n7iSF32ZNaqFLMwFNXhezSTYu/0N6YfeP3+x5D5AM=;
b=mKHfxxjTQ3N4d/GXh0gm+GRpXf9N6OCL3fAqj+inXiNjCpnCpy7Agpl2h6m/4SAb1Q
zHLB6gGX/JWrxtO24LWQGkbTMTz6GBMCI/n927XdaxpUTizpDKltJ09ozTRzrH8rDsOA
Wzn+fpSYGeNgJWWhrDgCVd2ckz1/xg/N+uum3mIdD83OOq01vk3unkjXwP0lhie3EJrY
C/DZOxfnPjvlz0MQsOwCKGjY97mFfUAg5TqpiWnphBn0R31F1EgnAhoeTC2K75lWpz2l
hmE+/7mUNEyiynYFzpO0AsRosknNB7B1g3x/pCixkZ/UUz1ucMkT3r7n0iHlflTlHwtl
pgLw==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=1e100.net; s=20260707; t=1792439790; x=1793044590;
h=to:in-reply-to:cc:references:message-id:date:subject:mime-version
:from:content-transfer-encoding:content-type:x-gm-gg
:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to
:content-type;
bh=H7n7iSF32ZNaqFLMwFNXhezSTYu/0N6YfeP3+x5D5AM=;
b=B5NLk7EPS40QhowxDaevPLe26FxAyjqT8fQQvOOHP1xOlB3dDwAeZiW5CvzBw2nigp
ettozb1gW6QlU4eF01BxZNDLmcJx2FYmZBBFM4LFHXZs6hhzkoTg6NkSGHUIkozfZZyl
kLpAQzkaGR8SmS1mqfd5ePYKNJt4vnU9s/IJwLORxFINMlDer6Eu02iie4z+M9M7l/C7
CPbbns2f71AAfTAJxq6+AbwbiJb8TGe8v7yNgpybmcRxEZ7ZFZ/Flc2zOJTqYZ56+5kH
BlYkW6QRlaZSs8+/q5MIiUC3hOudy871J/5U/zfH0rvUpjzuX88LfzcWMpc7Q/KvDHh8
dcZg==
X-Gm-Message-State: AFq9FYJSkxKdtuYQSPWoCRzSkcEFl1fqDUGPvVpxYWxhgdaisog9FqdA
n+dccCUGlhSTC8L0zn+Cc5XWMWTSda4jdTY1HQnUuQVs5M6JLcbEM9V3
X-Gm-Gg: AYBFou2QjRvRVtupTbfPgWYVkFsymnmoyM2NKZIE9jYH4LIcFNrjWsjpFRsOh3HuLup
Nji+RGraExvHWUbRK0n4KpHZhfWXWPrn0c13UM7qSp9K/cEBsa0gSVpG5hHn+6ETGPtjVcgdaPl
y2CeFnvtYpceOZA89qzoL0+SnpSKFsh5uJQRc/1UFePd3JefJPv7SG7CbT1O1kKb4HWkVk3XPxs
6zdPD7ohYqPLQuOsgOutUTbKBuuGbhn/gMXQKK01DAExh79GviPvGdrxKmytZJcXLOwawdDVVdr
S/qjj38kypx4nB6HSpNSkxBiuVZgsyN2Gh4ENdx5IkSTQbQqFz+7WkG8cE7q+gW/WQzOdlkA48x
N3Gy4uRkbO0leN9lz2VFfjxIdjC3TlyABj64FdSlbooX5Gh5u3LFy0sSw9WqFfWv1KqpALiSoWT
A3qm5stazPltB7b2/C5YYbc7VVQzatkpGNUWdgE8zaTrRNa5XjPVecir9iH27B6Zr9JINwbWIw6
Ib0Qi0cHMlCo4OdrtBWmZCpM+uiUZLWmeibstdj9c3VeatbHKSv1/ws+88ke9mIS1cmEH0syt56
OLd/iRfOwAaAktEe5BWPo/at8EVVe3l0p1ryWPC/ivbxpOQ=
X-Received: by 2002:a05:690e:4852:20b0:679:980d:9986 with SMTP id 956f58d0204a3-679ca4dff7bmr1992293d50.13.1792439790256;
Mon, 19 Oct 2026 12:56:30 -0700 (PDT)
X-Received: from smtpclient.apple ([2605:a601:9092:700:a9b4:ceb5:f03c:386b])
by smtp.gmail.com with ESMTPSA id 00721157ae682-8b11b9acbc4sm4270507b3.42.2026.10.19.12.56.29
(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
Mon, 19 Oct 2026 12:56:29 -0700 (PDT)
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-Cc: git@vger.kernel.org, Junio C Hamano <gitster@pobox.com>
X-In-Reply-To: <atHZvexnI0Ia7Xjr@pks.im>
X-Mailer: iPhone Mail (23D8133)