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,FREEMAIL_FROM,MAILING_LIST_MULTI,NICE_REPLY_A, RCVD_IN_DNSWL_MED,UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 19697 invoked from network); 13 Dec 2020 13:56:20 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 13 Dec 2020 13:56:20 -0000 ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20200801; t=1607867780; b=viQGlVBPZTSmQW+TfJc6Sas6JzXgL9DaE5yY+wTzoMdPma75LuFL4qm3O8rlr6S6j+qpdgBwJW z20r41Z3XRrMLMMbbro4BP2FbNh7ldsfZWjc8CsvE3/AppVLLqXN/LLAmi9AmoHToX/g1lfvaF MlsJzmhQ563L/nXaTPDXZA1dN/T27z9+t7cbu/koYpRef119W9LYSsScL+J8GAmucEsVsoyPgH Eva9e0AHplIrrCwDoLJeZuZhzeQaNEdXEJMUcjc7H9jDES4EZbdUS3gzdrTiq3EEJN5K3ee9Gs RVCjAd57igpCreVkOop/iHX9VdKRj7R7fdCoXJxw5loFmg==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (mail-wm1-f42.google.com) smtp.remote-ip=209.85.128.42; dkim=pass header.d=googlemail.com header.s=20161025 header.a=rsa-sha256; dmarc=pass header.from=googlemail.com; arc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed; d=zsh.org; s=rsa-20200801; t=1607867780; bh=eYkDpV4ka1zpv7KTbWLZJWvTAxL1c7utUgkh1jvUQjQ=; h=List-Archive:List-Owner:List-Post:List-Unsubscribe:List-Subscribe:List-Help: List-Id:Sender:Content-Transfer-Encoding:Content-Type:In-Reply-To: MIME-Version:Date:Message-ID:From:References:To:Subject:DKIM-Signature: DKIM-Signature; b=nBlZMDWhZeP/uZut6slcwNpE1l1a4+/DBAWAQTz2m8UJi+SwQXoZKxIeBJckJ8z0NJ5RTwwhcc B5WNvwmYRzBqXdhPOXsBW5RWsm28EiRjolG9Ei875LPMjeS0oJJr1T8tCixEZMIDXfCiex/fNV SbykKPAnLm0O4y4X41BMw643UPuD9CIaRkv8wFbJs+0U/o/Gsh6yfTxsi81Ret48rG981cKUz1 ixXt7eQHnPkwRzf6oAZCeiZSFxH6kGdqLAnaJgWeBshp02/8baZ3w1DhIYVRlOh/4chuF4ydL5 o5rbvFqwDj3QDckhMcLDbYyLNsye13ByOEE/zU+THwunCQ==; 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:Content-Transfer-Encoding: Content-Type:In-Reply-To:MIME-Version:Date:Message-ID:From:References:To: Subject:Reply-To:Cc:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID; bh=YMF6XFgOoRARYDj5ycnIVdACf8QBPfnf/nMFE7h2T0Q=; b=tB9GUI2r7lZBJB9qvXUzinOQSL ZtemwV+IlkI7kCMWzIBRr1fkvwTodPw1FiXo8TZF/HJIFpSCpA2GMMjJ1MvOHDFv5UA8+3Ar9BT1I cpomaUM29wN6ic4uQGcUuynN1crF5sqJ7DWmoatVxtwcllv/qk6XsrX12XA7CpCJFAMrtRHl6ETdl m7QcVIgcPUeYWYGrKNgCf/5G0cIDuv3uieELxNQWapEcbOEM0k5890HkYW76jX9tPxeQ3KGwyHVmR CwN3uk1PvEpRjrbOeK0+2CvE4dESawpJnqqL9BRb5DceJhNm3XbC5hbS7+Qn9VNw2nUTujAAn4vbF Pezu1Ayw==; Received: from authenticated user by zero.zsh.org with local id 1koRrE-000MrN-0z; Sun, 13 Dec 2020 13:56:16 +0000 Authentication-Results: zsh.org; iprev=pass (mail-wm1-f42.google.com) smtp.remote-ip=209.85.128.42; dkim=pass header.d=googlemail.com header.s=20161025 header.a=rsa-sha256; dmarc=pass header.from=googlemail.com; arc=none Received: from mail-wm1-f42.google.com ([209.85.128.42]:34444) by zero.zsh.org with esmtps (TLS1.3:TLS_AES_128_GCM_SHA256:128) id 1koRqv-000MhI-OH; Sun, 13 Dec 2020 13:55:58 +0000 Received: by mail-wm1-f42.google.com with SMTP id g25so7454772wmh.1 for ; Sun, 13 Dec 2020 05:55:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=20161025; h=subject:to:references:from:message-id:date:user-agent:mime-version :in-reply-to:content-language:content-transfer-encoding; bh=YMF6XFgOoRARYDj5ycnIVdACf8QBPfnf/nMFE7h2T0Q=; b=D5bgyz+U9lsCWDTy5eYYTLY70UCEY1EkMBdGSCR9n1SiuGL156nVac76gWIqOihTBK 3UNVmVcdC/tvSb2vmjTfXitiKk+w6mYT2TnDMF7DOoT/k3fHVwYhnHAovG3rA2vjsGey iZBJY8qREI9jSi1Tz7HAN1gZDr7FCQMdTDx2IrjItEKkZ0AjK8iF+rwIyIA3X4ezMck4 MFvcjSjmmKW9Tc/C5fKrPMNmooMHuJOdOzHuNq6atlEi/5kSZRdBnO8MWyCQEKLDq9bc Yto9QnSVAomOm4QMlhOZW6KzzUyIJLCSYSoTeGf1qHkw974tz0twvILjde43LTprCHFc +zWQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=YMF6XFgOoRARYDj5ycnIVdACf8QBPfnf/nMFE7h2T0Q=; b=JJ6lddlLyYDTCOBJwLeABNw1vFPqssglgM549iO4s2DXuRBJmJamDQc+nxy6Uhfoaf SEGZ4xMYVj94kadVKG0u2JlP4KD+hFEUkIRj5Or//JqM1ks8psCA1BbScp+m66Z9Eet+ tkSW67vDjTD6RfdRr0Xtte0uHjoKd5qi9uFQUlGClWV24we3TtYl37klh2C2/G8XjfCA X79T7OtfeKkVWL32rB+QHOWNV6oCeHuK4YAFUxK27pwOsARveOoI5zoCN1zag+YLqT4A Wz9zBgqtocPf3p6mFzB0Bx4S+E1sizERQddNMvQYFCH1C9fqqg50ZMFnkZlv4Ffh3Qrc InPw== X-Gm-Message-State: AOAM531XGQeA78ATq0er9y7irMyvRWPvjSTFSO+ZiKbmKsA5macjeOLj Lp7UBiBVm2J7Lra+4aQwcP67xw89iic= X-Google-Smtp-Source: ABdhPJyboTBtpvHidxvdbwpXbPQh+pvh1COyhOYq3XeOOJwYF2oou39E77md7Xx+aKHSZ7Qp1dYrSg== X-Received: by 2002:a1c:ddd5:: with SMTP id u204mr22798614wmg.174.1607867756823; Sun, 13 Dec 2020 05:55:56 -0800 (PST) Received: from ?IPv6:2a02:8071:2cc1:800:c4b4:294b:e845:2e30? ([2a02:8071:2cc1:800:c4b4:294b:e845:2e30]) by smtp.googlemail.com with ESMTPSA id a14sm17906766wrn.3.2020.12.13.05.55.56 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sun, 13 Dec 2020 05:55:56 -0800 (PST) Subject: Re: [RFC] Case-insensitive path completion in _git To: dana , Zsh hackers list References: From: m0viefreak Message-ID: Date: Sun, 13 Dec 2020 14:55:55 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.5.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-Seq: 47739 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: 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. 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.