From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-3.4 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED,UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 2263 invoked from network); 27 Mar 2021 21:08:45 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 27 Mar 2021 21:08:45 -0000 ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20200801; t=1616879325; b=1CRaIPZuUCEXjdx442V06N95LAjLCigw0o3Uo8f3m/4rHKEjzgW8v679QFgWd9qXFLHtFwxpZ6 lkK+Uhiq0ToP+shhY60HyerPy6laK0Q3hfa/pKqKenAHsq6mCTL4CV8MYXA0W/YOZab3UU024q WSup4t0gghuwoYaus0EYjnWj3DUxxdxeB6VJHlFHyPD21uZO0z0Io3vfkGkaqSr8MdJWph3VeB iEXAkhxinPUkTE0bf4xG3taQHDDWVrU+hf+J/JqKmwFDkzcAxga9m99oTczGxtJ76GRS7d09fs w6mlNLECUWx7RnfhBe6QkgOZqoJ60oj3H+Wf5WtucNPZOg==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (wout1-smtp.messagingengine.com) smtp.remote-ip=64.147.123.24; dkim=pass header.d=daniel.shahaf.name header.s=fm2 header.a=rsa-sha256; dkim=pass header.d=messagingengine.com header.s=fm2 header.a=rsa-sha256; dmarc=none header.from=daniel.shahaf.name; arc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed; d=zsh.org; s=rsa-20200801; t=1616879325; bh=P/8yvo5dIxYVTZ+HKqFs/jOe8hMDLKEmnIR6ldoC70g=; h=List-Archive:List-Owner:List-Post:List-Unsubscribe:List-Subscribe:List-Help: List-Id:Sender:In-Reply-To:Content-Transfer-Encoding:Content-Type: MIME-Version:References:Message-ID:Subject:Cc:To:From:Date:DKIM-Signature: DKIM-Signature:DKIM-Signature; b=poiZ9m0qZ/A7nYZL3BDRrDoa78rgr+w2UbZpwznl8MQOxOylS6rR4Q8YIUW3wiHYbN0vE++jvT xctr7OcRwH4al4RVzQdOXv9EkSiKEywkbSVdJ6QOkQjPUocR8OxphT+iiyrl2O85tUqPk8nmkS bOTvGZVy4+l1n/Zv2tl/C6QSmYjnyJEJMT824QIpsH2zHrhEj1+vpnSCvnkeL/EZCr4j3D8qrG fkdz5j1dev9HY3zRhCfQlP5It3OComaE7l6Uqx/DyTkFZiOjqwbGf5K2OdX8fCjm/frDsUaP1A 2OiH70HwUoQON6swhdNmMXgLHDDe3ArrYPhzh5uN8LZSGg==; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=zsh.org; s=rsa-20200801; h=List-Archive:List-Owner:List-Post:List-Unsubscribe: List-Subscribe:List-Help:List-Id:Sender:In-Reply-To:Content-Transfer-Encoding :Content-Type:MIME-Version:References:Message-ID:Subject:Cc:To:From:Date: Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender :Resent-To:Resent-Cc:Resent-Message-ID; bh=K/lQaEBYpChkLjBcEm/AiXOnEMFPBwqebghTMeqqlmg=; b=t2OGnrL0kdgW55PkCXT5ufTGxJ csUJ1PGBfoqTAEZsrFlc79rZ3NaTLarkzwof+s1Oi5XlPTfesiKrGLrlC9U739QwBQQZH31proyR4 k+lbe01pnuo7ihtIatKt4oHWtLaYGKQ2cyELZ5PhuzLWPk50B/cy9jBRaK3BByjMb35Xwde3/Lfv9 CDeszdpFNjHDGs9Os4Ffqh4BJyS1mYQyZXU+Q3cf5duhBG3oHdNoQzqREnmhwZL4FYzKl7vAJT27n KcyXms/L37z1QvJq2UOB9QbEM5LqzRWZldhaWntudngKYI1ZG8T/Rm19SIaFTV31+rTv6MTXMAq0r cQoUdgqQ==; Received: from authenticated user by zero.zsh.org with local id 1lQGAl-0007cV-Tc; Sat, 27 Mar 2021 21:08:43 +0000 Authentication-Results: zsh.org; iprev=pass (wout1-smtp.messagingengine.com) smtp.remote-ip=64.147.123.24; dkim=pass header.d=daniel.shahaf.name header.s=fm2 header.a=rsa-sha256; dkim=pass header.d=messagingengine.com header.s=fm2 header.a=rsa-sha256; dmarc=none header.from=daniel.shahaf.name; arc=none Received: from wout1-smtp.messagingengine.com ([64.147.123.24]:51889) by zero.zsh.org with esmtps (TLS1.3:TLS_AES_256_GCM_SHA384:256) id 1lQGAZ-0007T3-EN; Sat, 27 Mar 2021 21:08:32 +0000 Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailout.west.internal (Postfix) with ESMTP id 92CE110D3; Sat, 27 Mar 2021 17:08:29 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute3.internal (MEProxy); Sat, 27 Mar 2021 17:08:29 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= daniel.shahaf.name; h=date:from:to:cc:subject:message-id :references:mime-version:content-type:content-transfer-encoding :in-reply-to; s=fm2; bh=K/lQaEBYpChkLjBcEm/AiXOnEMFPBwqebghTMeqq lmg=; b=OySMa2HDPQVNPgve7A7vG8ppC48y9HOgkOfrwwxz1r5ooPsavihmFqb4 iooGHdioqGgeBHaE3muaOFYeFqAo6hyrmZj2YxbovnPs2NZwg+O5ZVPvHyxe9mVa DgWs55H0OCX6gym5eK35UthqjMDU+Z7tjESQlrdndHcCZzA/J7B4XU/dhvKqB6bU 7tXyRRAlmR8PL9r3dhxd2P05pqU2KpvKbm4Pp3pf0z41tTQNcKOiuYZBRcYUXhvU kxcSspnBY2sQ70X85rV9t8g3bQlWAzmrHO6YQJ4GfqyHidnhWJYoh3PIq1X6jnxR QlvPkXpNynORocvzssIAtYpM7t9kYw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm2; bh=K/lQaEBYpChkLjBcEm/AiXOnEMFPBwqebghTMeqql mg=; b=S+3feDwnX1H3W5/3zo8owkxjLkdee/FHr79eO9/Cpgh4R7dU4rGPbGnBi W89NtclvdA1nl9FKxUQh+nHfrfPuQ87cl8j+wWsAOVVaRlgsxnjou8MEBx3y/MPI j91OBHeARaqdYhD4aYbUs4Ddh7F9Q9Y1N5ujUDNxfSQuaMR7iIMkC2P2GWSC2HGd h7GSimPxuXeR2J8U6cp4XwbInrEmNeO7nr5X+vV0bAshZMclECcQLRpOi/XbF8nA k1TQphO2Dwqwkt2tXLmlIpERAZysth9NyfQMGavsCCbryxisuvB/aQNH85ac2FVW yz5kgKDc3IF/+E0j89VRcmjs9XC/g== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduledrudehgedgudegiecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecunecujfgurhepfffhvffukfhfgggtugfgjggfse htkedttddtreejnecuhfhrohhmpeffrghnihgvlhcuufhhrghhrghfuceougdrshesuggr nhhivghlrdhshhgrhhgrfhdrnhgrmhgvqeenucggtffrrghtthgvrhhnpefgkefgfeejgf dvvdfguddtleelkedvfeetiedtudfhveevveduhfdvveeffedvueenucfkphepjeelrddu kedvrdefiedrudekudenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrih hlfhhrohhmpegurdhssegurghnihgvlhdrshhhrghhrghfrdhnrghmvg X-ME-Proxy: Received: from tarpaulin.shahaf.local2 (bzq-79-182-36-181.red.bezeqint.net [79.182.36.181]) by mail.messagingengine.com (Postfix) with ESMTPA id AA243240057; Sat, 27 Mar 2021 17:08:28 -0400 (EDT) Received: by tarpaulin.shahaf.local2 (Postfix, from userid 1005) id 4F7BJp41Ccz44r; Sat, 27 Mar 2021 21:08:26 +0000 (UTC) Date: Sat, 27 Mar 2021 21:08:26 +0000 From: Daniel Shahaf To: m0viefreak Cc: dana , Zsh hackers list Subject: Re: [RFC] Case-insensitive path completion in _git Message-ID: <20210327210826.GJ18178@tarpaulin.shahaf.local2> References: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) X-Seq: 48278 Archived-At: X-Loop: zsh-workers@zsh.org Errors-To: zsh-workers-owner@zsh.org Precedence: list Precedence: bulk Sender: zsh-workers-request@zsh.org X-no-archive: yes List-Id: List-Help: List-Subscribe: List-Unsubscribe: List-Post: List-Owner: List-Archive: Archived-At: m0viefreak wrote on Sun, Dec 13, 2020 at 14:55:55 +0100: > > > On 13.12.2020 05:40, dana wrote: > > _git has issues completing files case-insensitively (if you have matcher-list > > 'm:{a-zA-Z}={A-Za-z}' or whatever). Looking into it, i found that __git_files > > is trying to pass a glob pattern to `git ls-files`, and this fails if there's > > not an exact case match, since ls-files is always case-sensitive. > > > There is a fall-back to `git ls-files` with no path, but this doesn't always > > work either, because it defaults to the CWD, and the file you're trying to > > complete may not be under the CWD. Even when the fall-back succeeds, it's not > > ideal, because it'll pass every single file in the tree to _multi_parts, which > > can be slow. > > > > The following hack solves the problem for me, but it might be too silly to > > commit. Can anyone think of a more proper fix? If not, would the hack be > > viable (probably gated behind a style)? > > > > dana > > > > ... > > + pref=${pref//(#m)[[:alpha:]]/\[${(U)MATCH}${(L)MATCH}\]} > > ... > > This solution only handles simple upper-lower-case conversion matcher-list styles, > but it will not work for more complicated styles like 'r:|[._-]=* r:|=*'. > That's probably fine for most use-cases. What about the default use-case — no matchspec and case-sensitive matching? The patch transforms a plain string to a list of character classes, and it's not clear to me what costs that might incur on large trees. @Lawrence Thanks for fishing these out of the archives ☺ Cheers, Daniel > I have been running with the following patch applied locally for quite some time: > > > diff --git a/Completion/Unix/Command/_git b/Completion/Unix/Command/_git > index 81a060e4d..1a6619e31 100644 > --- a/Completion/Unix/Command/_git > +++ b/Completion/Unix/Command/_git > @@ -7153,7 +7153,7 @@ __git_files () { > # TODO: --directory should probably be added to $opts when --others is given. > > local pref=${(Q)${~PREFIX}} > - [[ $pref[1] == '/' ]] || pref=$gittoplevel$gitprefix$pref > + [[ $pref[1] == '/' ]] || pref=$gittoplevel$gitprefix > > # First allow ls-files to pattern-match in case of remote repository > files=(${(0)"$(_call_program files git ls-files -z --exclude-standard ${(q)opts} -- ${(q)${pref:+$pref\*}:-.} 2>/dev/null)"}) > > > It just lets _multi_parts do the matching. > Performance-wise, it's obviously worse than than your proposed solution, but > still better than the fallback, since it still passes $gitprefix to ls-files, > which should also avoid the CWD problem. > > The trigger of the fallback is broken anyways, isn't it? > > > # If ls-files succeeded but returned nothing, try again with no pattern > > if [[ -z "$files" && -n "$pref" ]]; then > > It just considers the case where no match was found at all, but it does not > handle the case where *some* matches were found, but not all. > >