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

[PATCH 2/3] Completion/Unix/Command/_git: fix shortlog completer



Currently, __git-shortlog () says that 'git shortlog' can only accept
commits as arguments (probably because the official documentation says
this).  This is entirely untrue: shortlog can accept
commit-range-or-file, just like log can.  Fix the completer by copying
out segments from the __git-log () function.

Signed-off-by: Ramkumar Ramachandra <artagnon@xxxxxxxxx>
---
 Completion/Unix/Command/_git | 27 ++++++++++++++++++++++++++-
 1 file changed, 26 insertions(+), 1 deletion(-)

diff --git a/Completion/Unix/Command/_git b/Completion/Unix/Command/_git
index f1753aa..38b1d80 100644
--- a/Completion/Unix/Command/_git
+++ b/Completion/Unix/Command/_git
@@ -1298,7 +1298,8 @@ _git-shortlog () {
     '(-e --email)'{-e,--email}'[show email addres of each author]' \
     '-w-[linewrap the output]:: :->wrap' \
     $revision_options \
-    '*: :__git_commits' && ret=0
+    '(-)--[start file arguments]' \
+    '*:: :->commit-range-or-file' && ret=0
 
   case $state in
     (wrap)
@@ -1314,6 +1315,30 @@ _git-shortlog () {
         __git_guard_number 'line width'
       fi
       ;;
+    (commit-range-or-file)
+      case $CURRENT in
+        (1)
+          if [[ -n ${opt_args[(I)--]} ]]; then
+            __git_cached_files && ret=0
+          else
+            _alternative \
+              'commit-ranges::__git_commit_ranges' \
+              'cached-files::__git_cached_files' && ret=0
+          fi
+          ;;
+        (*)
+          # TODO: Write a wrapper function that checks whether we have a
+          # committish range or comittish and calls __git_tree_files
+          # appropriately.
+          if __git_is_committish_range $line[1]; then
+            __git_tree_files ${PREFIX:-.} $(__git_committish_range_last $line[1]) && ret=0
+          elif __git_is_committish $line[1]; then
+            __git_tree_files ${PREFIX:-.} $line[1] && ret=0
+          else
+            __git_cached_files && ret=0
+          fi
+          ;;
+      esac
   esac
 
   return ret
-- 
1.8.2.1.506.gbce9ff0



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