zsh-workers
 help / color / mirror / code / Atom feed
From: Ramkumar Ramachandra <artagnon@gmail.com>
To: ZSH Workers <zsh-workers@zsh.org>
Cc: Clint Adams <clint@users.sourceforge.net>,
	Frank Terbeck <bewater@users.sourceforge.net>,
	Nikolai Weibull <pcppopper@users.sourceforge.net>
Subject: [PATCH 2/3] Completion/Unix/Command/_git: fix shortlog completer
Date: Sat, 20 Apr 2013 18:26:12 +0530	[thread overview]
Message-ID: <1366462573-15545-3-git-send-email-artagnon@gmail.com> (raw)
In-Reply-To: <1366462573-15545-1-git-send-email-artagnon@gmail.com>

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@gmail.com>
---
 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


  parent reply	other threads:[~2013-04-20 12:56 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-04-20 12:56 [PATCH 0/3] Completion/Unix/Command/_git: misc fixes Ramkumar Ramachandra
2013-04-20 12:56 ` [PATCH 1/3] Completion/Unix/Command/_git: add a couple of browsers Ramkumar Ramachandra
2013-04-20 12:56 ` Ramkumar Ramachandra [this message]
2013-04-20 13:03   ` [PATCH 2/3] Completion/Unix/Command/_git: fix shortlog completer Nikolai Weibull
2013-04-20 15:05     ` Frank Terbeck
2013-04-20 17:13       ` Ramkumar Ramachandra
2013-04-20 17:35         ` Bart Schaefer
2013-04-20 17:50           ` Ramkumar Ramachandra
2013-04-25 12:42   ` Frank Terbeck
2013-04-25 13:11     ` Nikolai Weibull
2013-04-25 18:12       ` Ramkumar Ramachandra
2013-04-25 17:48     ` Ramkumar Ramachandra
2013-04-25 19:06       ` Frank Terbeck
2013-04-27  8:56         ` Nikolai Weibull
2013-04-27  9:01           ` Nikolai Weibull
2013-04-28 14:30           ` Nikolai Weibull
2013-05-11 16:55             ` Nikolai Weibull
2013-05-12 17:48               ` Peter Stephenson
2013-04-27 10:22         ` Ramkumar Ramachandra
2013-04-27 11:27           ` Frank Terbeck
2013-04-20 12:56 ` [PATCH 3/3] Completion/Unix/Command/_git: branch.*.pushremote, remote.pushdefault Ramkumar Ramachandra
2013-04-21 10:16 ` [PATCH 0/3] Completion/Unix/Command/_git: misc fixes Frank Terbeck

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1366462573-15545-3-git-send-email-artagnon@gmail.com \
    --to=artagnon@gmail.com \
    --cc=bewater@users.sourceforge.net \
    --cc=clint@users.sourceforge.net \
    --cc=pcppopper@users.sourceforge.net \
    --cc=zsh-workers@zsh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).