* Make git-commit complete both modified files and git-added files.
@ 2007-10-04 1:05 Mikael Magnusson
2007-10-04 8:05 ` Nikolai Weibull
0 siblings, 1 reply; 3+ messages in thread
From: Mikael Magnusson @ 2007-10-04 1:05 UTC (permalink / raw)
To: zsh-workers; +Cc: Nikolai Weibull, Clint Adams
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
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Make git-commit complete both modified files and git-added files.
2007-10-04 1:05 Make git-commit complete both modified files and git-added files Mikael Magnusson
@ 2007-10-04 8:05 ` Nikolai Weibull
2007-10-04 8:27 ` Clint Adams
0 siblings, 1 reply; 3+ messages in thread
From: Nikolai Weibull @ 2007-10-04 8:05 UTC (permalink / raw)
To: Mikael Magnusson; +Cc: zsh-workers, Clint Adams
On 10/4/07, Mikael Magnusson <mikachu@gmail.com> wrote:
> +#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
What do you need gitdir for?
> +
> + 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
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Make git-commit complete both modified files and git-added files.
2007-10-04 8:05 ` Nikolai Weibull
@ 2007-10-04 8:27 ` Clint Adams
0 siblings, 0 replies; 3+ messages in thread
From: Clint Adams @ 2007-10-04 8:27 UTC (permalink / raw)
To: Nikolai Weibull; +Cc: Mikael Magnusson, zsh-workers
On Thu, Oct 04, 2007 at 10:05:49AM +0200, Nikolai Weibull wrote:
> What do you need gitdir for?
He doesn't.
"files" is a pretty generic name for a tag.
Index: Completion/Unix/Command/_git
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/Unix/Command/_git,v
retrieving revision 1.40
diff -u -r1.40 _git
--- Completion/Unix/Command/_git 4 Oct 2007 08:24:33 -0000 1.40
+++ Completion/Unix/Command/_git 4 Oct 2007 08:25:55 -0000
@@ -2627,8 +2627,7 @@
#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
+ local -a files
files=(${(ps:\0:)"$(_call_program files git diff-index -z --name-only HEAD 2>/dev/null)"})
__git_command_successful || return
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2007-10-04 8:27 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-10-04 1:05 Make git-commit complete both modified files and git-added files Mikael Magnusson
2007-10-04 8:05 ` Nikolai Weibull
2007-10-04 8:27 ` Clint Adams
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).