Skip to content

Commit d79f81a

Browse files
felipecgitster
authored andcommitted
completion: use ls -1 instead of rolling a loop to do that ourselves
This simplifies the code a great deal. In particular, it allows us to get rid of __git_shopt, which is used only in this fuction to enable 'nullglob' in zsh. [jn: squashed with a patch that actually gets rid of __git_shopt] Signed-off-by: Felipe Contreras <[email protected]> Signed-off-by: Jonathan Nieder <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent cf0ff02 commit d79f81a

File tree

1 file changed

+2
-37
lines changed

1 file changed

+2
-37
lines changed

contrib/completion/git-completion.bash

Lines changed: 2 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -643,13 +643,8 @@ __git_refs_remotes ()
643643

644644
__git_remotes ()
645645
{
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
646+
local i IFS=$'\n' d="$(__gitdir)"
647+
test -d "$d/remotes" && ls -1 "$d/remotes"
653648
for i in $(git --git-dir="$d" config --get-regexp 'remote\..*\.url' 2>/dev/null); do
654649
i="${i#remote.}"
655650
echo "${i/.url*/}"
@@ -2736,33 +2731,3 @@ if [ Cygwin = "$(uname -o 2>/dev/null)" ]; then
27362731
complete -o bashdefault -o default -o nospace -F _git git.exe 2>/dev/null \
27372732
|| complete -o default -o nospace -F _git git.exe
27382733
fi
2739-
2740-
if [[ -n ${ZSH_VERSION-} ]]; then
2741-
__git_shopt () {
2742-
local option
2743-
if [ $# -ne 2 ]; then
2744-
echo "USAGE: $0 (-q|-s|-u) <option>" >&2
2745-
return 1
2746-
fi
2747-
case "$2" in
2748-
nullglob)
2749-
option="$2"
2750-
;;
2751-
*)
2752-
echo "$0: invalid option: $2" >&2
2753-
return 1
2754-
esac
2755-
case "$1" in
2756-
-q) setopt | grep -q "$option" ;;
2757-
-u) unsetopt "$option" ;;
2758-
-s) setopt "$option" ;;
2759-
*)
2760-
echo "$0: invalid flag: $1" >&2
2761-
return 1
2762-
esac
2763-
}
2764-
else
2765-
__git_shopt () {
2766-
shopt "$@"
2767-
}
2768-
fi

0 commit comments

Comments
 (0)