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 <felipe.contreras@gmail.com> Signed-off-by: Jonathan Nieder <jrnieder@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Felipe Contreras committed Feb 2, 2012 at 03:05 UTC d79f81adfe02a3f0eaf8deba5fb81dd220b72aae
1 file changed +2 -37
contrib/completion/git-completion.bash
+2 -37
@@ -643,13 +643,8 @@ __git_refs_remotes ()
643
644 __git_remotes ()
645 {
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"
648 for i in $(git --git-dir="$d" config --get-regexp 'remote\..*\.url' 2>/dev/null); do
649 i="${i#remote.}"
650 echo "${i/.url*/}"
@@ -2736,33 +2731,3 @@ if [ Cygwin = "$(uname -o 2>/dev/null)" ]; then
2731 complete -o bashdefault -o default -o nospace -F _git git.exe 2>/dev/null \
2732 || complete -o default -o nospace -F _git git.exe
2733 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