From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 8307 invoked from network); 4 Oct 2007 01:05:59 -0000 X-Spam-Checker-Version: SpamAssassin 3.2.3 (2007-08-08) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-2.5 required=5.0 tests=AWL,BAYES_00 autolearn=ham version=3.2.3 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by ns1.primenet.com.au with SMTP; 4 Oct 2007 01:05:59 -0000 Received-SPF: none (ns1.primenet.com.au: domain at sunsite.dk does not designate permitted sender hosts) Received: (qmail 95632 invoked from network); 4 Oct 2007 01:05:52 -0000 Received: from sunsite.dk (130.225.247.90) by a.mx.sunsite.dk with SMTP; 4 Oct 2007 01:05:52 -0000 Received: (qmail 20100 invoked by alias); 4 Oct 2007 01:05:49 -0000 Mailing-List: contact zsh-workers-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 23903 Received: (qmail 20085 invoked from network); 4 Oct 2007 01:05:48 -0000 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by sunsite.dk with SMTP; 4 Oct 2007 01:05:48 -0000 Received: (qmail 95335 invoked from network); 4 Oct 2007 01:05:48 -0000 Received: from ug-out-1314.google.com (66.249.92.169) by a.mx.sunsite.dk with SMTP; 4 Oct 2007 01:05:43 -0000 Received: by ug-out-1314.google.com with SMTP id u2so233094uge for ; Wed, 03 Oct 2007 18:05:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=beta; h=domainkey-signature:received:received:message-id:date:from:to:subject:cc:mime-version:content-type:content-transfer-encoding:content-disposition; bh=53UfPFMLiRaG7Gzg6oHnT0r4de7IdArCkiW+7VabWtE=; b=MRWJMIbtZMa6AgYiv5rIlgQn5B0GhmtR+UOPDtiNI0J+kp4N3Yhlbm3BU4Zbm9VYpCZMa+SHD2oLdCqVRDSGGPofBS/Ank1h6Q7P+SDjkeQ26Ak2tJdURVFt4kBmz9t4XRugQ89RdRPtOxy+AT2AASpcfvb5Qf9QRnIln78ccE0= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:message-id:date:from:to:subject:cc:mime-version:content-type:content-transfer-encoding:content-disposition; b=KtncYDH/2IGZP692jeI0/SOZwieGbP7dfbOvFZOFQehcbL8/ZcBz5oCfpAebtSAPwPwNHxvbhvS8oLPOk4C25TSs7zypLxMm+bF3isvsjBB218I7Tkpi+zXqCyrEpdqeOMseJNO32rCFeSiwlJWxIC6TmQPc/twhn+CsyIghb68= Received: by 10.142.221.19 with SMTP id t19mr156134wfg.1191459940842; Wed, 03 Oct 2007 18:05:40 -0700 (PDT) Received: by 10.142.86.21 with HTTP; Wed, 3 Oct 2007 18:05:40 -0700 (PDT) Message-ID: <237967ef0710031805r1124449dmc4c55e7545a81e0a@mail.gmail.com> Date: Thu, 4 Oct 2007 03:05:40 +0200 From: "Mikael Magnusson" To: zsh-workers Subject: Make git-commit complete both modified files and git-added files. Cc: "Nikolai Weibull" , "Clint Adams" MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Content-Disposition: inline This is useful when you've git-added two or more files, but you only want to commit one of them. http://git.mikachu.ath.cx/?p=zsh-cvs.git;a=commitdiff_plain;h=commit diff --git a/Completion/Unix/Command/_git b/Completion/Unix/Command/_git index 3771da1..dfb9655 100644 --- a/Completion/Unix/Command/_git +++ b/Completion/Unix/Command/_git @@ -1568,7 +1568,7 @@ _git-commit () { '(-q --quiet -v --verbose)'{-q,--quiet}'[suppress commit summary message]' \ '(-q --quiet -v --verbose)'{-v,--verbose}'[show unified diff of all file changes]' \ '(-u --untracked-files)'{-u,--untracked-files}'[show files in untracked directories]' \ - '*:file:__git_modified_files' \ + '*:file:__git_changed_files' \ - '(message)' \ '--amend[amend the tip of the current branch]' \ {-c,--reedit-message=}'[use existing commit object and edit log message]:commit:__git_commits' \ @@ -2624,6 +2624,18 @@ __git_unmerged_files () { __git_files $* --unmerged } +#this is for git-commit which can take files both git-added and not +(( $+functions[__git_changed_files] )) || +__git_changed_files () { + gitdir=$(_call_program gitdir git rev-parse --git-dir 2>/dev/null) + __git_command_successful || return + + files=(${(ps:\0:)"$(_call_program files git diff-index -z --name-only HEAD 2>/dev/null)"}) + __git_command_successful || return + + _wanted files expl 'index file' _multi_parts $@ - / files +} + (( $+functions[__git_tree_files] )) || __git_tree_files () { local multi_parts_opts -- Mikael Magnusson