Merge branch 'fc/zsh-completion'
authorJunio C Hamano <gitster@pobox.com>
Mon, 13 Feb 2012 06:42:35 +0000 (22:42 -0800)
committerJunio C Hamano <gitster@pobox.com>
Mon, 13 Feb 2012 06:42:35 +0000 (22:42 -0800)
* fc/zsh-completion:
completion: simplify __gitcomp and __gitcomp_nl implementations
completion: use ls -1 instead of rolling a loop to do that ourselves
completion: work around zsh option propagation bug

1  2 
contrib/completion/git-completion.bash
index a2965f7c6da087acc60b901befe2529a44446647,6c8dc8f1a3fc9bfc0d9d904723da9e7dd321a80d..d7367e9faa87482f638ae4e16df38aa1bb853c40
@@@ -495,11 -495,8 +495,8 @@@ f
  # 4: A suffix to be appended to each possible completion word (optional).
  __gitcomp ()
  {
-       local cur_="$cur"
+       local cur_="${3-$cur}"
  
-       if [ $# -gt 2 ]; then
-               cur_="$3"
-       fi
        case "$cur_" in
        --*=)
                COMPREPLY=()
  #    appended.
  __gitcomp_nl ()
  {
-       local s=$'\n' IFS=' '$'\t'$'\n'
-       local cur_="$cur" suffix=" "
-       if [ $# -gt 2 ]; then
-               cur_="$3"
-               if [ $# -gt 3 ]; then
-                       suffix="$4"
-               fi
-       fi
-       IFS=$s
-       COMPREPLY=($(compgen -P "${2-}" -S "$suffix" -W "$1" -- "$cur_"))
+       local IFS=$'\n'
+       COMPREPLY=($(compgen -P "${2-}" -S "${4- }" -W "$1" -- "${3-$cur}"))
  }
  
  __git_heads ()
@@@ -643,13 -630,8 +630,8 @@@ __git_refs_remotes (
  
  __git_remotes ()
  {
-       local i ngoff IFS=$'\n' d="$(__gitdir)"
-       __git_shopt -q nullglob || ngoff=1
-       __git_shopt -s nullglob
-       for i in "$d/remotes"/*; do
-               echo ${i#$d/remotes/}
-       done
-       [ "$ngoff" ] && __git_shopt -u nullglob
+       local i IFS=$'\n' d="$(__gitdir)"
+       test -d "$d/remotes" && ls -1 "$d/remotes"
        for i in $(git --git-dir="$d" config --get-regexp 'remote\..*\.url' 2>/dev/null); do
                i="${i#remote.}"
                echo "${i/.url*/}"
@@@ -676,7 -658,8 +658,8 @@@ __git_merge_strategies
  # is needed.
  __git_compute_merge_strategies ()
  {
-       : ${__git_merge_strategies:=$(__git_list_merge_strategies)}
+       test -n "$__git_merge_strategies" ||
+       __git_merge_strategies=$(__git_list_merge_strategies)
  }
  
  __git_complete_revlist_file ()
@@@ -854,7 -837,8 +837,8 @@@ __git_list_all_commands (
  __git_all_commands=
  __git_compute_all_commands ()
  {
-       : ${__git_all_commands:=$(__git_list_all_commands)}
+       test -n "$__git_all_commands" ||
+       __git_all_commands=$(__git_list_all_commands)
  }
  
  __git_list_porcelain_commands ()
@@@ -947,7 -931,8 +931,8 @@@ __git_porcelain_commands
  __git_compute_porcelain_commands ()
  {
        __git_compute_all_commands
-       : ${__git_porcelain_commands:=$(__git_list_porcelain_commands)}
+       test -n "$__git_porcelain_commands" ||
+       __git_porcelain_commands=$(__git_list_porcelain_commands)
  }
  
  __git_pretty_aliases ()
@@@ -1152,7 -1137,7 +1137,7 @@@ _git_branch (
                __gitcomp "
                        --color --no-color --verbose --abbrev= --no-abbrev
                        --track --no-track --contains --merged --no-merged
 -                      --set-upstream
 +                      --set-upstream --edit-description
                        "
                ;;
        *)
@@@ -1622,7 -1607,7 +1607,7 @@@ _git_log (
  
  __git_merge_options="
        --no-commit --no-stat --log --no-log --squash --strategy
 -      --commit --stat --no-squash --ff --no-ff --ff-only
 +      --commit --stat --no-squash --ff --no-ff --ff-only --edit --no-edit
  "
  
  _git_merge ()
@@@ -2733,33 -2718,3 +2718,3 @@@ if [ Cygwin = "$(uname -o 2>/dev/null)
  complete -o bashdefault -o default -o nospace -F _git git.exe 2>/dev/null \
        || complete -o default -o nospace -F _git git.exe
  fi
- if [[ -n ${ZSH_VERSION-} ]]; then
-       __git_shopt () {
-               local option
-               if [ $# -ne 2 ]; then
-                       echo "USAGE: $0 (-q|-s|-u) <option>" >&2
-                       return 1
-               fi
-               case "$2" in
-               nullglob)
-                       option="$2"
-                       ;;
-               *)
-                       echo "$0: invalid option: $2" >&2
-                       return 1
-               esac
-               case "$1" in
-               -q)     setopt | grep -q "$option" ;;
-               -u)     unsetopt "$option" ;;
-               -s)     setopt "$option" ;;
-               *)
-                       echo "$0: invalid flag: $1" >&2
-                       return 1
-               esac
-       }
- else
-       __git_shopt () {
-               shopt "$@"
-       }
- fi