495
495
# 4: A suffix to be appended to each possible completion word (optional).
496
496
__gitcomp ()
497
497
{
498
- local cur_=" $cur "
498
+ local cur_=" ${3- $ cur} "
499
499
500
- if [ $# -gt 2 ]; then
501
- cur_=" $3 "
502
- fi
503
500
case " $cur_ " in
504
501
--* =)
505
502
COMPREPLY=()
@@ -524,18 +521,8 @@ __gitcomp ()
524
521
# appended.
525
522
__gitcomp_nl ()
526
523
{
527
- local s=$' \n ' IFS=' ' $' \t ' $' \n '
528
- local cur_=" $cur " suffix=" "
529
-
530
- if [ $# -gt 2 ]; then
531
- cur_=" $3 "
532
- if [ $# -gt 3 ]; then
533
- suffix=" $4 "
534
- fi
535
- fi
536
-
537
- IFS=$s
538
- COMPREPLY=($( compgen -P " ${2-} " -S " $suffix " -W " $1 " -- " $cur_ " ) )
524
+ local IFS=$' \n '
525
+ COMPREPLY=($( compgen -P " ${2-} " -S " ${4- } " -W " $1 " -- " ${3-$cur } " ) )
539
526
}
540
527
541
528
__git_heads ()
@@ -643,13 +630,8 @@ __git_refs_remotes ()
643
630
644
631
__git_remotes ()
645
632
{
646
- local i ngoff IFS=$' \n ' d=" $( __gitdir) "
647
- __git_shopt -q nullglob || ngoff=1
648
- __git_shopt -s nullglob
649
- for i in " $d /remotes" /* ; do
650
- echo ${i# $d / remotes/ }
651
- done
652
- [ " $ngoff " ] && __git_shopt -u nullglob
633
+ local i IFS=$' \n ' d=" $( __gitdir) "
634
+ test -d " $d /remotes" && ls -1 " $d /remotes"
653
635
for i in $( git --git-dir=" $d " config --get-regexp ' remote\..*\.url' 2> /dev/null) ; do
654
636
i=" ${i# remote.} "
655
637
echo " ${i/ .url*/ } "
@@ -676,7 +658,8 @@ __git_merge_strategies=
676
658
# is needed.
677
659
__git_compute_merge_strategies ()
678
660
{
679
- : ${__git_merge_strategies:= $(__git_list_merge_strategies)}
661
+ test -n " $__git_merge_strategies " ||
662
+ __git_merge_strategies=$( __git_list_merge_strategies)
680
663
}
681
664
682
665
__git_complete_revlist_file ()
@@ -854,7 +837,8 @@ __git_list_all_commands ()
854
837
__git_all_commands=
855
838
__git_compute_all_commands ()
856
839
{
857
- : ${__git_all_commands:= $(__git_list_all_commands)}
840
+ test -n " $__git_all_commands " ||
841
+ __git_all_commands=$( __git_list_all_commands)
858
842
}
859
843
860
844
__git_list_porcelain_commands ()
@@ -947,7 +931,8 @@ __git_porcelain_commands=
947
931
__git_compute_porcelain_commands ()
948
932
{
949
933
__git_compute_all_commands
950
- : ${__git_porcelain_commands:= $(__git_list_porcelain_commands)}
934
+ test -n " $__git_porcelain_commands " ||
935
+ __git_porcelain_commands=$( __git_list_porcelain_commands)
951
936
}
952
937
953
938
__git_pretty_aliases ()
@@ -2733,33 +2718,3 @@ if [ Cygwin = "$(uname -o 2>/dev/null)" ]; then
2733
2718
complete -o bashdefault -o default -o nospace -F _git git.exe 2> /dev/null \
2734
2719
|| complete -o default -o nospace -F _git git.exe
2735
2720
fi
2736
-
2737
- if [[ -n ${ZSH_VERSION-} ]]; then
2738
- __git_shopt () {
2739
- local option
2740
- if [ $# -ne 2 ]; then
2741
- echo " USAGE: $0 (-q|-s|-u) <option>" >&2
2742
- return 1
2743
- fi
2744
- case " $2 " in
2745
- nullglob)
2746
- option=" $2 "
2747
- ;;
2748
- * )
2749
- echo " $0 : invalid option: $2 " >&2
2750
- return 1
2751
- esac
2752
- case " $1 " in
2753
- -q) setopt | grep -q " $option " ;;
2754
- -u) unsetopt " $option " ;;
2755
- -s) setopt " $option " ;;
2756
- * )
2757
- echo " $0 : invalid flag: $1 " >&2
2758
- return 1
2759
- esac
2760
- }
2761
- else
2762
- __git_shopt () {
2763
- shopt " $@ "
2764
- }
2765
- fi
0 commit comments