From 2ea9cd47752de9bd5b791c9394b3f625a35db3c2 Mon Sep 17 00:00:00 2001 From: Ramkumar Ramachandra Date: Sat, 20 Apr 2013 18:26:12 +0530 Subject: 31288: _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 --- Completion/Unix/Command/_git | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) (limited to 'Completion') diff --git a/Completion/Unix/Command/_git b/Completion/Unix/Command/_git index 5d0f8c5a8..db59a9b75 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 -- cgit 1.4.1