From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 5484 invoked from network); 15 Aug 2008 23:37:51 -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=BAYES_00 autolearn=ham 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; 15 Aug 2008 23:37:51 -0000 Received-SPF: none (ns1.primenet.com.au: domain at sunsite.dk does not designate permitted sender hosts) Received: (qmail 68454 invoked from network); 15 Aug 2008 23:37:24 -0000 Received: from sunsite.dk (130.225.247.90) by a.mx.sunsite.dk with SMTP; 15 Aug 2008 23:37:24 -0000 Received: (qmail 4453 invoked by alias); 15 Aug 2008 23:37:16 -0000 Mailing-List: contact zsh-workers-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 25455 Received: (qmail 4434 invoked from network); 15 Aug 2008 23:37:13 -0000 Received: from bifrost.dotsrc.org (130.225.254.106) by sunsite.dk with SMTP; 15 Aug 2008 23:37:13 -0000 Received: from mta-1.ms.rz.rwth-aachen.de (mta-1.ms.rz.RWTH-Aachen.DE [134.130.7.72]) by bifrost.dotsrc.org (Postfix) with ESMTPS id 90D2C805A425 for ; Sat, 16 Aug 2008 01:37:08 +0200 (CEST) Received: from ironport-out-2.rz.rwth-aachen.de ([134.130.3.59]) by mta-1.ms.rz.RWTH-Aachen.de (Sun Java System Messaging Server 6.2-8.04 (built Feb 28 2007)) with ESMTP id <0K5O0018Z1LWQU80@mta-1.ms.rz.RWTH-Aachen.de> for zsh-workers@sunsite.dk; Sat, 16 Aug 2008 01:37:08 +0200 (CEST) Received: from relay.rwth-aachen.de ([134.130.3.1]) by ironport-in-2.rz.rwth-aachen.de with ESMTP; Sat, 16 Aug 2008 01:37:08 +0200 Received: from fsst.voodoo.lan (i59F669B8.versanet.de [89.246.105.184]) by relay.rwth-aachen.de (8.13.7/8.13.3/1) with ESMTP id m7FNb7Ok012798 for ; Sat, 16 Aug 2008 01:37:07 +0200 (MEST) Received: from hawk by fsst.voodoo.lan with local (Exim 4.69) (envelope-from ) id 1KU8qt-0005iX-Jr for zsh-workers@sunsite.dk; Sat, 16 Aug 2008 01:37:03 +0200 Date: Sat, 16 Aug 2008 01:37:03 +0200 From: Frank Terbeck Subject: [PATCH] _git: Add support for 'git stash' To: zsh workers Mail-followup-to: zsh workers Message-id: <20080815233703.GJ2925@fsst.voodoo.lan> MIME-version: 1.0 Content-type: text/plain; charset=iso-8859-1 Content-transfer-encoding: 7BIT Content-disposition: inline X-IronPort-AV: E=Sophos;i="4.32,219,1217800800"; d="scan'208";a="52009693" User-Agent: Mutt/1.5.18 (2008-05-17) X-Virus-Scanned: ClamAV 0.92.1/8049/Fri Aug 15 22:57:07 2008 on bifrost X-Virus-Status: Clean 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 \