Merge branch 'sg/completion'
authorJunio C Hamano <gitster@pobox.com>
Tue, 18 Oct 2011 04:37:13 +0000 (21:37 -0700)
committerJunio C Hamano <gitster@pobox.com>
Tue, 18 Oct 2011 04:37:13 +0000 (21:37 -0700)
* sg/completion:
completion: unite --format and --pretty for 'log' and 'show'
completion: unite --reuse-message and --reedit-message for 'notes'

1  2 
contrib/completion/git-completion.bash
index 344119b1b7be234b1c4a87148ce5c0d4ca0d3225,5c649c6f46524dab6e43425a60cdf29876d12763..888e8e10ccd932df3aa8f30a3d83441d5485fc30
@@@ -1,6 -1,6 +1,6 @@@
  #!bash
  #
 -# bash completion support for core Git.
 +# bash/zsh completion support for core Git.
  #
  # Copyright (C) 2006,2007 Shawn O. Pearce <spearce@spearce.org>
  # Conceptually based on gitcompletion (http://gitweb.hawaga.org.uk/).
  # To use these routines:
  #
  #    1) Copy this file to somewhere (e.g. ~/.git-completion.sh).
 -#    2) Added the following line to your .bashrc:
 -#        source ~/.git-completion.sh
 -#
 -#       Or, add the following lines to your .zshrc:
 -#        autoload bashcompinit
 -#        bashcompinit
 +#    2) Add the following line to your .bashrc/.zshrc:
  #        source ~/.git-completion.sh
  #
  #    3) Consider changing your PS1 to also show the current branch:
 -#        PS1='[\u@\h \W$(__git_ps1 " (%s)")]\$ '
 +#         Bash: PS1='[\u@\h \W$(__git_ps1 " (%s)")]\$ '
 +#         ZSH:  PS1='[%n@%m %c$(__git_ps1 " (%s)")]\$ '
  #
  #       The argument to __git_ps1 will be displayed only if you
  #       are currently in a git repository.  The %s token will be
  #       git@vger.kernel.org
  #
  
 +if [[ -n ${ZSH_VERSION-} ]]; then
 +      autoload -U +X bashcompinit && bashcompinit
 +fi
 +
  case "$COMP_WORDBREAKS" in
  *:*) : great ;;
  *)   COMP_WORDBREAKS="$COMP_WORDBREAKS:"
  # generates completion reply with compgen
  __gitcomp ()
  {
 -      local cur
 -      _get_comp_words_by_ref -n =: cur
 +      local cur_="$cur"
 +
        if [ $# -gt 2 ]; then
 -              cur="$3"
 +              cur_="$3"
        fi
 -      case "$cur" in
 +      case "$cur_" in
        --*=)
                COMPREPLY=()
                ;;
                local IFS=$'\n'
                COMPREPLY=($(compgen -P "${2-}" \
                        -W "$(__gitcomp_1 "${1-}" "${4-}")" \
 -                      -- "$cur"))
 +                      -- "$cur_"))
                ;;
        esac
  }
@@@ -551,7 -551,8 +551,7 @@@ __git_tags (
  __git_refs ()
  {
        local i is_hash=y dir="$(__gitdir "${1-}")" track="${2-}"
 -      local cur format refs
 -      _get_comp_words_by_ref -n =: cur
 +      local format refs
        if [ -d "$dir" ]; then
                case "$cur" in
                refs|refs/*)
@@@ -628,12 -629,12 +628,12 @@@ __git_refs_remotes (
  __git_remotes ()
  {
        local i ngoff IFS=$'\n' d="$(__gitdir)"
 -      shopt -q nullglob || ngoff=1
 -      shopt -s nullglob
 +      __git_shopt -q nullglob || ngoff=1
 +      __git_shopt -s nullglob
        for i in "$d/remotes"/*; do
                echo ${i#$d/remotes/}
        done
 -      [ "$ngoff" ] && shopt -u nullglob
 +      [ "$ngoff" ] && __git_shopt -u nullglob
        for i in $(git --git-dir="$d" config --get-regexp 'remote\..*\.url' 2>/dev/null); do
                i="${i#remote.}"
                echo "${i/.url*/}"
@@@ -665,18 -666,19 +665,18 @@@ __git_compute_merge_strategies (
  
  __git_complete_revlist_file ()
  {
 -      local pfx ls ref cur
 -      _get_comp_words_by_ref -n =: cur
 -      case "$cur" in
 +      local pfx ls ref cur_="$cur"
 +      case "$cur_" in
        *..?*:*)
                return
                ;;
        ?*:*)
 -              ref="${cur%%:*}"
 -              cur="${cur#*:}"
 -              case "$cur" in
 +              ref="${cur_%%:*}"
 +              cur_="${cur_#*:}"
 +              case "$cur_" in
                ?*/*)
 -                      pfx="${cur%/*}"
 -                      cur="${cur##*/}"
 +                      pfx="${cur_%/*}"
 +                      cur_="${cur_##*/}"
                        ls="$ref:$pfx"
                        pfx="$pfx/"
                        ;;
                                           s,$,/,
                                       }
                                       s/^.*    //')" \
 -                      -- "$cur"))
 +                      -- "$cur_"))
                ;;
        *...*)
 -              pfx="${cur%...*}..."
 -              cur="${cur#*...}"
 -              __gitcomp "$(__git_refs)" "$pfx" "$cur"
 +              pfx="${cur_%...*}..."
 +              cur_="${cur_#*...}"
 +              __gitcomp "$(__git_refs)" "$pfx" "$cur_"
                ;;
        *..*)
 -              pfx="${cur%..*}.."
 -              cur="${cur#*..}"
 -              __gitcomp "$(__git_refs)" "$pfx" "$cur"
 +              pfx="${cur_%..*}.."
 +              cur_="${cur_#*..}"
 +              __gitcomp "$(__git_refs)" "$pfx" "$cur_"
                ;;
        *)
                __gitcomp "$(__git_refs)"
@@@ -737,7 -739,9 +737,7 @@@ __git_complete_revlist (
  
  __git_complete_remote_or_refspec ()
  {
 -      local cur words cword
 -      _get_comp_words_by_ref -n =: cur words cword
 -      local cmd="${words[1]}"
 +      local cur_="$cur" cmd="${words[1]}"
        local i c=2 remote="" pfx="" lhs=1 no_complete_refspec=0
        while [ $c -lt $cword ]; do
                i="${words[c]}"
                return
        fi
        [ "$remote" = "." ] && remote=
 -      case "$cur" in
 +      case "$cur_" in
        *:*)
                case "$COMP_WORDBREAKS" in
                *:*) : great ;;
 -              *)   pfx="${cur%%:*}:" ;;
 +              *)   pfx="${cur_%%:*}:" ;;
                esac
 -              cur="${cur#*:}"
 +              cur_="${cur_#*:}"
                lhs=0
                ;;
        +*)
                pfx="+"
 -              cur="${cur#+}"
 +              cur_="${cur_#+}"
                ;;
        esac
        case "$cmd" in
        fetch)
                if [ $lhs = 1 ]; then
 -                      __gitcomp "$(__git_refs2 "$remote")" "$pfx" "$cur"
 +                      __gitcomp "$(__git_refs2 "$remote")" "$pfx" "$cur_"
                else
 -                      __gitcomp "$(__git_refs)" "$pfx" "$cur"
 +                      __gitcomp "$(__git_refs)" "$pfx" "$cur_"
                fi
                ;;
        pull)
                if [ $lhs = 1 ]; then
 -                      __gitcomp "$(__git_refs "$remote")" "$pfx" "$cur"
 +                      __gitcomp "$(__git_refs "$remote")" "$pfx" "$cur_"
                else
 -                      __gitcomp "$(__git_refs)" "$pfx" "$cur"
 +                      __gitcomp "$(__git_refs)" "$pfx" "$cur_"
                fi
                ;;
        push)
                if [ $lhs = 1 ]; then
 -                      __gitcomp "$(__git_refs)" "$pfx" "$cur"
 +                      __gitcomp "$(__git_refs)" "$pfx" "$cur_"
                else
 -                      __gitcomp "$(__git_refs "$remote")" "$pfx" "$cur"
 +                      __gitcomp "$(__git_refs "$remote")" "$pfx" "$cur_"
                fi
                ;;
        esac
  
  __git_complete_strategy ()
  {
 -      local cur prev
 -      _get_comp_words_by_ref -n =: cur prev
        __git_compute_merge_strategies
        case "$prev" in
        -s|--strategy)
@@@ -985,7 -991,8 +985,7 @@@ __git_aliased_command (
  # __git_find_on_cmdline requires 1 argument
  __git_find_on_cmdline ()
  {
 -      local word subcommand c=1 words cword
 -      _get_comp_words_by_ref -n =: words cword
 +      local word subcommand c=1
        while [ $c -lt $cword ]; do
                word="${words[c]}"
                for subcommand in $1; do
  
  __git_has_doubledash ()
  {
 -      local c=1 words cword
 -      _get_comp_words_by_ref -n =: words cword
 +      local c=1
        while [ $c -lt $cword ]; do
                if [ "--" = "${words[c]}" ]; then
                        return 0
@@@ -1014,7 -1022,8 +1014,7 @@@ __git_whitespacelist="nowarn warn erro
  
  _git_am ()
  {
 -      local cur dir="$(__gitdir)"
 -      _get_comp_words_by_ref -n =: cur
 +      local dir="$(__gitdir)"
        if [ -d "$dir"/rebase-apply ]; then
                __gitcomp "--skip --continue --resolved --abort"
                return
  
  _git_apply ()
  {
 -      local cur
 -      _get_comp_words_by_ref -n =: cur
        case "$cur" in
        --whitespace=*)
                __gitcomp "$__git_whitespacelist" "" "${cur##--whitespace=}"
@@@ -1060,6 -1071,8 +1060,6 @@@ _git_add (
  {
        __git_has_doubledash && return
  
 -      local cur
 -      _get_comp_words_by_ref -n =: cur
        case "$cur" in
        --*)
                __gitcomp "
  
  _git_archive ()
  {
 -      local cur
 -      _get_comp_words_by_ref -n =: cur
        case "$cur" in
        --format=*)
                __gitcomp "$(git archive --list)" "" "${cur##--format=}"
@@@ -1120,8 -1135,9 +1120,8 @@@ _git_bisect (
  
  _git_branch ()
  {
 -      local i c=1 only_local_ref="n" has_r="n" cur words cword
 +      local i c=1 only_local_ref="n" has_r="n"
  
 -      _get_comp_words_by_ref -n =: cur words cword
        while [ $c -lt $cword ]; do
                i="${words[c]}"
                case "$i" in
  
  _git_bundle ()
  {
 -      local words cword
 -      _get_comp_words_by_ref -n =: words cword
        local cmd="${words[2]}"
        case "$cword" in
        2)
@@@ -1173,6 -1191,8 +1173,6 @@@ _git_checkout (
  {
        __git_has_doubledash && return
  
 -      local cur
 -      _get_comp_words_by_ref -n =: cur
        case "$cur" in
        --conflict=*)
                __gitcomp "diff3 merge" "" "${cur##--conflict=}"
@@@ -1202,6 -1222,8 +1202,6 @@@ _git_cherry (
  
  _git_cherry_pick ()
  {
 -      local cur
 -      _get_comp_words_by_ref -n =: cur
        case "$cur" in
        --*)
                __gitcomp "--edit --no-commit"
@@@ -1216,6 -1238,8 +1216,6 @@@ _git_clean (
  {
        __git_has_doubledash && return
  
 -      local cur
 -      _get_comp_words_by_ref -n =: cur
        case "$cur" in
        --*)
                __gitcomp "--dry-run --quiet"
  
  _git_clone ()
  {
 -      local cur
 -      _get_comp_words_by_ref -n =: cur
        case "$cur" in
        --*)
                __gitcomp "
@@@ -1253,6 -1279,8 +1253,6 @@@ _git_commit (
  {
        __git_has_doubledash && return
  
 -      local cur
 -      _get_comp_words_by_ref -n =: cur
        case "$cur" in
        --cleanup=*)
                __gitcomp "default strip verbatim whitespace
  
  _git_describe ()
  {
 -      local cur
 -      _get_comp_words_by_ref -n =: cur
        case "$cur" in
        --*)
                __gitcomp "
@@@ -1315,6 -1345,8 +1315,6 @@@ _git_diff (
  {
        __git_has_doubledash && return
  
 -      local cur
 -      _get_comp_words_by_ref -n =: cur
        case "$cur" in
        --*)
                __gitcomp "--cached --staged --pickaxe-all --pickaxe-regex
@@@ -1335,6 -1367,8 +1335,6 @@@ _git_difftool (
  {
        __git_has_doubledash && return
  
 -      local cur
 -      _get_comp_words_by_ref -n =: cur
        case "$cur" in
        --tool=*)
                __gitcomp "$__git_mergetools_common kompare" "" "${cur##--tool=}"
@@@ -1359,6 -1393,8 +1359,6 @@@ __git_fetch_options=
  
  _git_fetch ()
  {
 -      local cur
 -      _get_comp_words_by_ref -n =: cur
        case "$cur" in
        --*)
                __gitcomp "$__git_fetch_options"
  
  _git_format_patch ()
  {
 -      local cur
 -      _get_comp_words_by_ref -n =: cur
        case "$cur" in
        --thread=*)
                __gitcomp "
  
  _git_fsck ()
  {
 -      local cur
 -      _get_comp_words_by_ref -n =: cur
        case "$cur" in
        --*)
                __gitcomp "
  
  _git_gc ()
  {
 -      local cur
 -      _get_comp_words_by_ref -n =: cur
        case "$cur" in
        --*)
                __gitcomp "--prune --aggressive"
@@@ -1433,14 -1475,15 +1433,14 @@@ _git_grep (
  {
        __git_has_doubledash && return
  
 -      local cur
 -      _get_comp_words_by_ref -n =: cur
        case "$cur" in
        --*)
                __gitcomp "
                        --cached
                        --text --ignore-case --word-regexp --invert-match
 -                      --full-name
 +                      --full-name --line-number
                        --extended-regexp --basic-regexp --fixed-strings
 +                      --perl-regexp
                        --files-with-matches --name-only
                        --files-without-match
                        --max-depth
  
  _git_help ()
  {
 -      local cur
 -      _get_comp_words_by_ref -n =: cur
        case "$cur" in
        --*)
                __gitcomp "--all --info --man --web"
        __gitcomp "$__git_all_commands $(__git_aliases)
                attributes cli core-tutorial cvs-migration
                diffcore gitk glossary hooks ignore modules
 -              repository-layout tutorial tutorial-2
 +              namespaces repository-layout tutorial tutorial-2
                workflows
                "
  }
  
  _git_init ()
  {
 -      local cur
 -      _get_comp_words_by_ref -n =: cur
        case "$cur" in
        --shared=*)
                __gitcomp "
@@@ -1492,6 -1539,8 +1492,6 @@@ _git_ls_files (
  {
        __git_has_doubledash && return
  
 -      local cur
 -      _get_comp_words_by_ref -n =: cur
        case "$cur" in
        --*)
                __gitcomp "--cached --deleted --modified --others --ignored
@@@ -1532,7 -1581,7 +1532,7 @@@ __git_log_common_options=
  __git_log_gitk_options="
        --dense --sparse --full-history
        --simplify-merges --simplify-by-decoration
 -      --left-right
 +      --left-right --notes --no-notes
  "
  # Options that go well for log and shortlog (not gitk)
  __git_log_shortlog_options="
@@@ -1552,15 -1601,12 +1552,10 @@@ _git_log (
        if [ -f "$g/MERGE_HEAD" ]; then
                merge="--merge"
        fi
 -      local cur
 -      _get_comp_words_by_ref -n =: cur
        case "$cur" in
-       --pretty=*)
+       --pretty=*|--format=*)
                __gitcomp "$__git_log_pretty_formats $(__git_pretty_aliases)
-                       " "" "${cur##--pretty=}"
-               return
-               ;;
-       --format=*)
-               __gitcomp "$__git_log_pretty_formats $(__git_pretty_aliases)
-                       " "" "${cur##--format=}"
+                       " "" "${cur#*=}"
                return
                ;;
        --date=*)
@@@ -1605,6 -1651,8 +1600,6 @@@ _git_merge (
  {
        __git_complete_strategy && return
  
 -      local cur
 -      _get_comp_words_by_ref -n =: cur
        case "$cur" in
        --*)
                __gitcomp "$__git_merge_options"
  
  _git_mergetool ()
  {
 -      local cur
 -      _get_comp_words_by_ref -n =: cur
        case "$cur" in
        --tool=*)
                __gitcomp "$__git_mergetools_common tortoisemerge" "" "${cur##--tool=}"
@@@ -1635,6 -1685,8 +1630,6 @@@ _git_merge_base (
  
  _git_mv ()
  {
 -      local cur
 -      _get_comp_words_by_ref -n =: cur
        case "$cur" in
        --*)
                __gitcomp "--dry-run"
@@@ -1653,6 -1705,8 +1648,6 @@@ _git_notes (
  {
        local subcommands='add append copy edit list prune remove show'
        local subcommand="$(__git_find_on_cmdline "$subcommands")"
 -      local cur words cword
 -      _get_comp_words_by_ref -n =: cur words cword
  
        case "$subcommand,$cur" in
        ,--*)
                        ;;
                esac
                ;;
-       add,--reuse-message=*|append,--reuse-message=*)
-               __gitcomp "$(__git_refs)" "" "${cur##--reuse-message=}"
-               ;;
+       add,--reuse-message=*|append,--reuse-message=*|\
        add,--reedit-message=*|append,--reedit-message=*)
-               __gitcomp "$(__git_refs)" "" "${cur##--reedit-message=}"
+               __gitcomp "$(__git_refs)" "" "${cur#*=}"
                ;;
        add,--*|append,--*)
                __gitcomp '--file= --message= --reedit-message=
@@@ -1702,6 -1754,8 +1695,6 @@@ _git_pull (
  {
        __git_complete_strategy && return
  
 -      local cur
 -      _get_comp_words_by_ref -n =: cur
        case "$cur" in
        --*)
                __gitcomp "
  
  _git_push ()
  {
 -      local cur prev
 -      _get_comp_words_by_ref -n =: cur prev
        case "$prev" in
        --repo)
                __gitcomp "$(__git_remotes)"
        --*)
                __gitcomp "
                        --all --mirror --tags --dry-run --force --verbose
 -                      --receive-pack= --repo=
 +                      --receive-pack= --repo= --set-upstream
                "
                return
                ;;
  _git_rebase ()
  {
        local dir="$(__gitdir)"
 -      local cur
 -      _get_comp_words_by_ref -n =: cur
        if [ -d "$dir"/rebase-apply ] || [ -d "$dir"/rebase-merge ]; then
                __gitcomp "--continue --skip --abort"
                return
@@@ -1782,6 -1840,8 +1775,6 @@@ __git_send_email_suppresscc_options="au
  
  _git_send_email ()
  {
 -      local cur
 -      _get_comp_words_by_ref -n =: cur
        case "$cur" in
        --confirm=*)
                __gitcomp "
@@@ -1823,6 -1883,8 +1816,6 @@@ _git_stage (
  
  __git_config_get_set_variables ()
  {
 -      local words cword
 -      _get_comp_words_by_ref -n =: words cword
        local prevword word config_file= c=$cword
        while [ $c -gt 1 ]; do
                word="${words[c]}"
  
  _git_config ()
  {
 -      local cur prev
 -      _get_comp_words_by_ref -n =: cur prev
        case "$prev" in
        branch.*.remote)
                __gitcomp "$(__git_remotes)"
                return
                ;;
        branch.*.*)
 -              local pfx="${cur%.*}."
 -              cur="${cur##*.}"
 -              __gitcomp "remote merge mergeoptions rebase" "$pfx" "$cur"
 +              local pfx="${cur%.*}." cur_="${cur##*.}"
 +              __gitcomp "remote merge mergeoptions rebase" "$pfx" "$cur_"
                return
                ;;
        branch.*)
 -              local pfx="${cur%.*}."
 -              cur="${cur#*.}"
 -              __gitcomp "$(__git_heads)" "$pfx" "$cur" "."
 +              local pfx="${cur%.*}." cur_="${cur#*.}"
 +              __gitcomp "$(__git_heads)" "$pfx" "$cur_" "."
                return
                ;;
        guitool.*.*)
 -              local pfx="${cur%.*}."
 -              cur="${cur##*.}"
 +              local pfx="${cur%.*}." cur_="${cur##*.}"
                __gitcomp "
                        argprompt cmd confirm needsfile noconsole norescan
                        prompt revprompt revunmerged title
 -                      " "$pfx" "$cur"
 +                      " "$pfx" "$cur_"
                return
                ;;
        difftool.*.*)
 -              local pfx="${cur%.*}."
 -              cur="${cur##*.}"
 -              __gitcomp "cmd path" "$pfx" "$cur"
 +              local pfx="${cur%.*}." cur_="${cur##*.}"
 +              __gitcomp "cmd path" "$pfx" "$cur_"
                return
                ;;
        man.*.*)
 -              local pfx="${cur%.*}."
 -              cur="${cur##*.}"
 -              __gitcomp "cmd path" "$pfx" "$cur"
 +              local pfx="${cur%.*}." cur_="${cur##*.}"
 +              __gitcomp "cmd path" "$pfx" "$cur_"
                return
                ;;
        mergetool.*.*)
 -              local pfx="${cur%.*}."
 -              cur="${cur##*.}"
 -              __gitcomp "cmd path trustExitCode" "$pfx" "$cur"
 +              local pfx="${cur%.*}." cur_="${cur##*.}"
 +              __gitcomp "cmd path trustExitCode" "$pfx" "$cur_"
                return
                ;;
        pager.*)
 -              local pfx="${cur%.*}."
 -              cur="${cur#*.}"
 +              local pfx="${cur%.*}." cur_="${cur#*.}"
                __git_compute_all_commands
 -              __gitcomp "$__git_all_commands" "$pfx" "$cur"
 +              __gitcomp "$__git_all_commands" "$pfx" "$cur_"
                return
                ;;
        remote.*.*)
 -              local pfx="${cur%.*}."
 -              cur="${cur##*.}"
 +              local pfx="${cur%.*}." cur_="${cur##*.}"
                __gitcomp "
                        url proxy fetch push mirror skipDefaultUpdate
                        receivepack uploadpack tagopt pushurl
 -                      " "$pfx" "$cur"
 +                      " "$pfx" "$cur_"
                return
                ;;
        remote.*)
 -              local pfx="${cur%.*}."
 -              cur="${cur#*.}"
 -              __gitcomp "$(__git_remotes)" "$pfx" "$cur" "."
 +              local pfx="${cur%.*}." cur_="${cur#*.}"
 +              __gitcomp "$(__git_remotes)" "$pfx" "$cur_" "."
                return
                ;;
        url.*.*)
 -              local pfx="${cur%.*}."
 -              cur="${cur##*.}"
 -              __gitcomp "insteadOf pushInsteadOf" "$pfx" "$cur"
 +              local pfx="${cur%.*}." cur_="${cur##*.}"
 +              __gitcomp "insteadOf pushInsteadOf" "$pfx" "$cur_"
                return
                ;;
        esac
                color.ui
                commit.status
                commit.template
 -              core.abbrevguard
 +              core.abbrev
                core.askpass
                core.attributesfile
                core.autocrlf
@@@ -2312,6 -2386,8 +2305,6 @@@ _git_reset (
  {
        __git_has_doubledash && return
  
 -      local cur
 -      _get_comp_words_by_ref -n =: cur
        case "$cur" in
        --*)
                __gitcomp "--merge --mixed --hard --soft --patch"
  
  _git_revert ()
  {
 -      local cur
 -      _get_comp_words_by_ref -n =: cur
        case "$cur" in
        --*)
                __gitcomp "--edit --mainline --no-edit --no-commit --signoff"
@@@ -2336,6 -2414,8 +2329,6 @@@ _git_rm (
  {
        __git_has_doubledash && return
  
 -      local cur
 -      _get_comp_words_by_ref -n =: cur
        case "$cur" in
        --*)
                __gitcomp "--cached --dry-run --ignore-unmatch --quiet"
@@@ -2349,6 -2429,8 +2342,6 @@@ _git_shortlog (
  {
        __git_has_doubledash && return
  
 -      local cur
 -      _get_comp_words_by_ref -n =: cur
        case "$cur" in
        --*)
                __gitcomp "
@@@ -2366,15 -2448,12 +2359,10 @@@ _git_show (
  {
        __git_has_doubledash && return
  
 -      local cur
 -      _get_comp_words_by_ref -n =: cur
        case "$cur" in
-       --pretty=*)
-               __gitcomp "$__git_log_pretty_formats $(__git_pretty_aliases)
-                       " "" "${cur##--pretty=}"
-               return
-               ;;
-       --format=*)
+       --pretty=*|--format=*)
                __gitcomp "$__git_log_pretty_formats $(__git_pretty_aliases)
-                       " "" "${cur##--format=}"
+                       " "" "${cur#*=}"
                return
                ;;
        --*)
  
  _git_show_branch ()
  {
 -      local cur
 -      _get_comp_words_by_ref -n =: cur
        case "$cur" in
        --*)
                __gitcomp "
  
  _git_stash ()
  {
 -      local cur
 -      _get_comp_words_by_ref -n =: cur
        local save_opts='--keep-index --no-keep-index --quiet --patch'
        local subcommands='save list show apply clear drop pop create branch'
        local subcommand="$(__git_find_on_cmdline "$subcommands")"
@@@ -2449,6 -2532,8 +2437,6 @@@ _git_submodule (
  
        local subcommands="add status init update summary foreach sync"
        if [ -z "$(__git_find_on_cmdline "$subcommands")" ]; then
 -              local cur
 -              _get_comp_words_by_ref -n =: cur
                case "$cur" in
                --*)
                        __gitcomp "--quiet --cached"
@@@ -2492,6 -2577,8 +2480,6 @@@ _git_svn (
                        --edit --rmdir --find-copies-harder --copy-similarity=
                        "
  
 -              local cur
 -              _get_comp_words_by_ref -n =: cur
                case "$subcommand,$cur" in
                fetch,--*)
                        __gitcomp "--revision= --fetch-all $fc_opts"
  _git_tag ()
  {
        local i c=1 f=0
 -      local words cword prev
 -      _get_comp_words_by_ref -n =: words cword prev
        while [ $c -lt $cword ]; do
                i="${words[c]}"
                case "$i" in
@@@ -2606,14 -2695,10 +2594,14 @@@ _git (
        if [[ -n ${ZSH_VERSION-} ]]; then
                emulate -L bash
                setopt KSH_TYPESET
 +
 +              # workaround zsh's bug that leaves 'words' as a special
 +              # variable in versions < 4.3.12
 +              typeset -h words
        fi
  
 -      local cur words cword
 -      _get_comp_words_by_ref -n =: cur words cword
 +      local cur words cword prev
 +      _get_comp_words_by_ref -n =: cur words cword prev
        while [ $c -lt $cword ]; do
                i="${words[c]}"
                case "$i" in
                        --exec-path
                        --html-path
                        --work-tree=
 +                      --namespace=
                        --help
                        "
                        ;;
@@@ -2662,22 -2746,17 +2650,22 @@@ _gitk (
        if [[ -n ${ZSH_VERSION-} ]]; then
                emulate -L bash
                setopt KSH_TYPESET
 +
 +              # workaround zsh's bug that leaves 'words' as a special
 +              # variable in versions < 4.3.12
 +              typeset -h words
        fi
  
 +      local cur words cword prev
 +      _get_comp_words_by_ref -n =: cur words cword prev
 +
        __git_has_doubledash && return
  
 -      local cur
        local g="$(__gitdir)"
        local merge=""
        if [ -f "$g/MERGE_HEAD" ]; then
                merge="--merge"
        fi
 -      _get_comp_words_by_ref -n =: cur
        case "$cur" in
        --*)
                __gitcomp "
@@@ -2706,7 -2785,7 +2694,7 @@@ complete -o bashdefault -o default -o n
  fi
  
  if [[ -n ${ZSH_VERSION-} ]]; then
 -      shopt () {
 +      __git_shopt () {
                local option
                if [ $# -ne 2 ]; then
                        echo "USAGE: $0 (-q|-s|-u) <option>" >&2
                        return 1
                esac
        }
 +else
 +      __git_shopt () {
 +              shopt "$@"
 +      }
  fi