Merge branch 'sp/maint-bash-completion-optim'
authorJunio C Hamano <gitster@pobox.com>
Sun, 13 Jul 2008 23:41:02 +0000 (16:41 -0700)
committerJunio C Hamano <gitster@pobox.com>
Sun, 13 Jul 2008 23:41:02 +0000 (16:41 -0700)
* sp/maint-bash-completion-optim:
bash completion: Don't offer "a.." as a completion for "a."
bash completion: Improve responsiveness of git-log completion

1  2 
contrib/completion/git-completion.bash
index 84a256ec54875288ff0c92e4ce1cc45551667aeb,821c9a7f9f2b78f46c2f9ea87da72ff961c2cf9b..d268e6f0b3f90d50367bfcd8907d29fdb70a8cc5
@@@ -114,9 -114,20 +114,20 @@@ __git_ps1 (
        fi
  }
  
+ __gitcomp_1 ()
+ {
+       local c IFS=' '$'\t'$'\n'
+       for c in $1; do
+               case "$c$2" in
+               --*=*) printf %s$'\n' "$c$2" ;;
+               *.)    printf %s$'\n' "$c$2" ;;
+               *)     printf %s$'\n' "$c$2 " ;;
+               esac
+       done
+ }
  __gitcomp ()
  {
-       local all c s=$'\n' IFS=' '$'\t'$'\n'
        local cur="${COMP_WORDS[COMP_CWORD]}"
        if [ $# -gt 2 ]; then
                cur="$3"
        case "$cur" in
        --*=)
                COMPREPLY=()
-               return
                ;;
        *)
-               for c in $1; do
-                       case "$c$4" in
-                       --*=*) all="$all$c$4$s" ;;
-                       *.)    all="$all$c$4$s" ;;
-                       *)     all="$all$c$4 $s" ;;
-                       esac
-               done
+               local IFS=$'\n'
+               COMPREPLY=($(compgen -P "$2" \
+                       -W "$(__gitcomp_1 "$1" "$4")" \
+                       -- "$cur"))
                ;;
        esac
-       IFS=$s
-       COMPREPLY=($(compgen -P "$2" -W "$all" -- "$cur"))
-       return
  }
  
  __git_heads ()
@@@ -320,9 -324,6 +324,6 @@@ __git_complete_revlist (
                cur="${cur#*..}"
                __gitcomp "$(__git_refs)" "$pfx" "$cur"
                ;;
-       *.)
-               __gitcomp "$cur."
-               ;;
        *)
                __gitcomp "$(__git_refs)"
                ;;
@@@ -527,7 -528,7 +528,7 @@@ _git_bisect (
  {
        __git_has_doubledash && return
  
 -      local subcommands="start bad good reset visualize replay log"
 +      local subcommands="start bad good skip reset visualize replay log run"
        local subcommand="$(__git_find_subcommand "$subcommands")"
        if [ -z "$subcommand" ]; then
                __gitcomp "$subcommands"
        fi
  
        case "$subcommand" in
 -      bad|good|reset)
 +      bad|good|reset|skip)
                __gitcomp "$(__git_refs)"
                ;;
        *)
@@@ -562,7 -563,7 +563,7 @@@ _git_branch (
        --*)
                __gitcomp "
                        --color --no-color --verbose --abbrev= --no-abbrev
 -                      --track --no-track
 +                      --track --no-track --contains --merged --no-merged
                        "
                ;;
        *)
@@@ -784,9 -785,6 +785,9 @@@ _git_log (
                        --not --all
                        --left-right --cherry-pick
                        --graph
 +                      --stat --numstat --shortstat
 +                      --decorate --diff-filter=
 +                      --color-words --walk-reflogs
                        "
                return
                ;;
@@@ -1063,6 -1061,7 +1064,6 @@@ _git_config (
                pull.octopus
                pull.twohead
                repack.useDeltaBaseOffset
 -              show.difftree
                showbranch.default
                tar.umask
                transfer.unpackLimit
                user.name
                user.email
                user.signingkey
 -              whatchanged.difftree
                branch. remote.
        "
  }
@@@ -1163,19 -1163,8 +1164,19 @@@ _git_show (
  _git_stash ()
  {
        local subcommands='save list show apply clear drop pop create'
 -      if [ -z "$(__git_find_subcommand "$subcommands")" ]; then
 +      local subcommand="$(__git_find_subcommand "$subcommands")"
 +      if [ -z "$subcommand" ]; then
                __gitcomp "$subcommands"
 +      else
 +              local cur="${COMP_WORDS[COMP_CWORD]}"
 +              case "$subcommand,$cur" in
 +              save,--*)
 +                      __gitcomp "--keep-index"
 +                      ;;
 +              *)
 +                      COMPREPLY=()
 +                      ;;
 +              esac
        fi
  }