zsh-workers
 help / color / mirror / code / Atom feed
From: Clint Adams <clint@zsh.org>
To: zsh-workers@sunsite.dk
Subject: git checkout improvement
Date: Thu, 21 Aug 2008 00:09:48 +0000	[thread overview]
Message-ID: <20080821000948.GA20166@scru.org> (raw)

Maybe we should abstract the words[(I)--] bit into some kind of
_git_arguments function.

From: Mikael Magnusson <mikachu@gmail.com>
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 <tab>
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


             reply	other threads:[~2008-08-21  0:10 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-08-21  0:09 Clint Adams [this message]
2008-08-21  0:20 ` Mikael Magnusson
2008-08-21  0:52   ` Clint Adams
2008-08-21  2:18     ` Mikael Magnusson
2008-08-21  2:22       ` Mikael Magnusson
2008-08-21  5:04         ` Clint Adams
2008-08-21  5:19           ` Mikael Magnusson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20080821000948.GA20166@scru.org \
    --to=clint@zsh.org \
    --cc=zsh-workers@sunsite.dk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).