Skip to content

Commit

Permalink
Merge branch 'jk/complete-checkout-sans-dwim-remote'
Browse files Browse the repository at this point in the history
Completion for "git checkout <branch>" 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
  • Loading branch information
gitster committed May 1, 2017
2 parents 027a3b9 + 60e71bb commit b439747
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion contrib/completion/git-completion.bash
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +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 ;;
Expand Down Expand Up @@ -1249,7 +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
Expand Down

0 comments on commit b439747

Please sign in to comment.