From: Junio C Hamano Date: Mon, 1 May 2017 05:14:41 +0000 (+0900) Subject: Merge branch 'jk/complete-checkout-sans-dwim-remote' X-Git-Tag: v2.13.0-rc2~13 X-Git-Url: https://git.lorimer.id.au/gitweb.git/diff_plain/b439747bc1074f6f325987d6f2b1a38119d3b863?hp=-c Merge branch 'jk/complete-checkout-sans-dwim-remote' Completion for "git checkout " that auto-creates the branch out of a remote tracking branch can now be disabled, as this completion often gets in the way when completing to checkout an existing local branch that happens to share the same prefix with bunch of remote tracking branches. * jk/complete-checkout-sans-dwim-remote: completion: optionally disable checkout DWIM --- b439747bc1074f6f325987d6f2b1a38119d3b863 diff --combined contrib/completion/git-completion.bash index b617019075,f977b54d8d..af658995d5 --- a/contrib/completion/git-completion.bash +++ b/contrib/completion/git-completion.bash @@@ -28,6 -28,14 +28,14 @@@ # 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 ; ... '". + # + # You can set the following environment variables to influence the behavior of + # the completion routines: + # + # GIT_COMPLETION_CHECKOUT_NO_GUESS + # + # When set to "1", do not include "DWIM" suggestions in git-checkout + # completion (e.g., completing "foo" when "origin/foo" exists). case "$COMP_WORDBREAKS" in *:*) : great ;; @@@ -709,7 -717,6 +717,7 @@@ __git_complete_remote_or_refspec ( i="${words[c]}" case "$i" in --mirror) [ "$cmd" = "push" ] && no_complete_refspec=1 ;; + -d|--delete) [ "$cmd" = "push" ] && lhs=0 ;; --all) case "$cmd" in push) no_complete_refspec=1 ;; @@@ -1249,7 -1256,8 +1257,8 @@@ _git_checkout ( # check if --track, --no-track, or --no-guess was specified # if so, disable DWIM mode local flags="--track --no-track --no-guess" track_opt="--track" - if [ -n "$(__git_find_on_cmdline "$flags")" ]; then + if [ "$GIT_COMPLETION_CHECKOUT_NO_GUESS" = "1" ] || + [ -n "$(__git_find_on_cmdline "$flags")" ]; then track_opt='' fi __git_complete_refs $track_opt