about summary refs log tree commit diff
diff options
context:
space:
mode:
authorOliver Kiddle <opk@zsh.org>2020-10-29 21:44:19 +0100
committerOliver Kiddle <opk@zsh.org>2020-10-29 21:44:19 +0100
commit2644e3097dd26babf73ea8664f30341b262a2450 (patch)
tree9b22523cc81c9bce15a1a5490867a5f77cfb6b67
parent8773f01f2b7a908af70dc06d7d00481f1c9bec44 (diff)
downloadzsh-2644e3097dd26babf73ea8664f30341b262a2450.tar.gz
zsh-2644e3097dd26babf73ea8664f30341b262a2450.tar.xz
zsh-2644e3097dd26babf73ea8664f30341b262a2450.zip
users/26107: complete changed files after git diff HEAD
-rw-r--r--ChangeLog5
-rw-r--r--Completion/Unix/Command/_git9
2 files changed, 13 insertions, 1 deletions
diff --git a/ChangeLog b/ChangeLog
index 9db67eea0..b7283a07e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2020-10-29  Oliver Kiddle  <opk@zsh.org>
+
+	* users/26107: Completion/Unix/Command/_git: complete changed
+	files after git diff HEAD
+
 2020-10-25  Mikael Magnusson  <mikachu@gmail.com>
 
 	* Jun-ichi Takimoto: 47301: Src/builtin.c: Fix print -v
diff --git a/Completion/Unix/Command/_git b/Completion/Unix/Command/_git
index 05e2a2361..81a060e4d 100644
--- a/Completion/Unix/Command/_git
+++ b/Completion/Unix/Command/_git
@@ -806,11 +806,14 @@ _git-diff () {
             # Example: git diff branch1..branch2 <tab>
             __git_tree_files ${PREFIX:-.} $(__git_committish_range_last $line[1]) && ret=0
           elif __git_is_committish $line[1] || __git_is_treeish $line[1]; then
+            local files_alt='files::__git_tree_files ${PREFIX:-.} HEAD'
+            [[ $line[1] = (HEAD|@) ]] &&
+                files_alt='files::__git_changed_files'
             # Example: git diff branch1 <tab>
             _alternative \
               'commits::__git_commits' \
               'blobs-and-trees-in-treeish::__git_blobs_and_trees_in_treeish' \
-              'files::__git_tree_files ${PREFIX:-.} HEAD' && ret=0
+              $files_alt && ret=0
           elif __git_is_blob $line[1]; then
             _alternative \
               'files::__git_cached_files' \
@@ -831,6 +834,10 @@ _git-diff () {
               __git_is_treeish $line[2]; then
             # Example: git diff branch1 branch2 <tab>
             __git_tree_files ${PREFIX:-.} $line[2] && ret=0
+          elif [[ $line[1] = (HEAD|@) ]]; then
+            # Example: git diff @ file1 <tab>
+            # Example: git diff HEAD -- <tab>
+            __git_ignore_line __git_changed_files && ret=0
           elif __git_is_committish $line[1] || __git_is_treeish $line[1]; then
             # Example: git diff branch file1 <tab>
             # Example: git diff branch -- f<tab>