Merge branch 'vs/completion-branch-fully-spelled-d-m-r'
authorJunio C Hamano <gitster@pobox.com>
Fri, 12 Aug 2016 16:47:35 +0000 (09:47 -0700)
committerJunio C Hamano <gitster@pobox.com>
Fri, 12 Aug 2016 16:47:35 +0000 (09:47 -0700)
* vs/completion-branch-fully-spelled-d-m-r:
completion: complete --delete, --move, and --remotes for git branch

1  2 
contrib/completion/git-completion.bash
index c1b2135544bba888ccdeadf3075d86b76571f688,ce14c6f8da77f958b7ba942dd77ce825176635d2..9c8f7380d0f1ad76f0163209e5005adfe46ec916
@@@ -803,50 -803,6 +803,50 @@@ __git_find_on_cmdline (
        done
  }
  
 +# Echo the value of an option set on the command line or config
 +#
 +# $1: short option name
 +# $2: long option name including =
 +# $3: list of possible values
 +# $4: config string (optional)
 +#
 +# example:
 +# result="$(__git_get_option_value "-d" "--do-something=" \
 +#     "yes no" "core.doSomething")"
 +#
 +# result is then either empty (no option set) or "yes" or "no"
 +#
 +# __git_get_option_value requires 3 arguments
 +__git_get_option_value ()
 +{
 +      local c short_opt long_opt val
 +      local result= values config_key word
 +
 +      short_opt="$1"
 +      long_opt="$2"
 +      values="$3"
 +      config_key="$4"
 +
 +      ((c = $cword - 1))
 +      while [ $c -ge 0 ]; do
 +              word="${words[c]}"
 +              for val in $values; do
 +                      if [ "$short_opt$val" = "$word" ] ||
 +                         [ "$long_opt$val"  = "$word" ]; then
 +                              result="$val"
 +                              break 2
 +                      fi
 +              done
 +              ((c--))
 +      done
 +
 +      if [ -n "$config_key" ] && [ -z "$result" ]; then
 +              result="$(git --git-dir="$(__gitdir)" config "$config_key")"
 +      fi
 +
 +      echo "$result"
 +}
 +
  __git_has_doubledash ()
  {
        local c=1
@@@ -1008,8 -964,8 +1008,8 @@@ _git_branch (
        while [ $c -lt $cword ]; do
                i="${words[c]}"
                case "$i" in
-               -d|-m)  only_local_ref="y" ;;
-               -r)     has_r="y" ;;
+               -d|--delete|-m|--move)  only_local_ref="y" ;;
+               -r|--remotes)           has_r="y" ;;
                esac
                ((c++))
        done
                        --color --no-color --verbose --abbrev= --no-abbrev
                        --track --no-track --contains --merged --no-merged
                        --set-upstream-to= --edit-description --list
-                       --unset-upstream
+                       --unset-upstream --delete --move --remotes
                        "
                ;;
        *)
@@@ -1136,15 -1092,12 +1136,15 @@@ _git_clone (
                        --depth
                        --single-branch
                        --branch
 +                      --recurse-submodules
                        "
                return
                ;;
        esac
  }
  
 +__git_untracked_file_modes="all no normal"
 +
  _git_commit ()
  {
        case "$prev" in
                return
                ;;
        --untracked-files=*)
 -              __gitcomp "all no normal" "" "${cur##--untracked-files=}"
 +              __gitcomp "$__git_untracked_file_modes" "" "${cur##--untracked-files=}"
                return
                ;;
        --*)
@@@ -1205,8 -1158,6 +1205,8 @@@ _git_describe (
  
  __git_diff_algorithms="myers minimal patience histogram"
  
 +__git_diff_submodule_formats="log short"
 +
  __git_diff_common_options="--stat --numstat --shortstat --summary
                        --patch-with-stat --name-only --name-status --color
                        --no-color --color-words --no-renames --check
                        --dirstat --dirstat= --dirstat-by-file
                        --dirstat-by-file= --cumulative
                        --diff-algorithm=
 +                      --submodule --submodule=
  "
  
  _git_diff ()
                __gitcomp "$__git_diff_algorithms" "" "${cur##--diff-algorithm=}"
                return
                ;;
 +      --submodule=*)
 +              __gitcomp "$__git_diff_submodule_formats" "" "${cur##--submodule=}"
 +              return
 +              ;;
        --*)
                __gitcomp "--cached --staged --pickaxe-all --pickaxe-regex
                        --base --ours --theirs --no-index
@@@ -1501,14 -1447,6 +1501,14 @@@ _git_log (
                __gitcomp "full short no" "" "${cur##--decorate=}"
                return
                ;;
 +      --diff-algorithm=*)
 +              __gitcomp "$__git_diff_algorithms" "" "${cur##--diff-algorithm=}"
 +              return
 +              ;;
 +      --submodule=*)
 +              __gitcomp "$__git_diff_submodule_formats" "" "${cur##--submodule=}"
 +              return
 +              ;;
        --*)
                __gitcomp "
                        $__git_log_common_options
@@@ -1842,56 -1780,6 +1842,56 @@@ _git_stage (
        _git_add
  }
  
 +_git_status ()
 +{
 +      local complete_opt
 +      local untracked_state
 +
 +      case "$cur" in
 +      --ignore-submodules=*)
 +              __gitcomp "none untracked dirty all" "" "${cur##--ignore-submodules=}"
 +              return
 +              ;;
 +      --untracked-files=*)
 +              __gitcomp "$__git_untracked_file_modes" "" "${cur##--untracked-files=}"
 +              return
 +              ;;
 +      --column=*)
 +              __gitcomp "
 +                      always never auto column row plain dense nodense
 +                      " "" "${cur##--column=}"
 +              return
 +              ;;
 +      --*)
 +              __gitcomp "
 +                      --short --branch --porcelain --long --verbose
 +                      --untracked-files= --ignore-submodules= --ignored
 +                      --column= --no-column
 +                      "
 +              return
 +              ;;
 +      esac
 +
 +      untracked_state="$(__git_get_option_value "-u" "--untracked-files=" \
 +              "$__git_untracked_file_modes" "status.showUntrackedFiles")"
 +
 +      case "$untracked_state" in
 +      no)
 +              # --ignored option does not matter
 +              complete_opt=
 +              ;;
 +      all|normal|*)
 +              complete_opt="--cached --directory --no-empty-directory --others"
 +
 +              if [ -n "$(__git_find_on_cmdline "--ignored")" ]; then
 +                      complete_opt="$complete_opt --ignored --exclude=*"
 +              fi
 +              ;;
 +      esac
 +
 +      __git_complete_index_file "$complete_opt"
 +}
 +
  __git_config_get_set_variables ()
  {
        local prevword word config_file= c=$cword
@@@ -2197,7 -2085,6 +2197,7 @@@ _git_config (
                format.attach
                format.cc
                format.coverLetter
 +              format.from
                format.headers
                format.numbered
                format.pretty
@@@ -2472,10 -2359,6 +2472,10 @@@ _git_show (
                __gitcomp "$__git_diff_algorithms" "" "${cur##--diff-algorithm=}"
                return
                ;;
 +      --submodule=*)
 +              __gitcomp "$__git_diff_submodule_formats" "" "${cur##--submodule=}"
 +              return
 +              ;;
        --*)
                __gitcomp "--pretty= --format= --abbrev-commit --oneline
                        --show-signature
@@@ -2712,32 -2595,6 +2712,32 @@@ _git_whatchanged (
        _git_log
  }
  
 +_git_worktree ()
 +{
 +      local subcommands="add list lock prune unlock"
 +      local subcommand="$(__git_find_on_cmdline "$subcommands")"
 +      if [ -z "$subcommand" ]; then
 +              __gitcomp "$subcommands"
 +      else
 +              case "$subcommand,$cur" in
 +              add,--*)
 +                      __gitcomp "--detach"
 +                      ;;
 +              list,--*)
 +                      __gitcomp "--porcelain"
 +                      ;;
 +              lock,--*)
 +                      __gitcomp "--reason"
 +                      ;;
 +              prune,--*)
 +                      __gitcomp "--dry-run --expire --verbose"
 +                      ;;
 +              *)
 +                      ;;
 +              esac
 +      fi
 +}
 +
  __git_main ()
  {
        local i c=1 command __git_dir