Code

Merge branch 'sp/maint-bash-completion-optim'
authorJunio C Hamano <gitster@pobox.com>
Tue, 15 Jul 2008 06:36:08 +0000 (23:36 -0700)
committerJunio C Hamano <gitster@pobox.com>
Tue, 15 Jul 2008 06:36:08 +0000 (23:36 -0700)
* sp/maint-bash-completion-optim:
  bash completion: Resolve git show ref:path<tab> losing ref: portion
  bash completion: Append space after file names have been completed

1  2 
contrib/completion/git-completion.bash

index d48dbf26728bba562a307d18cf9ea0c2e9c8fcae,72f02f208fad95128d7e2fd3b55fdddd23bf2460..37f52d5395daf5791917aa4c4a3b1dc45114b69a
  #       git@vger.kernel.org
  #
  
+ case "$COMP_WORDBREAKS" in
+ *:*) : great ;;
+ *)   COMP_WORDBREAKS="$COMP_WORDBREAKS:"
+ esac
  __gitdir ()
  {
        if [ -z "$1" ]; then
@@@ -294,9 -299,23 +299,23 @@@ __git_complete_file (
                        ls="$ref"
                        ;;
            esac
+               case "$COMP_WORDBREAKS" in
+               *:*) : great ;;
+               *)   pfx="$ref:$pfx" ;;
+               esac
+               local IFS=$'\n'
                COMPREPLY=($(compgen -P "$pfx" \
                        -W "$(git --git-dir="$(__gitdir)" ls-tree "$ls" \
-                               | sed '/^100... blob /s,^.*     ,,
+                               | sed '/^100... blob /{
+                                          s,^.*        ,,
+                                          s,$, ,
+                                      }
+                                      /^120000 blob /{
+                                          s,^.*        ,,
+                                          s,$, ,
+                                      }
                                       /^040000 tree /{
                                           s,^.*        ,,
                                           s,$,/,
@@@ -528,7 -547,7 +547,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)"
                ;;
        *)
@@@ -563,7 -582,7 +582,7 @@@ _git_branch (
        --*)
                __gitcomp "
                        --color --no-color --verbose --abbrev= --no-abbrev
 -                      --track --no-track
 +                      --track --no-track --contains --merged --no-merged
                        "
                ;;
        *)
@@@ -692,7 -711,12 +711,12 @@@ _git_fetch (
        *)
                case "$cur" in
                *:*)
-                       __gitcomp "$(__git_refs)" "" "${cur#*:}"
+                       local pfx=""
+                       case "$COMP_WORDBREAKS" in
+                       *:*) : great ;;
+                       *)   pfx="${cur%%:*}:" ;;
+                       esac
+                       __gitcomp "$(__git_refs)" "$pfx" "${cur#*:}"
                        ;;
                *)
                        local remote
@@@ -785,9 -809,6 +809,9 @@@ _git_log (
                        --not --all
                        --left-right --cherry-pick
                        --graph
 +                      --stat --numstat --shortstat
 +                      --decorate --diff-filter=
 +                      --color-words --walk-reflogs
                        "
                return
                ;;
@@@ -868,7 -889,14 +892,14 @@@ _git_push (
                        git-push)  remote="${COMP_WORDS[1]}" ;;
                        git)       remote="${COMP_WORDS[2]}" ;;
                        esac
-                       __gitcomp "$(__git_refs "$remote")" "" "${cur#*:}"
+                       local pfx=""
+                       case "$COMP_WORDBREAKS" in
+                       *:*) : great ;;
+                       *)   pfx="${cur%%:*}:" ;;
+                       esac
+                       __gitcomp "$(__git_refs "$remote")" "$pfx" "${cur#*:}"
                        ;;
                +*)
                        __gitcomp "$(__git_refs)" + "${cur#+}"
@@@ -905,24 -933,6 +936,24 @@@ _git_rebase (
        __gitcomp "$(__git_refs)"
  }
  
 +_git_send_email ()
 +{
 +      local cur="${COMP_WORDS[COMP_CWORD]}"
 +      case "$cur" in
 +      --*)
 +              __gitcomp "--bcc --cc --cc-cmd --chain-reply-to --compose
 +                      --dry-run --envelope-sender --from --identity
 +                      --in-reply-to --no-chain-reply-to --no-signed-off-by-cc
 +                      --no-suppress-from --no-thread --quiet
 +                      --signed-off-by-cc --smtp-pass --smtp-server
 +                      --smtp-server-port --smtp-ssl --smtp-user --subject
 +                      --suppress-cc --suppress-from --thread --to"
 +              return
 +              ;;
 +      esac
 +      COMPREPLY=()
 +}
 +
  _git_config ()
  {
        local cur="${COMP_WORDS[COMP_CWORD]}"
                pull.octopus
                pull.twohead
                repack.useDeltaBaseOffset
 -              show.difftree
                showbranch.default
                tar.umask
                transfer.unpackLimit
                user.name
                user.email
                user.signingkey
 -              whatchanged.difftree
                branch. remote.
        "
  }
@@@ -1182,19 -1194,8 +1213,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
  }
  
@@@ -1394,7 -1395,6 +1425,7 @@@ _git (
        rebase)      _git_rebase ;;
        remote)      _git_remote ;;
        reset)       _git_reset ;;
 +      send-email)  _git_send_email ;;
        shortlog)    _git_shortlog ;;
        show)        _git_show ;;
        show-branch) _git_log ;;
@@@ -1454,7 -1454,6 +1485,7 @@@ complete -o default -o nospace -F _git_
  complete -o default -o nospace -F _git_config git-config
  complete -o default -o nospace -F _git_remote git-remote
  complete -o default -o nospace -F _git_reset git-reset
 +complete -o default -o nospace -F _git_send_email git-send-email
  complete -o default -o nospace -F _git_shortlog git-shortlog
  complete -o default -o nospace -F _git_show git-show
  complete -o default -o nospace -F _git_stash git-stash