Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm
Precedence: bulk
X-No-Archive: yes
List-Id: Zsh Workers List <zsh-workers.zsh.org>
List-Post: <mailto:zsh-workers@zsh.org>
List-Help: <mailto:zsh-workers-help@zsh.org>
X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on f.primenet.com.au
X-Spam-Level: 
X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM,
	T_DKIM_INVALID autolearn=ham autolearn_force=no version=3.4.1
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=googlemail.com; s=20120113;
        h=from:to:cc:subject:date:message-id:in-reply-to:references;
        bh=A7c1hU91SgAo6kzuF14hc2Bi/QLE8RwH5Ir+u+mjZd8=;
        b=u4JOykqmsNFqu7zoIe2HTxhBiBIi86mKoh8QubZuneFCHod05fEeQlTV+eNCo08Mp6
         bkQSfW+sdPf5Y9BXFUFQ44dN9R/jgJeWU1sJEerHWf8rrBu7dYFdx9pOVUQIPIt7zbs2
         6trDTWYzo9SESKJrwjD/Uo/5isV5WRWMaAgMVRlpeX0siRPyHeZWkp4SxR2uVvAJQFxM
         KYgcujeqBwEKFqvMcA8uvfoM0NnmdZwEHhTvpXcPI9hfgLHXBF6fk1uTSdfGSKYL0pnq
         R5P5//Hvmr3AHSW0A5+VsnpmTUy95WLAkCZkoXIfV3dMJA3S4sM+x/aBPSw/3oeY1D1y
         78TQ==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20130820;
        h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to
         :references;
        bh=A7c1hU91SgAo6kzuF14hc2Bi/QLE8RwH5Ir+u+mjZd8=;
        b=hbgj0xVH9RUq8Oppojn4dDVo1rL99WMbX76383Ydj5tm+V9/9QVJK7sU2uWsi8CtUK
         GpKfnVF8N/+0nwA1QUR1n5JkTIRG9rIYPdYUCa1XM3bytG6z0FXK/aU4F3pghaGr1sE/
         u3uJQWOJiNmuSOA8kOYYhvhgqC0ssfQWOWEYMmqsk/wgRBrLpl2WXFKy7xw2BtkH381B
         vgpN7S0U05ZXZEa4Kbym2by+017O5gzT2+330xH2fNHtU5JgkRbcYl3xAqd/BunXSmNa
         llWGxGbdOeJ8GkgZdiJpDcYLM+55CTPwhlmog/61mBiE9qiiXKvCohqem4Y4e+/ioRap
         efrA==
X-Gm-Message-State: AD7BkJJDU1exBK/mIbROVjgwE8+PnT5zAn98/a26pt3wB4laE4+DorKzLrDKb6IlzXbI4g==
X-Received: by 10.28.53.134 with SMTP id c128mr14316926wma.10.1457906537234;
        Sun, 13 Mar 2016 15:02:17 -0700 (PDT)
From: m0viefreak <m0viefreak.cm@googlemail.com>
To: zsh-workers@zsh.org
Cc: m0viefreak <m0viefreak.cm@googlemail.com>
Subject: [PATCH 4/4] completion: _git: diff: add --no-index
Date: Sun, 13 Mar 2016 23:02:00 +0100
Message-Id: <1457906520-2612-5-git-send-email-m0viefreak.cm@googlemail.com>
X-Mailer: git-send-email 2.5.0.234.gefc8a62
In-Reply-To: <1457906520-2612-1-git-send-email-m0viefreak.cm@googlemail.com>
References: <1457906520-2612-1-git-send-email-m0viefreak.cm@googlemail.com>
X-Seq: zsh-workers 38147

---
 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

