From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 27293 invoked from network); 21 Aug 2008 00:10:40 -0000 X-Spam-Checker-Version: SpamAssassin 3.2.5 (2008-06-10) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 tests=AWL,BAYES_00,WEIRD_PORT autolearn=no version=3.2.5 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by ns1.primenet.com.au with SMTP; 21 Aug 2008 00:10:40 -0000 Received-SPF: none (ns1.primenet.com.au: domain at sunsite.dk does not designate permitted sender hosts) Received: (qmail 6755 invoked from network); 21 Aug 2008 00:10:08 -0000 Received: from sunsite.dk (130.225.247.90) by a.mx.sunsite.dk with SMTP; 21 Aug 2008 00:10:08 -0000 Received: (qmail 29926 invoked by alias); 21 Aug 2008 00:09:55 -0000 Mailing-List: contact zsh-workers-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 25491 Received: (qmail 29909 invoked from network); 21 Aug 2008 00:09:54 -0000 Received: from bifrost.dotsrc.org (130.225.254.106) by sunsite.dk with SMTP; 21 Aug 2008 00:09:54 -0000 Received: from cork.scru.org (cork.scru.org [209.20.67.2]) by bifrost.dotsrc.org (Postfix) with ESMTPS id B1C618030846 for ; Thu, 21 Aug 2008 02:09:49 +0200 (CEST) Received: by cork.scru.org (Postfix, from userid 1000) id 1ECF9104083; Thu, 21 Aug 2008 00:09:48 +0000 (UTC) Date: Thu, 21 Aug 2008 00:09:48 +0000 From: Clint Adams To: zsh-workers@sunsite.dk Subject: git checkout improvement Message-ID: <20080821000948.GA20166@scru.org> Mail-Followup-To: zsh-workers@sunsite.dk MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit User-Agent: Mutt/1.5.18 (2008-05-17) X-Virus-Scanned: ClamAV 0.92.1/8060/Wed Aug 20 22:17:24 2008 on bifrost X-Virus-Status: Clean Maybe we should abstract the words[(I)--] bit into some kind of _git_arguments function. From: Mikael Magnusson Date: Wed, 20 Aug 2008 02:07:33 +0000 (+0200) Subject: _git: Make git checkout completion better. X-Git-Url: http://git.mika.l3ib.org:1234/?p=zsh-cvs.git;a=commitdiff_plain;h=ac165daf55008c6ac06c1ef7627a80a358b7342d _git: Make git checkout completion better. Now -- works, and you can complete more than one file for the second invocation form. Like the added XXX says, if you type git checkout -q HEAD then it tries to use -q as a treeish, which obviously doesn't work out. --- diff --git a/Completion/Unix/Command/_git b/Completion/Unix/Command/_git index 64ea8de..6603371 100644 --- a/Completion/Unix/Command/_git +++ b/Completion/Unix/Command/_git @@ -1543,24 +1543,29 @@ _git-checkout () { new_branch_reflog_arg='-l[create the new branch'\''s reflog]' fi - # TODO: This isn’t quite correct in regards of the handling of the “--” - # option, as it should prevent us from seeing a branch, not stop matching - # options. - _arguments -C -S -A "-*" \ - - switch-branch \ - '-q[suppress feedback messages]' \ - '-f[force a complete re-read]' \ - '-b[create a new branch based at given branch]: :__git_guard_branch-name' \ - {-t,--track}'[set up configuration so pull merges from the start point]' \ - '--no-track[override the branch.autosetupmerge configuration variable]' \ - '-l[create the branch'\''s reflog]' \ - $new_branch_reflog_arg \ - '-m[3way merge current branch, working tree and new branch]' \ - '::branch:__git_revisions' \ - - update-files \ - '::tree-ish:__git_tree_ishs' \ - '::file:->files' && ret=0 + if (( words[(I)--] > 0 && words[(I)--] < CURRENT )); then + _arguments -C -S \ + - update-files \ + '*::file:->files' && ret=0 + else + _arguments -C -S \ + - switch-branch \ + '-q[suppress feedback messages]' \ + '-f[force a complete re-read]' \ + '-b[create a new branch based at given branch]: :__git_guard_branch-name' \ + {-t,--track}'[set up configuration so pull merges from the start point]' \ + '--no-track[override the branch.autosetupmerge configuration variable]' \ + '-l[create the branch'\''s reflog]' \ + $new_branch_reflog_arg \ + '-m[3way merge current branch, working tree and new branch]' \ + '::branch:__git_revisions' \ + - update-files \ + '::tree-ish:__git_tree_ishs' \ + '*::file:->files' && ret=0 + fi + #XXX TODO and all that: $line[1] only works if you didn't write any options. + #What's the variable that holds the tree-ish argument? Is it even reliably possible? case $state in (files) if [[ -n $line[1] ]]; then