completion: move private shopt shim for zsh to __git_ namespace

Most zsh users probably probably do not expect a custom shopt function to enter their environment just because they ran "source ~/.git-completion.sh". Such namespace pollution makes development of other scripts confusing (because it makes the bash-specific shopt utility seem to be available in zsh) and makes git's tab completion script brittle (since any other shell snippet implementing some other subset of shopt will break it). Rename the shopt shim to the more innocuous __git_shopt to be a good citizen (with two underscores to avoid confusion with completion rules for a hypothetical "git shopt" command). Signed-off-by: Jonathan Nieder <jrnieder@gmail.com> Acked-by: SZEDER Gábor <szeder@ira.uka.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Jonathan Nieder committed Apr 27, 2011 at 16:27 UTC dad4277529b856bffe07760ac3928d06b5424fdc
1 file changed +8 -4
contrib/completion/git-completion.bash
+8 -4
@@ -628,12 +628,12 @@ __git_refs_remotes ()
628 __git_remotes ()
629 {
630 local i ngoff IFS=$'\n' d="$(__gitdir)"
631 - shopt -q nullglob || ngoff=1
632 - shopt -s nullglob
631 + __git_shopt -q nullglob || ngoff=1
632 + __git_shopt -s nullglob
633 for i in "$d/remotes"/*; do
634 echo ${i#$d/remotes/}
635 done
636 - [ "$ngoff" ] && shopt -u nullglob
636 + [ "$ngoff" ] && __git_shopt -u nullglob
637 for i in $(git --git-dir="$d" config --get-regexp 'remote\..*\.url' 2>/dev/null); do
638 i="${i#remote.}"
639 echo "${i/.url*/}"
@@ -2703,7 +2703,7 @@ complete -o bashdefault -o default -o nospace -F _git git.exe 2>/dev/null \
2703 fi
2704
2705 if [[ -n ${ZSH_VERSION-} ]]; then
2706 - shopt () {
2706 + __git_shopt () {
2707 local option
2708 if [ $# -ne 2 ]; then
2709 echo "USAGE: $0 (-q|-s|-u) <option>" >&2
@@ -2726,4 +2726,8 @@ if [[ -n ${ZSH_VERSION-} ]]; then
2726 return 1
2727 esac
2728 }
2729 +else
2730 + __git_shopt () {
2731 + shopt "$@"
2732 + }
2733 fi