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