@@ -2603,21 +2603,6 @@ _git ()
2603
2603
{
2604
2604
local i c=1 command __git_dir
2605
2605
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
2621
2606
while [ $c -lt $cword ]; do
2622
2607
i=" ${words[c]} "
2623
2608
case " $i " in
@@ -2667,22 +2652,6 @@ _git ()
2667
2652
2668
2653
_gitk ()
2669
2654
{
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
-
2686
2655
__git_has_doubledash && return
2687
2656
2688
2657
local g=" $( __gitdir) "
@@ -2703,16 +2672,43 @@ _gitk ()
2703
2672
__git_complete_revlist
2704
2673
}
2705
2674
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
2710
2707
2711
2708
# The following are necessary only for Cygwin, and only are needed
2712
2709
# when the user has tab-completed the executable name and consequently
2713
2710
# included the '.exe' suffix.
2714
2711
#
2715
2712
if [ 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
2718
2714
fi
0 commit comments