Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Add --cached to git-diff completion



Not sure how to make _arguments do different things based on options given,for
git-diff ... -- <tab>
it should complete files
and for
git-diff --cached <tab>
it should only complete one commit, not two, since we're diffing
against the index
but i think the following change is still better than not. (don't add
--cached to $diff_args
since that is also used for git-diff-index and others where the
description is different).

diff --git a/Completion/Unix/Command/_git
b/Completion/Unix/Command/_git
index 3a365e5..9dcb481 100644
--- a/Completion/Unix/Command/_git
+++ b/Completion/Unix/Command/_git
@@ -1585,6 +1585,7 @@ __git_zstyle_default
':completion::complete:git-commit:argument-rest:*' ignore-l
 _git-diff () {
   _arguments -S \
     $diff_args \
+    '--cached[show diff between index and named commit]' \
     '::original revision:__git_commits' \
     '::new revision:__git_commits' \
     '*::index file:__git_modified_files' && ret=0


-- 
Mikael Magnusson



Messages sorted by: Reverse Date, Date, Thread, Author