Subject: [PATCH 4/4] completion: _git: diff: add --no-index
From: m0viefreak <[email-masked]>
To: [email-masked]
Cc: m0viefreak <[email-masked]>
Date: Sun, 13 Mar 2016 23:02:00 +0100
List-Id: Zsh Workers List <zsh-workers.zsh.org>

---
 Completion/Unix/Command/_git | 18 +++++++++++++++++-
 1 file changed, 17 insertions(+), 1 deletion(-)

diff --git a/Completion/Unix/Command/_git b/Completion/Unix/Command/_git
index 023740e..c989a2c 100644
--- a/Completion/Unix/Command/_git
+++ b/Completion/Unix/Command/_git
@@ -725,12 +725,28 @@ _git-diff () {
     $* \
     $diff_options \
     $diff_stage_options \
-    '(--cached --staged)'{--cached,--staged}'[show diff between index and named commit]' \
+    '(--no-index --cached --staged)--no-index[diff files outside of git repo]' \
+    '(--no-index --cached --staged)'{--cached,--staged}'[show diff between index and named commit]' \
     '(-)--[start file arguments]' \
     '*:: :->from-to-file' && ret=0
 
   case $state in
     (from-to-file)
+      # If "--no-index" was given simply complete arbitrary files
+      if (( opt_args[(I)--no-index] )); then
+        local expl descr
+        if (( CURRENT == 1 )); then
+          descr="original file"
+        elif (( CURRENT == 2 )); then
+          descr="new file"
+        else
+          return ret
+        fi
+        _description all-files expl "$descr"
+        _files "$expl[@]"
+        return
+      fi
+
       # If "--" is part of $opt_args, this means it was specified before any
       # $words arguments. This means that no heads are specified in front, so
       # we need to complete *changed* files only.
-- 
2.5.0.234.gefc8a62