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.3 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED,UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 28061 invoked from network); 30 Mar 2021 05:58:36 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 30 Mar 2021 05:58:36 -0000 ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20200801; t=1617083916; b=hcGekjMOuK0ke8EKB2Jzmoja3l5oj/ixuH6iqlawJcgUl7kWQXQ/pdcQQSEELMsGk5kwQzYO13 iAjAxwLhAZZrThVZP399qPEsToS9MCguxY2+IEY7X4OKmeI5xv3lPejvbctkBmN4TygS+3wvv2 4XurhuS88ArA6Z4NZWFYJ3e3yc4DD/WHzojzoyKKnvGAw6PCA3qewJRaEP/TJS8epwR57TnCcs Sb2gxKh4RDFPfobn0JvqpaRvvRO01XzOodusNoLdn3DO0gF9SShEb5dOu2aIkUly50CSP449JR TC7swd+Hrh5Z5fJ9eCRbwFBXpEgedHQwy5ua8q9DhO/Mpw==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (mail-qv1-f47.google.com) smtp.remote-ip=209.85.219.47; dkim=pass header.d=dana-is.20150623.gappssmtp.com header.s=20150623 header.a=rsa-sha256; dmarc=none header.from=dana.is; arc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed; d=zsh.org; s=rsa-20200801; t=1617083916; bh=vj+PUna378Yt78UnNmtJU8GVikm6p+qfuXBVnWgYrQ4=; h=List-Archive:List-Owner:List-Post:List-Unsubscribe:List-Subscribe:List-Help: List-Id:Sender:To:References:Message-ID:Content-Transfer-Encoding:Cc:Date: In-Reply-To:From:Subject:MIME-Version:Content-Type:DKIM-Signature: DKIM-Signature; b=JDEJkoV1yOCsCmo1hGDyDwnH6DSFycALuFkQBiNkYjD76PTX76soNDlympZkOqxgQdlvJd0Hv+ lwyz8fJtXLygkkaDV9oRrSyT/VYER161g2ydAucPr2/3i140fxIAkWnXowA0WWKiMoD5Yvr8Zw 781DxrxlBdoqiRF4TYegPb++9oZFpP4uPfHGdtrbNV3J4Hqk2rreb46JDLtJdRa7H9FsvNK6a2 jg+lIo1UFj3O6b5zmybYw2LyMhqfVjPRAnRoKDyh3PGJDsL3QZrVjXgO3NCym3nNXAaE5rmWtY 4Yrlj9nBgnZ4j8+6wSRqOkKbaSVtiUWoce/pnjGTT5Nh0w==; 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:To:References:Message-Id: Content-Transfer-Encoding:Cc:Date:In-Reply-To:From:Subject:Mime-Version: Content-Type:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID; bh=M/oxl+RwWaqg5JG/UTuS0SS/w7M4oQIE1fVhCPigDl4=; b=oZYNGE7ZV/IGAa48oBpIGZkITo vIWhn/1gHB/SoQfEcwxdu6Qp5te3VQgvRw1QdF98fAgk2sa9CUd6tHmm3clcUvSb2zcUvINquJuuJ BKtrey+WNpxooohV7I7evo3WUGmkCapGF9P1I55RHIfuPbJ2EJXoPcJxjOqgwnF+9743O7Qx6xgni Qc07jFSnStgOL253XrpCfRscwhBPPHFJAwXuN+pL2Cs6E2A7NgDpG7sWP1eI2SjGFc9KCKa3qWjPt G7XZb9/eeNe/7JNS2DvpEx8R2bHYA0ffcV/b/iZvoKOHC2vkfmQm/4Y/Sg53YtNbXnRqiJsS9ZzWa KOGnvY5A==; Received: from authenticated user by zero.zsh.org with local id 1lR7Od-000Lpn-UW; Tue, 30 Mar 2021 05:58:35 +0000 Authentication-Results: zsh.org; iprev=pass (mail-qv1-f47.google.com) smtp.remote-ip=209.85.219.47; dkim=pass header.d=dana-is.20150623.gappssmtp.com header.s=20150623 header.a=rsa-sha256; dmarc=none header.from=dana.is; arc=none Received: from mail-qv1-f47.google.com ([209.85.219.47]:47081) by zero.zsh.org with esmtps (TLS1.3:TLS_AES_128_GCM_SHA256:128) id 1lR7OH-000LgH-Uf; Tue, 30 Mar 2021 05:58:15 +0000 Received: by mail-qv1-f47.google.com with SMTP id j17so7599791qvo.13 for ; Mon, 29 Mar 2021 22:58:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=dana-is.20150623.gappssmtp.com; s=20150623; h=mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=M/oxl+RwWaqg5JG/UTuS0SS/w7M4oQIE1fVhCPigDl4=; b=AC1s4Ac2tvcc4gDGsMotO2WBC/Z4hNsEr+WpHoa/ntT+kUm+B0+NhLtdFw743NP1a+ QN6/TCdv3Czq9jW+nnNtQxCMGJW7zHtkPG2bMsaAJHdK8me54JyLpiPrKs3+xoWi/oyB c1qU09WLwBajBny7lO+CgR2XDsokKgs03PQJFD624qnoUTghuXEk0DUbqYblBRmk8tu+ RGCztm4H3EiMQ/7BVw7JDO/g4Nm5/wiZVTB15KvJv9ef85iSZome/Kqc3KMh9Ueq+J9L FwDE8ePjwsQzXiSO5IgfsWmI5Pjpg56wQWjKHENBmaoJ3RBdLdbAu2iiGRaYZ7w30d7/ 85vw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=M/oxl+RwWaqg5JG/UTuS0SS/w7M4oQIE1fVhCPigDl4=; b=BaWA/srGOEYPdJ8nrNDcmSI4ibs6cyN3e7tQh8z0qGP5RvhN1B1m35XIc1TuRUpVhl bkJGizLoK7BBDvV+x+LglcpuSEZ3Y9BE4UjifqFONaIGkMBcVuvDqSUwIo51Rzrvn6Fc vVk07ZSpiVanigzlB93A88xvce0QfzLWJymytzHDrdEJyKgu8mTbugr5KLqdRnsweTRs 0jerMV22ad/XG333FaPfzVtw+YBKpis8+0QBDz7UpIQqwp9vOswOc/aAyAvsGINJHzuS L0dH/MsvPmXyMP+JuUX/0kDZgKH2Z3SXGbWRVuMi1uVtw2NxxdCYn62Slwg6Y9U1INZs HTcg== X-Gm-Message-State: AOAM533Sslrk761m1kvbiZ9Rap6AoMfPB+e5kmZyqC/VhdBBnqfsPJLM 0TQ5BTaxpUqaRmpEEVQT4cOf8qzOzVqqGg== X-Google-Smtp-Source: ABdhPJyEsqoDZfihVryY0ze+z4CjW7+XL0uDk96xvr6hIGR0YoSbKqEQuNDEUZqMQcRIsyP+EkcVrA== X-Received: by 2002:a05:6214:180d:: with SMTP id o13mr28607999qvw.10.1617083892697; Mon, 29 Mar 2021 22:58:12 -0700 (PDT) Received: from heartswap.lan.dana.is (173-17-84-59.client.mchsi.com. [173.17.84.59]) by smtp.gmail.com with ESMTPSA id v11sm12212969qtx.79.2021.03.29.22.58.11 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 29 Mar 2021 22:58:12 -0700 (PDT) Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 13.4 \(3608.120.23.2.4\)) Subject: Re: [RFC] Case-insensitive path completion in _git From: dana In-Reply-To: <59566-1616918897.215402@6qHq.M4f6.Ov84> Date: Tue, 30 Mar 2021 00:59:06 -0500 Cc: Zsh hackers list Content-Transfer-Encoding: quoted-printable Message-Id: <850A9481-BE4A-4EED-A43A-129A2C3EB1E7@dana.is> References: <20210327210826.GJ18178@tarpaulin.shahaf.local2> <1C958552-603A-4716-8D4B-EF1EDA6D304F@dana.is> <59566-1616918897.215402@6qHq.M4f6.Ov84> To: Oliver Kiddle X-Mailer: Apple Mail (2.3608.120.23.2.4) X-Seq: 48338 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 28 Mar 2021, at 03:08, Oliver Kiddle wrote: > That applies to the whole path including the directory components = which > I don't thing we'd want in this case - but correct me if I'm wrong. = ... > The only reference to the feature I could find was in the top-level > git.1 man page so maybe the syntax is different. I found the syntax description under the 'pathspec' section in = gitglossary(7). The documentation doesn't say one way or the other, but this suggests = that icase *doesn't* apply to the whole path: % git ls-files -- ":(icase)${(U)PWD}/*Kbuild*" fatal: Invalid path '/HOME': No such file or directory And i found this in git's dir.c, which seems to confirm: * Suppose the pathspec is 'foo' and '../bar' running from * subdir 'xyz'. The common prefix at #1 will be empty, thanks * to "../". We may have xyz/foo _and_ XYZ/foo after #2. The * user does not want XYZ/foo, only the "foo" part should be * case-insensitive. We need to filter out XYZ/foo here. In * other words, we do not trust the caller on comparing the * prefix part when :(icase) is involved. We do exact * comparison ourselves. On 28 Mar 2021, at 03:08, Oliver Kiddle wrote: > That doesn't look too bad at all but I tend not to work in big trees > like the Linux kernel. :(icase) may be worse for a deeper path where > it adds extra directory matches. Did you run these benchmarks on a > case-sensitive or insensitive file-system? Case-sensitive (ext4). Not sure if it's still like this, but you used to = get unresolvable conflicts if you checked out the Linux source on a case-insensitive file system... On 28 Mar 2021, at 03:08, Oliver Kiddle wrote: > I don't think thats necessary. Committing as per the original patch > seems good to me. Thanks. The only other thing i can think of that's worth mentioning is that the = first ls-files call may now return unusable results that nonetheless bypass = the second call. e.g., if you're using case-sensitive matching, and you try = to complete Foo, but you only find foo, the latter will be used to populate $files, which will bypass the second ls-files call. I don't know if or = when this would be an issue, but it is different. If anyone can think of a problem with that, please let me know. = Otherwise i'll commit the following in a few days probably dana diff --git a/Completion/Unix/Command/_git b/Completion/Unix/Command/_git index ced89b501..0267acfa8 100644 --- a/Completion/Unix/Command/_git +++ b/Completion/Unix/Command/_git @@ -7155,11 +7155,16 @@ __git_files () { local pref=3D${(Q)${~PREFIX}} [[ $pref[1] =3D=3D '/' ]] || pref=3D$gittoplevel$gitprefix$pref =20 - # First allow ls-files to pattern-match in case of remote repository - files=3D(${(0)"$(_call_program files git ls-files -z = --exclude-standard ${(q)opts} -- ${(q)${pref:+$pref\*}:-.} = 2>/dev/null)"}) + # First allow ls-files to pattern-match in case of remote repository. = Use the + # icase pathspec magic word to ensure that we support = case-insensitive path + # completion for users with the appropriate matcher configuration + files=3D(${(0)"$(_call_program files git ls-files -z = --exclude-standard ${(q)opts} -- ${(q)${pref:+:\(icase\)$pref\*}:-.} = 2>/dev/null)"}) __git_command_successful $pipestatus || return =20 - # If ls-files succeeded but returned nothing, try again with no = pattern + # If ls-files succeeded but returned nothing, try again with no = pattern. Note + # that ls-files defaults to the CWD if not given a path, so if the = file we + # were trying to add is in an *adjacent* directory, this won't return = anything + # helpful either if [[ -z "$files" && -n "$pref" ]]; then files=3D(${(0)"$(_call_program files git ls-files -z = --exclude-standard ${(q)opts} -- 2>/dev/null)"}) __git_command_successful $pipestatus || return