@@ -2601,21 +2601,6 @@ _git ()
2601
2601
{
2602
2602
local i c=1 command __git_dir
2603
2603
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
2619
2604
while [ $c -lt $cword ]; do
2620
2605
i=" ${words[c]} "
2621
2606
case " $i " in
@@ -2665,22 +2650,6 @@ _git ()
2665
2650
2666
2651
_gitk ()
2667
2652
{
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
-
2684
2653
__git_has_doubledash && return
2685
2654
2686
2655
local g=" $( __gitdir) "
@@ -2701,16 +2670,43 @@ _gitk ()
2701
2670
__git_complete_revlist
2702
2671
}
2703
2672
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
2708
2705
2709
2706
# The following are necessary only for Cygwin, and only are needed
2710
2707
# when the user has tab-completed the executable name and consequently
2711
2708
# included the '.exe' suffix.
2712
2709
#
2713
2710
if [ 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
2716
2712
fi
0 commit comments