Merge branch 'sp/complete-ext-alias'
authorJunio C Hamano <gitster@pobox.com>
Wed, 25 Jun 2014 19:23:27 +0000 (12:23 -0700)
committerJunio C Hamano <gitster@pobox.com>
Wed, 25 Jun 2014 19:23:27 +0000 (12:23 -0700)
* sp/complete-ext-alias:
completion: handle '!f() { ... }; f' and "!sh -c '...' -" aliases

1  2 
contrib/completion/git-completion.bash
index 019026efcbc5876d7aa3890eab5078a8bfbe2f7c,575f8f7a3fc08eeba1dde0b762ee105de05b031d..7a6e1d797a1ec95a17ad2a759acb85cbe25e9f10
  #        source ~/.git-completion.sh
  #    3) Consider changing your PS1 to also show the current branch,
  #       see git-prompt.sh for details.
+ #
+ # If you use complex aliases of form '!f() { ... }; f', you can use the null
+ # command ':' as the first command in the function body to declare the desired
+ # completion style.  For example '!f() { : git commit ; ... }; f' will
+ # tell the completion to use commit completion.  This also works with aliases
+ # of form "!sh -c '...'".  For example, "!sh -c ': git commit ; ... '".
  
  case "$COMP_WORDBREAKS" in
  *:*) : great ;;
@@@ -781,6 -787,10 +787,10 @@@ __git_aliased_command (
                -*)     : option ;;
                *=*)    : setting env ;;
                git)    : git itself ;;
+               \(\))   : skip parens of shell function definition ;;
+               {)      : skip start of shell helper function ;;
+               :)      : skip null command ;;
+               \'*)    : skip opening quote after sh -c ;;
                *)
                        echo "$word"
                        return
@@@ -1472,12 -1482,9 +1482,12 @@@ _git_log (
        __git_complete_revlist
  }
  
 +# Common merge options shared by git-merge(1) and git-pull(1).
  __git_merge_options="
        --no-commit --no-stat --log --no-log --squash --strategy
        --commit --stat --no-squash --ff --no-ff --ff-only --edit --no-edit
 +      --verify-signatures --no-verify-signatures --gpg-sign
 +      --quiet --verbose --progress --no-progress
  "
  
  _git_merge ()
  
        case "$cur" in
        --*)
 -              __gitcomp "$__git_merge_options"
 +              __gitcomp "$__git_merge_options
 +                      --rerere-autoupdate --no-rerere-autoupdate --abort"
                return
        esac
        __gitcomp_nl "$(__git_refs)"