@@ -2601,21 +2601,6 @@ _git ()
26012601{
26022602 local i c=1 command __git_dir
26032603
2604- if [[ -n ${ZSH_VERSION-} ]]; then
2605- emulate -L bash
2606- setopt KSH_TYPESET
2607-
2608- # workaround zsh's bug that leaves 'words' as a special
2609- # variable in versions < 4.3.12
2610- typeset -h words
2611-
2612- # workaround zsh's bug that quotes spaces in the COMPREPLY
2613- # array if IFS doesn't contain spaces.
2614- typeset -h IFS
2615- fi
2616-
2617- local cur words cword prev
2618- _get_comp_words_by_ref -n =: cur words cword prev
26192604 while [ $c -lt $cword ]; do
26202605 i=" ${words[c]} "
26212606 case " $i " in
@@ -2665,22 +2650,6 @@ _git ()
26652650
26662651_gitk ()
26672652{
2668- if [[ -n ${ZSH_VERSION-} ]]; then
2669- emulate -L bash
2670- setopt KSH_TYPESET
2671-
2672- # workaround zsh's bug that leaves 'words' as a special
2673- # variable in versions < 4.3.12
2674- typeset -h words
2675-
2676- # workaround zsh's bug that quotes spaces in the COMPREPLY
2677- # array if IFS doesn't contain spaces.
2678- typeset -h IFS
2679- fi
2680-
2681- local cur words cword prev
2682- _get_comp_words_by_ref -n =: cur words cword prev
2683-
26842653 __git_has_doubledash && return
26852654
26862655 local g=" $( __gitdir) "
@@ -2701,16 +2670,43 @@ _gitk ()
27012670 __git_complete_revlist
27022671}
27032672
2704- complete -o bashdefault -o default -o nospace -F _git git 2> /dev/null \
2705- || complete -o default -o nospace -F _git git
2706- complete -o bashdefault -o default -o nospace -F _gitk gitk 2> /dev/null \
2707- || complete -o default -o nospace -F _gitk gitk
2673+ __git_func_wrap ()
2674+ {
2675+ if [[ -n ${ZSH_VERSION-} ]]; then
2676+ emulate -L bash
2677+ setopt KSH_TYPESET
2678+
2679+ # workaround zsh's bug that leaves 'words' as a special
2680+ # variable in versions < 4.3.12
2681+ typeset -h words
2682+
2683+ # workaround zsh's bug that quotes spaces in the COMPREPLY
2684+ # array if IFS doesn't contain spaces.
2685+ typeset -h IFS
2686+ fi
2687+ local cur words cword prev
2688+ _get_comp_words_by_ref -n =: cur words cword prev
2689+ $1
2690+ }
2691+
2692+ # Setup completion for certain functions defined above by setting common
2693+ # variables and workarounds.
2694+ # This is NOT a public function; use at your own risk.
2695+ __git_complete ()
2696+ {
2697+ local wrapper=" __git_wrap${2} "
2698+ eval " $wrapper () { __git_func_wrap $2 ; }"
2699+ complete -o bashdefault -o default -o nospace -F $wrapper $1 2> /dev/null \
2700+ || complete -o default -o nospace -F $wrapper $1
2701+ }
2702+
2703+ __git_complete git _git
2704+ __git_complete gitk _gitk
27082705
27092706# The following are necessary only for Cygwin, and only are needed
27102707# when the user has tab-completed the executable name and consequently
27112708# included the '.exe' suffix.
27122709#
27132710if [ Cygwin = " $( uname -o 2> /dev/null) " ]; then
2714- complete -o bashdefault -o default -o nospace -F _git git.exe 2> /dev/null \
2715- || complete -o default -o nospace -F _git git.exe
2711+ __git_complete git.exe _git
27162712fi
0 commit comments