summary refs log tree commit diff
path: root/Completion/Unix
diff options
context:
space:
mode:
authorClint Adams <clint@users.sourceforge.net>2008-08-16 00:22:00 +0000
committerClint Adams <clint@users.sourceforge.net>2008-08-16 00:22:00 +0000
commitac8d013c16b891f359d255fb57e8a344d92962c6 (patch)
tree91b09f6438069f4d7b07f9335f0ff454a3dcd5b5 /Completion/Unix
parentfcf8b81ec3eb38d48327af8c0979f3520e738a0f (diff)
downloadzsh-ac8d013c16b891f359d255fb57e8a344d92962c6.tar.gz
zsh-ac8d013c16b891f359d255fb57e8a344d92962c6.tar.xz
zsh-ac8d013c16b891f359d255fb57e8a344d92962c6.zip
Frank Terbeck: 24455: Completion/Unix/Command/_git: handle git stashes.
Diffstat (limited to 'Completion/Unix')
-rw-r--r--Completion/Unix/Command/_git61
1 files changed, 61 insertions, 0 deletions
diff --git a/Completion/Unix/Command/_git b/Completion/Unix/Command/_git
index 20e8d1dc8..b85710c61 100644
--- a/Completion/Unix/Command/_git
+++ b/Completion/Unix/Command/_git
@@ -166,6 +166,7 @@ _git_commands () {
     'revert:revert existing commit'
     'rm:remove files from the working tree and from the index'
     'show-branch:show branches and their commits'
+    'stash:stash away changes to the working tree'
     'status:show working-tree'\''s status'
     'tag:create tag object signed with GPG'
     'verify-tag:check GPG signature of a tag')
@@ -1913,6 +1914,66 @@ _git-status () {
 }
 __git_zstyle_default ':completion::complete:git-status:argument-rest:*' ignore-line yes
 
+
+(( $+functions[__git_stashes] )) ||
+__git_stashes () {
+  local expl
+  declare -a st_list
+
+  st_list=(${${(f)"$(_call_program stashes git stash list 2>/dev/null)"}/: */})
+  __git_command_successful || return
+
+  _wanted tags expl stash-list compadd $* - $st_list
+}
+
+(( $+functions[_git-stash] )) ||
+_git-stash () {
+  local expl
+  local -a stash_cmds
+
+  stash_cmds=(
+    apply:"restore the changes recorded in the stash"
+    branch:"branch off at the commit at which the stash was originally created"
+    clear:"remove all the stashed states"
+    drop:"remove a single stashed state from the stash list"
+    list:"list the stashes that you currently have"
+    pop:"remove and apply a single stashed state from the stash list"
+    save:"save your local modifications to a new stash"
+    show:"show the changes recorded in the stash as a diff"
+  )
+
+  if (( CURRENT == 2 )); then
+    _describe -t command "git-stash commands" stash_cmds && ret=0
+  else
+    case $words[2] in
+      (apply)
+        _arguments \
+          '--index[try to reinstate the index'\''s changes too]' \
+          '*:stash:__git_stashes' && ret=0
+        ;;
+      (branch)
+        _arguments \
+          '2:branch name:' \
+          '*:stash:__git_stashes' && ret=0
+        ;;
+      (drop|pop|show)
+        _arguments \
+          '*:stash:__git_stashes' && ret=0
+        ;;
+      (save)
+        _arguments \
+          '--keep-index[all changes already added to the index are left intact]' \
+          '*: :->end' && ret=0
+
+        [[ $state == 'end' ]] && _message 'message'
+        ;;
+      (*)
+        _nothing
+        ;;
+    esac
+  fi
+}
+
 (( $+functions[_git-verify-tag] )) ||
 _git-verify-tag () {
   _arguments \