zsh-workers
 help / color / mirror / code / Atom feed
From: Frank Terbeck <ft@bewatermyfriend.org>
To: zsh workers <zsh-workers@sunsite.dk>
Subject: [PATCH] _git: Add support for 'git stash'
Date: Sat, 16 Aug 2008 01:37:03 +0200	[thread overview]
Message-ID: <20080815233703.GJ2925@fsst.voodoo.lan> (raw)

Just what the subject suggests.


Index: Completion/Unix/Command/_git
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/Unix/Command/_git,v
retrieving revision 1.64
diff -u -r1.64 _git
--- Completion/Unix/Command/_git	17 Apr 2008 03:00:10 -0000	1.64
+++ Completion/Unix/Command/_git	15 Aug 2008 23:32:46 -0000
@@ -166,6 +166,7 @@
     '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_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 \


                 reply	other threads:[~2008-08-15 23:37 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20080815233703.GJ2925@fsst.voodoo.lan \
    --to=ft@bewatermyfriend.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).