From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 17552 invoked by alias); 7 Oct 2015 22:29:04 -0000 Mailing-List: contact zsh-users-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Users List List-Post: List-Help: X-Seq: 20705 Received: (qmail 12364 invoked from network); 7 Oct 2015 22:29:01 -0000 X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM, T_DKIM_INVALID autolearn=ham autolearn_force=no version=3.4.0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.co.uk; s=s2048; t=1444256553; bh=xU8UL2kLnM8LE0p3yqaR1jQNYPnAibNnlRebJehT6Zw=; h=In-reply-to:From:References:To:Subject:Date:From:Subject; b=qkHr21vLx/kTJOxC/ygAbCZl9NCitkP5KgVkdKB6MnwWw/YA/6nWkimDPDlBMgne16a176izIgoDgz5E9tq10Ah/EbLzswsCwvusVYerHmWTLiXtZRmSLZIXpfD+mrLR+/Yf8aIf0g8S8m2D3viptK74rhH+n2bq7UYhC18v/Saz9iCPp1o8sRoXM2bKX5aYrNYsB9P62LwMaSYN30YfGW3A1EPxAPg1mWac7BkuAZZQK7EO/UcMTC6oEX2kGofL9mNPqMfUQ2AS7N5PZ0HH1bASDuNYIVqe03NOyfBLklu6e609SLAFE8PorchiirNz/V11H3Aldja/Go+Z+M2Gtw== X-Yahoo-Newman-Id: 161346.7133.bm@smtp134.mail.ir2.yahoo.com X-Yahoo-Newman-Property: ymail-3 X-YMail-OSG: S3om64AVM1nL1RP5dZ8bI7XME965lNCGrXP.3esnk.7KLZd piM1c.Xqagk32CSwmypPK0y0M3v4dDPl.LOMxyPQgkYo2mtgPmbfYICqJkd9 1cnoNjS9AYfmiN9vqTL6tzU8cqEptRgKChkZbn6SCQWe5GpjTPIGcyXkMcI. 9CEnefjkA6k4YeEjGjDe8eBOgCYwUw.ZjWvWblqHpzuuyGdihZujECVxFQLa IfJvSYhO9sOEmLeJ1ZVqTMpTiSfEN8INpiCUJzHJNeTYGF.Vxm5iKVBj7R67 0D3wIX.iWJ7q.giJin2h4YV5.5POckJq21nXWeRIoeMTCPb8a4_R8eVIXltN Uc3JGDDIeMQ3H0kAC31wM0uSsgEu0RL_qdfiT4SR5b41C5H5xruAVk7qEV.t IUq5jXHK7TMAqaxQhuoQyiIvPrT7Gc5oIT3xwpPCgyqmGYpdh.f72Ohgc1Ro 3sz8Noz_HMqsq9QYC_KVHTBAKumACOWGOLRX2ppmJG8HL3IpkFTVXRXaeXIl 14CkIQETaNtOMw6DBB6DX5_tVSrL8HA-- X-Yahoo-SMTP: opAkk_CswBAce_kJ3nIPlH80cJI- In-reply-to: <20151007120820.6f8a59e9@pwslap01u.europe.root.pri> From: Oliver Kiddle References: <20151007120820.6f8a59e9@pwslap01u.europe.root.pri> To: Zsh Users' List Subject: Re: tag-order with git refs MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <28910.1444256551.1@thecus.kiddle.eu> Date: Thu, 08 Oct 2015 00:22:31 +0200 Message-ID: <28911.1444256551@thecus.kiddle.eu> Peter wrote: > How do I limit completion after "git checkout" to showing local heads > first (i.e. branches I actually use)? > > zstyle ':completion:*:complete:git-checkout:*' tag-order heads-local There are several nested tag loops in _git. In such cases, I find it works better to list all tags along the path: zstyle ':completion:*:complete:git-checkout:*' tag-order 'tree-ishs heads heads-local' This has limitations. _next_tags will advance within inner tag loops first before tracking back to outer ones. There are other irritations here like ORIG_HEAD making it hard to complete origin/ given case-insensitive matching control. It also doesn't help that in a couple of cases functions are called sequentially instead of using _alternative. The following patch helps a tiny bit with this. The tag loop structure for git checkout looks something like the following: tree-ishs heads - sequentially calls: heads-local heads-remote commit-tags commit-tags commit-objects - sequentially calls: commit-tags heads commits modified-files modified-files remote branches - the space looks like a mistake remote-branch-names-noprefix In general, it is better to avoid nesting. If you look at many of the simpler functions in Completion/Unix/Type, you'll see that they don't call _wanted but just use _description. This is sensible for functions that are likely always called from another tag loop. It'd be worth thinking about how we might further flatten this. Maybe _alternative could take a special action style for functions that call a nested _alternative that should be incorporated as a single tag loop. I've not done anything about the lack of a tag loop in __git_recent_commits because that looks like it needs wider refactoring. On the subject of that function, I'd prefer if it used things like HEAD~3 (or even @~3 which is an abbreviation for the same thing) instead of the hashes for the matches. That gives them a common prefix so you can type git checkout @ if you know you want recent commits. Looking at the history, it seems those were added to the description to avoid grouping of matches if two commits have the same comment. I'd be inclined to not use _describe and handle the descriptions more manually. Also __git_heads should avoid duplicating local heads in the remote list. Oliver diff --git a/Completion/Unix/Command/_git b/Completion/Unix/Command/_git index 1fcde90..2cfe636 100644 --- a/Completion/Unix/Command/_git +++ b/Completion/Unix/Command/_git @@ -457,7 +457,7 @@ _git-checkout () { if (( CURRENT == 1 )) && [[ -z $opt_args[(I)--] ]]; then # TODO: Allow A...B local branch_arg='' \ - remote_branch_noprefix_arg='remote branches::__git_remote_branch_names_noprefix' \ + remote_branch_noprefix_arg='remote-branches::__git_remote_branch_names_noprefix' \ tree_ish_arg='tree-ishs::__git_tree_ishs' \ file_arg='modified-files::__git_modified_files' @@ -5587,8 +5587,9 @@ __git_commits () { (( $+functions[__git_heads] )) || __git_heads () { - __git_heads_local - __git_heads_remote + _alternative \ + 'heads-local::__git_heads_local' \ + 'heads-remote::__git_heads_remote' } (( $+functions[__git_heads_local] )) ||