Junio C Hamano <junkio@xxxxxxx> wrote: > Shawn Pearce <spearce@xxxxxxxxxxx> writes: > > > +_git_log () > > +{ > > +... > > +} > > +... > > +_git_whatchanged () > > +{ > > +... > > +} > > These two look the same. Probably not very easy to maintain in > the long run. They are the same. > It would be nice to have git-show as well but it usually does > not take ranges unlike these two. It is more like "git branch" > from completion purposes. Like this? :-) -- >8 -- Consolidated git_log and git_whatchanged; added git_show. Minor requests from Junio: Consolidate the identical implementations of git_log and git_whatchanged, especially since these two commands take pretty much identical arguments. This should make the completion package a little easier to maintain. Also added branch name completion for git-show. I tried to implement --pretty=oneline (etc.) but am apparently missing something as bash did not want to complete it through the registered completion routine, so that's still unsupported. Signed-off-by: Shawn O. Pearce <spearce@xxxxxxxxxxx> --- contrib/bash-git-completion.sh | 21 +++++++-------------- 1 files changed, 7 insertions(+), 14 deletions(-) diff --git a/contrib/bash-git-completion.sh b/contrib/bash-git-completion.sh index 4800185..e8cf6bb 100644 --- a/contrib/bash-git-completion.sh +++ b/contrib/bash-git-completion.sh @@ -254,19 +254,10 @@ _git_push () esac } -_git_whatchanged () +_git_show () { local cur="${COMP_WORDS[COMP_CWORD]}" - case "$cur" in - *..*) - local pfx=$(echo "$cur" | sed 's/\.\..*$/../') - cur=$(echo "$cur" | sed 's/^.*\.\.//') - COMPREPLY=($(compgen -P "$pfx" -W "$(__git_refs .)" -- "$cur")) - ;; - *) - COMPREPLY=($(compgen -W "$(__git_refs .)" -- "$cur")) - ;; - esac + COMPREPLY=($(compgen -W "$(__git_refs .)" -- "$cur")) } _git () @@ -288,7 +279,8 @@ _git () ls-tree) _git_ls_tree ;; pull) _git_pull ;; push) _git_push ;; - whatchanged) _git_whatchanged ;; + show) _git_show ;; + whatchanged) _git_log ;; *) COMPREPLY=() ;; esac fi @@ -314,7 +306,8 @@ complete -o default -o nospace -F _git_l complete -o default -F _git_merge_base git-merge-base complete -o default -o nospace -F _git_pull git-pull complete -o default -o nospace -F _git_push git-push -complete -o default -o nospace -F _git_whatchanged git-whatchanged +complete -o default -F _git_show git-show +complete -o default -o nospace -F _git_log git-whatchanged # The following are necessary only for Cygwin, and only are needed # when the user has tab-completed the executable name and consequently @@ -327,4 +320,4 @@ complete -o default -o nospace -F _git_l complete -o default -o nospace -F _git_ls_tree git-ls-tree.exe complete -o default -F _git_merge_base git-merge-base.exe complete -o default -o nospace -F _git_push git-push.exe -complete -o default -o nospace -F _git_whatchanged git-whatchanged.exe +complete -o default -o nospace -F _git_log git-whatchanged.exe -- 1.4.2.1.ga817 - To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html