Merge branch 'nd/completion-no-cache-failure' into maint
authorJunio C Hamano <gitster@pobox.com>
Mon, 29 Jul 2019 19:38:20 +0000 (12:38 -0700)
committerJunio C Hamano <gitster@pobox.com>
Mon, 29 Jul 2019 19:38:20 +0000 (12:38 -0700)
An incorrect list of options was cached after command line
completion failed (e.g. trying to complete a command that requires
a repository outside one), which has been corrected.

* nd/completion-no-cache-failure:
completion: do not cache if --git-completion-helper fails

1  2 
contrib/completion/git-completion.bash
index 9f71bcde967bc50915b90eaef72061f8c6a56315,00cc695e3d748cc27b106ef96b6f579886277954..8c6b610a2447cd1ec7c2dff0f9dbd09f6a024f57
@@@ -400,7 -400,8 +400,8 @@@ __gitcomp_builtin (
        if [ -z "$options" ]; then
                # leading and trailing spaces are significant to make
                # option removal work correctly.
-               options=" $incl $(__git ${cmd/_/ } --git-completion-helper) "
+               options=" $incl $(__git ${cmd/_/ } --git-completion-helper) " || return
                for i in $excl; do
                        options="${options/ $i / }"
                done
@@@ -853,11 -854,6 +854,11 @@@ __git_compute_merge_strategies (
        __git_merge_strategies=$(__git_list_merge_strategies)
  }
  
 +__git_merge_strategy_options="ours theirs subtree subtree= patience
 +      histogram diff-algorithm= ignore-space-change ignore-all-space
 +      ignore-space-at-eol renormalize no-renormalize no-renames
 +      find-renames find-renames= rename-threshold="
 +
  __git_complete_revlist_file ()
  {
        local dequoted_word pfx ls ref cur_="$cur"
@@@ -1001,21 -997,12 +1002,21 @@@ __git_complete_strategy (
        -s|--strategy)
                __gitcomp "$__git_merge_strategies"
                return 0
 +              ;;
 +      -X)
 +              __gitcomp "$__git_merge_strategy_options"
 +              return 0
 +              ;;
        esac
        case "$cur" in
        --strategy=*)
                __gitcomp "$__git_merge_strategies" "" "${cur##--strategy=}"
                return 0
                ;;
 +      --strategy-option=*)
 +              __gitcomp "$__git_merge_strategy_options" "" "${cur##--strategy-option=}"
 +              return 0
 +              ;;
        esac
        return 1
  }
@@@ -1024,7 -1011,7 +1025,7 @@@ __git_all_commands
  __git_compute_all_commands ()
  {
        test -n "$__git_all_commands" ||
 -      __git_all_commands=$(git --list-cmds=main,others,alias,nohelpers)
 +      __git_all_commands=$(__git --list-cmds=main,others,alias,nohelpers)
  }
  
  # Lists all set config variables starting with the given section prefix,
@@@ -1177,7 -1164,6 +1178,7 @@@ __git_count_arguments (
  }
  
  __git_whitespacelist="nowarn warn error error-all fix"
 +__git_patchformat="mbox stgit stgit-series hg mboxrd"
  __git_am_inprogress_options="--skip --continue --resolved --abort --quit --show-current-patch"
  
  _git_am ()
                __gitcomp "$__git_whitespacelist" "" "${cur##--whitespace=}"
                return
                ;;
 +      --patch-format=*)
 +              __gitcomp "$__git_patchformat" "" "${cur##--patch-format=}"
 +              return
 +              ;;
        --*)
                __gitcomp_builtin am "" \
                        "$__git_am_inprogress_options"
@@@ -1219,10 -1201,6 +1220,10 @@@ _git_apply (
  _git_add ()
  {
        case "$cur" in
 +      --chmod=*)
 +              __gitcomp "+x -x" "" "${cur##--chmod=}"
 +              return
 +              ;;
        --*)
                __gitcomp_builtin add
                return
@@@ -1283,8 -1261,6 +1284,8 @@@ _git_bisect (
        esac
  }
  
 +__git_ref_fieldlist="refname objecttype objectsize objectname upstream push HEAD symref"
 +
  _git_branch ()
  {
        local i c=1 only_local_ref="n" has_r="n"
@@@ -1368,9 -1344,6 +1369,9 @@@ _git_cherry_pick (
                __gitcomp "$__git_cherry_pick_inprogress_options"
                return
        fi
 +
 +      __git_complete_strategy && return
 +
        case "$cur" in
        --*)
                __gitcomp_builtin cherry-pick "" \
@@@ -1501,8 -1474,7 +1502,8 @@@ _git_diff (
  }
  
  __git_mergetools_common="diffuse diffmerge ecmerge emerge kdiff3 meld opendiff
 -                      tkdiff vimdiff gvimdiff xxdiff araxis p4merge bc codecompare
 +                      tkdiff vimdiff gvimdiff xxdiff araxis p4merge bc
 +                      codecompare smerge
  "
  
  _git_difftool ()
@@@ -1535,10 -1507,6 +1536,10 @@@ _git_fetch (
                __gitcomp "$__git_fetch_recurse_submodules" "" "${cur##--recurse-submodules=}"
                return
                ;;
 +      --filter=*)
 +              __gitcomp "blob:none blob:limit= sparse:oid=" "" "${cur##--filter=}"
 +              return
 +              ;;
        --*)
                __gitcomp_builtin fetch
                return
@@@ -1653,9 -1621,9 +1654,9 @@@ _git_help (
        esac
        if test -n "$GIT_TESTING_ALL_COMMAND_LIST"
        then
 -              __gitcomp "$GIT_TESTING_ALL_COMMAND_LIST $(git --list-cmds=alias,list-guide) gitk"
 +              __gitcomp "$GIT_TESTING_ALL_COMMAND_LIST $(__git --list-cmds=alias,list-guide) gitk"
        else
 -              __gitcomp "$(git --list-cmds=main,nohelpers,alias,list-guide) gitk"
 +              __gitcomp "$(__git --list-cmds=main,nohelpers,alias,list-guide) gitk"
        fi
  }
  
@@@ -1735,8 -1703,8 +1736,8 @@@ __git_log_shortlog_options=
        --all-match --invert-grep
  "
  
 -__git_log_pretty_formats="oneline short medium full fuller email raw format:"
 -__git_log_date_formats="relative iso8601 rfc2822 short local default raw"
 +__git_log_pretty_formats="oneline short medium full fuller email raw format: mboxrd"
 +__git_log_date_formats="relative iso8601 iso8601-strict rfc2822 short local default raw unix format:"
  
  _git_log ()
  {
@@@ -2254,7 -2222,7 +2255,7 @@@ _git_config (
                return
                ;;
        diff.submodule)
 -              __gitcomp "log short"
 +              __gitcomp "$__git_diff_submodule_formats"
                return
                ;;
        help.format)
@@@ -2421,10 -2389,6 +2422,10 @@@ _git_remote (
  _git_replace ()
  {
        case "$cur" in
 +      --format=*)
 +              __gitcomp "short medium long" "" "${cur##--format=}"
 +              return
 +              ;;
        --*)
                __gitcomp_builtin replace
                return
@@@ -2466,7 -2430,6 +2467,7 @@@ _git_revert (
                __gitcomp "$__git_revert_inprogress_options"
                return
        fi
 +      __git_complete_strategy && return
        case "$cur" in
        --*)
                __gitcomp_builtin revert "" \
@@@ -2611,7 -2574,7 +2612,7 @@@ _git_submodule (
  {
        __git_has_doubledash && return
  
 -      local subcommands="add status init deinit update summary foreach sync"
 +      local subcommands="add status init deinit update set-branch summary foreach sync absorbgitdirs"
        local subcommand="$(__git_find_on_cmdline "$subcommands")"
        if [ -z "$subcommand" ]; then
                case "$cur" in
                        --force --rebase --merge --reference --depth --recursive --jobs
                "
                ;;
 +      set-branch,--*)
 +              __gitcomp "--default --branch"
 +              ;;
        summary,--*)
                __gitcomp "--cached --files --summary-limit"
                ;;
@@@ -2929,7 -2889,7 +2930,7 @@@ __git_main (
                        then
                                __gitcomp "$GIT_TESTING_PORCELAIN_COMMAND_LIST"
                        else
 -                              __gitcomp "$(git --list-cmds=list-mainporcelain,others,nohelpers,alias,list-complete,config)"
 +                              __gitcomp "$(__git --list-cmds=list-mainporcelain,others,nohelpers,alias,list-complete,config)"
                        fi
                        ;;
                esac