Skip to content

Commit dad4277

Browse files
jrngitster
authored andcommitted
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 <[email protected]> Acked-by: SZEDER Gábor <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 3bee6a4 commit dad4277

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

contrib/completion/git-completion.bash

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -628,12 +628,12 @@ __git_refs_remotes ()
628628
__git_remotes ()
629629
{
630630
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
633633
for i in "$d/remotes"/*; do
634634
echo ${i#$d/remotes/}
635635
done
636-
[ "$ngoff" ] && shopt -u nullglob
636+
[ "$ngoff" ] && __git_shopt -u nullglob
637637
for i in $(git --git-dir="$d" config --get-regexp 'remote\..*\.url' 2>/dev/null); do
638638
i="${i#remote.}"
639639
echo "${i/.url*/}"
@@ -2703,7 +2703,7 @@ complete -o bashdefault -o default -o nospace -F _git git.exe 2>/dev/null \
27032703
fi
27042704

27052705
if [[ -n ${ZSH_VERSION-} ]]; then
2706-
shopt () {
2706+
__git_shopt () {
27072707
local option
27082708
if [ $# -ne 2 ]; then
27092709
echo "USAGE: $0 (-q|-s|-u) <option>" >&2
@@ -2726,4 +2726,8 @@ if [[ -n ${ZSH_VERSION-} ]]; then
27262726
return 1
27272727
esac
27282728
}
2729+
else
2730+
__git_shopt () {
2731+
shopt "$@"
2732+
}
27292733
fi

0 commit comments

Comments
 (0)