From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: zsh-workers-return-43530-ml=inbox.vuxu.org@zsh.org X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-1.1 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham autolearn_force=no version=3.4.2 Received: from primenet.com.au (ns1.primenet.com.au [203.24.36.2]) by inbox.vuxu.org (OpenSMTPD) with ESMTP id d92cc045 for ; Mon, 24 Sep 2018 16:04:48 +0000 (UTC) Received: (qmail 27410 invoked by alias); 24 Sep 2018 16:04:35 -0000 Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Workers List List-Post: List-Help: List-Unsubscribe: X-Seq: 43530 Received: (qmail 5670 invoked by uid 1010); 24 Sep 2018 16:04:35 -0000 X-Qmail-Scanner-Diagnostics: from out1-smtp.messagingengine.com by f.primenet.com.au (envelope-from , uid 7791) with qmail-scanner-2.11 (clamdscan: 0.99.2/21882. spamassassin: 3.4.1. Clear:RC:0(66.111.4.25):SA:0(-2.6/5.0):. Processed in 6.310507 secs); 24 Sep 2018 16:04:35 -0000 X-Envelope-From: d.s@daniel.shahaf.name X-Qmail-Scanner-Mime-Attachments: | X-Qmail-Scanner-Zip-Files: | DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= daniel.shahaf.name; h=content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-sender:x-me-sender:x-sasl-enc; s=fm1; bh=wJUdRP apkG384x6aBn9ifnJUGvZ1soWoJ0BSUBFlOfg=; b=XyBY+Khu6gcmu5fWhMEh+R 8EhzoF3ButEG+yLB5rttMNO+UlPvrQIsujwSt7DJu8z8QuuI0I3RI/T7Cq80YX0/ Vy8ehxNYfv67l86RV61IqwnV8UJrFbji9BSytLog1FEV/I30ncbZRqYpY2DSrMBe 6fQ5DCLxgF055QJJ80qvy2PAAu2ftnfCTDxzwvGkTEQpFdKQrv4xvJ2J/eJDuSK0 05AkCqhzAtb+Sz/dDntA461SWgNSjYv3UwucLShTe9xqZooQuIX5i1YtbySSdiMe h/hIymMA9OEahOz9nz+0oJUX4turNNvjuW+GL2xZFlKBfPSAj3qpS6t/w7/2XwAQ == DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-sender:x-me-sender:x-sasl-enc; s=fm3; bh=wJUdRP apkG384x6aBn9ifnJUGvZ1soWoJ0BSUBFlOfg=; b=vaZtrBBUi02JK73CTAFkRZ nCBjm/WC7qLFQjhsuKecZKhLbv3WIO5rdF6x4pTCeQ6INJUpF8vz/e1vJd+P9vIK 9xYwFhQxTMXCtOoXvbufhl7+1k022PemN9guwP3GWJEqEPBJJX/Orv9P9oZjipQa 1L5fdxIpSejprPU7vcUyE+XDG7bzKzVBgjIMT4TxxESrUWL8ditvSKzEqqyi2F0W 6uS+NrPvD387DXjJLQr7ZXPxtyCzhNOePZxvwKvw8ZQDY5s3Xd400NttBqLsABTg XLPZo9OM+NORIzTlc3JqBvvqkCyeHv5d01p8/Xv63DYpeO2KwZhVrhY8521L6jRQ == X-ME-Proxy: X-ME-Sender: Message-Id: <1537805063.1343776.1518857576.402E4300@webmail.messagingengine.com> From: Daniel Shahaf To: =?utf-8?Q?Marc=20Cornell=C3=A0?= , zsh-workers@zsh.org MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" X-Mailer: MessagingEngine.com Webmail Interface - ajax-e556cd15 In-Reply-To: References: Subject: Re: [BUG] git checkout completion shows duplicated branch names Date: Mon, 24 Sep 2018 16:04:23 +0000 Marc Cornell=C3=A0 wrote on Mon, 24 Sep 2018 14:51 +0000: > Steps to reproduce: >=20 > git init repo > cd repo > git commit --allow-empty -m 'Initial commit' > git checkout -b topic/foo > git checkout master >=20 > Now, when trying to complete to a branch name, here's what I see: >=20 > ~/repo% git checkout > e287376 -- [HEAD] Initial commit (12 seconds ago) > topic/foo master -- Initial commit > HEAD master > topic/foo >=20 > Notice that branches appear twice. This only happens on versions newer > than 5.3.1, excluding this one. > A `git bisect` pointed me to commit e869952, which changed to using > the __git_recent_branches function, > which uses extracts branch names from the git reflog. >=20 The catch here is that they appear as part of different groups: the first instance is part of the "recent branches" group and the second is part of the "head" group. You can see group names by setting =C2=ABzstyle ':completion:*' format '> %d'=C2=BB. A user can disable or hide individual groups with the tag-order style. If a user disables the "recent branches" group, then topic/foo should still be offered under "head", and vice-versa. That is not to say that we can't make changes; I am just trying to explain that avoiding the duplication is not as trivial as it may seem. > Furthermore, on versions prior to commit 4dddf3aa (< zsh-5.6), the > completion is even worse since a branch > is not fully completed even if there isn't any other branch with the > same prefix. >=20 > So typing this: >=20 > ~/repo% git checkout topic/ > topic/foo -- Initial commit > topic/foo >=20 > gets completed to `git checkout topic` instead of the full branch name. >=20 With 'zsh -f' + 'autoload compinit; compinit', =C2=ABgit checkout t=C2= =BB gives me =C2=ABgit checkout topic/foo=C2=BB and a subsequent displays possible completions. That is better than the behaviour you get, but I agree it shouldn't be treating this situation as an ambiguous completion. I don't know offhand where the relevant piece of code is, though. Probably in the internals of bin_compdescribe/bin_compadd? Here's a minimal example: _f() { local a=3D( foo:FOO bar:BAR ) expl _describe -t lorem "lorem" a _wanted ipsum expl 'ipsum' compadd foo bar }=20 compdef _f f f f > So after version 5.6 and newer the bug is not that annoying because > the full branch name is indeed completed, > but there're still duplicated entries and I'd expect there to be > unique branch names. >=20 > If I knew enough about the completion system I would try to fix it, > but sometimes you have to let the hard stuff > to the pros. Cheers, Daniel