Merge branch 'fg/completion-external'
authorJunio C Hamano <gitster@pobox.com>
Wed, 23 May 2018 05:38:25 +0000 (14:38 +0900)
committerJunio C Hamano <gitster@pobox.com>
Wed, 23 May 2018 05:38:25 +0000 (14:38 +0900)
The command line completion mechanism (in contrib/) learned to load
custom completion file for "git $command" where $command is a
custom "git-$command" that the end user has on the $PATH when using
newer version of bash.

* fg/completion-external:
completion: load completion file for external subcommand

1  2 
contrib/completion/git-completion.bash
index f2f331120bd2c132f90dcf314a9c5065781659b7,604ba2b039a240ea868fdb2e4667055e607ad181..961a0ed76f89133dc01fc86a07be37eb5728651a
@@@ -3045,45 -3036,6 +3045,52 @@@ _git_worktree (
        fi
  }
  
-       if declare -f $completion_func >/dev/null 2>/dev/null; then
 +__git_complete_common () {
 +      local command="$1"
 +
 +      case "$cur" in
 +      --*)
 +              __gitcomp_builtin "$command"
 +              ;;
 +      esac
 +}
 +
 +__git_cmds_with_parseopt_helper=
 +__git_support_parseopt_helper () {
 +      test -n "$__git_cmds_with_parseopt_helper" ||
 +              __git_cmds_with_parseopt_helper="$(__git --list-parseopt-builtins)"
 +
 +      case " $__git_cmds_with_parseopt_helper " in
 +      *" $1 "*)
 +              return 0
 +              ;;
 +      *)
 +              return 1
 +              ;;
 +      esac
 +}
 +
 +__git_complete_command () {
 +      local command="$1"
 +      local completion_func="_git_${command//-/_}"
-       elif __git_support_parseopt_helper "$command"; then
++      if ! declare -f $completion_func >/dev/null 2>/dev/null &&
++              declare -f _completion_loader >/dev/null 2>/dev/null
++      then
++              _completion_loader "git-$command"
++      fi
++      if declare -f $completion_func >/dev/null 2>/dev/null
++      then
 +              $completion_func
 +              return 0
++      elif __git_support_parseopt_helper "$command"
++      then
 +              __git_complete_common "$command"
 +              return 0
 +      else
 +              return 1
 +      fi
 +}
 +
  __git_main ()
  {
        local i c=1 command __git_dir __git_repo_path