Merge branch 'cp/completion-clone-recurse-submodules'
authorJunio C Hamano <gitster@pobox.com>
Mon, 8 Aug 2016 21:48:37 +0000 (14:48 -0700)
committerJunio C Hamano <gitster@pobox.com>
Mon, 8 Aug 2016 21:48:37 +0000 (14:48 -0700)
* cp/completion-clone-recurse-submodules:
completion: add option '--recurse-submodules' to 'git clone'

1  2 
contrib/completion/git-completion.bash
index 10f6d52254335edeb2253df5b9e63bb4d5608150,03ace767b4ea3393154ac6ef1c234b771cb7e428..6a187bc11bc9b8b141f70f81ae256c27921ff00d
@@@ -10,7 -10,6 +10,7 @@@
  #    *) local and remote tag names
  #    *) .git/remotes file names
  #    *) git 'subcommands'
 +#    *) git email aliases for git-send-email
  #    *) tree paths within 'ref:path/to/file' expressions
  #    *) file paths within current working directory and index
  #    *) common --long-options
@@@ -803,50 -802,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
@@@ -1136,14 -1091,13 +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
                ;;
        --*)
@@@ -1215,7 -1169,7 +1216,7 @@@ __git_diff_common_options="--stat --num
                        --no-prefix --src-prefix= --dst-prefix=
                        --inter-hunk-context=
                        --patience --histogram --minimal
 -                      --raw --word-diff
 +                      --raw --word-diff --word-diff-regex=
                        --dirstat --dirstat= --dirstat-by-file
                        --dirstat-by-file= --cumulative
                        --diff-algorithm=
@@@ -1358,7 -1312,6 +1359,7 @@@ _git_grep (
                        --full-name --line-number
                        --extended-regexp --basic-regexp --fixed-strings
                        --perl-regexp
 +                      --threads
                        --files-with-matches --name-only
                        --files-without-match
                        --max-depth
@@@ -1385,15 -1338,15 +1386,15 @@@ _git_help (
  {
        case "$cur" in
        --*)
 -              __gitcomp "--all --info --man --web"
 +              __gitcomp "--all --guides --info --man --web"
                return
                ;;
        esac
        __git_compute_all_commands
        __gitcomp "$__git_all_commands $(__git_aliases)
                attributes cli core-tutorial cvs-migration
 -              diffcore gitk glossary hooks ignore modules
 -              namespaces repository-layout tutorial tutorial-2
 +              diffcore everyday gitk glossary hooks ignore modules
 +              namespaces repository-layout revisions tutorial tutorial-2
                workflows
                "
  }
@@@ -1504,7 -1457,6 +1505,7 @@@ _git_log (
                        --relative-date --date=
                        --pretty= --format= --oneline
                        --show-signature
 +                      --cherry-mark
                        --cherry-pick
                        --graph
                        --decorate --decorate=
@@@ -1735,12 -1687,8 +1736,12 @@@ _git_rebase (
                        --preserve-merges --stat --no-stat
                        --committer-date-is-author-date --ignore-date
                        --ignore-whitespace --whitespace=
 -                      --autosquash --fork-point --no-fork-point
 -                      --autostash
 +                      --autosquash --no-autosquash
 +                      --fork-point --no-fork-point
 +                      --autostash --no-autostash
 +                      --verify --no-verify
 +                      --keep-empty --root --force-rebase --no-ff
 +                      --exec
                        "
  
                return
@@@ -1765,15 -1713,6 +1766,15 @@@ __git_send_email_suppresscc_options="au
  
  _git_send_email ()
  {
 +      case "$prev" in
 +      --to|--cc|--bcc|--from)
 +              __gitcomp "
 +              $(git --git-dir="$(__gitdir)" send-email --dump-aliases 2>/dev/null)
 +              "
 +              return
 +              ;;
 +      esac
 +
        case "$cur" in
        --confirm=*)
                __gitcomp "
                        " "" "${cur##--thread=}"
                return
                ;;
 +      --to=*|--cc=*|--bcc=*|--from=*)
 +              __gitcomp "
 +              $(git --git-dir="$(__gitdir)" send-email --dump-aliases 2>/dev/null)
 +              " "" "${cur#--*=}"
 +              return
 +              ;;
        --*)
                __gitcomp "--annotate --bcc --cc --cc-cmd --chain-reply-to
                        --compose --confirm= --dry-run --envelope-sender
@@@ -1826,56 -1759,6 +1827,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
@@@ -1910,7 -1793,7 +1911,7 @@@ _git_config (
                return
                ;;
        branch.*.rebase)
 -              __gitcomp "false true"
 +              __gitcomp "false true preserve interactive"
                return
                ;;
        remote.pushdefault)
                core.sparseCheckout
                core.symlinks
                core.trustctime
 +              core.untrackedCache
                core.warnAmbiguousRefs
                core.whitespace
                core.worktree
@@@ -2471,7 -2353,7 +2472,7 @@@ _git_show_branch (
        case "$cur" in
        --*)
                __gitcomp "
 -                      --all --remotes --topo-order --current --more=
 +                      --all --remotes --topo-order --date-order --current --more=
                        --list --independent --merge-base --no-name
                        --color --no-color
                        --sha1-name --sparse --topics --reflog
  
  _git_stash ()
  {
 -      local save_opts='--keep-index --no-keep-index --quiet --patch'
 +      local save_opts='--all --keep-index --no-keep-index --quiet --patch --include-untracked'
        local subcommands='save list show apply clear drop pop create branch'
        local subcommand="$(__git_find_on_cmdline "$subcommands")"
        if [ -z "$subcommand" ]; then
                apply,--*|pop,--*)
                        __gitcomp "--index --quiet"
                        ;;
 -              show,--*|drop,--*|branch,--*)
 +              drop,--*)
 +                      __gitcomp "--quiet"
                        ;;
 -              show,*|apply,*|drop,*|pop,*|branch,*)
 +              show,--*|branch,--*)
 +                      ;;
 +              branch,*)
 +                      if [ $cword -eq 3 ]; then
 +                              __gitcomp_nl "$(__git_refs)";
 +                      else
 +                              __gitcomp_nl "$(git --git-dir="$(__gitdir)" stash list \
 +                                              | sed -n -e 's/:.*//p')"
 +                      fi
 +                      ;;
 +              show,*|apply,*|drop,*|pop,*)
                        __gitcomp_nl "$(git --git-dir="$(__gitdir)" stash list \
                                        | sed -n -e 's/:.*//p')"
                        ;;
@@@ -2691,32 -2562,6 +2692,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