summary refs log tree commit diff
diff options
context:
space:
mode:
authorClint Adams <clint@users.sourceforge.net>2007-10-04 08:24:32 +0000
committerClint Adams <clint@users.sourceforge.net>2007-10-04 08:24:32 +0000
commit79df5a832e4a584253cd3b44f4ceaff73089a195 (patch)
tree6fa6cbf8cb4f61ac4112cd1c8942e6c54534b0a0
parent91b9f3d7866c8c27c693d65ae1f42609227b907b (diff)
downloadzsh-79df5a832e4a584253cd3b44f4ceaff73089a195.tar.gz
zsh-79df5a832e4a584253cd3b44f4ceaff73089a195.tar.xz
zsh-79df5a832e4a584253cd3b44f4ceaff73089a195.zip
Mikael Magnusson: 23903: complete both modified and added files for git commit.
-rw-r--r--ChangeLog5
-rw-r--r--Completion/Unix/Command/_git14
2 files changed, 18 insertions, 1 deletions
diff --git a/ChangeLog b/ChangeLog
index 759bf2668..f65eca8ce 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2007-10-04  Clint Adams  <clint@zsh.org>
+
+	* Mikael Magnusson: 23903: Completion/Unix/Command/_git:
+	complete both modified and added files for git commit.
+
 2007-10-02  Peter Stephenson  <pws@csr.com>
 
 	* 23896: configure.ac, INSTALL, README: replace
diff --git a/Completion/Unix/Command/_git b/Completion/Unix/Command/_git
index 3771da1a4..dfb96558a 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