Skip to content

Commit b439747

Browse files
committed
Merge branch 'jk/complete-checkout-sans-dwim-remote'
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
2 parents 027a3b9 + 60e71bb commit b439747

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

contrib/completion/git-completion.bash

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,14 @@
2828
# completion style. For example '!f() { : git commit ; ... }; f' will
2929
# tell the completion to use commit completion. This also works with aliases
3030
# of form "!sh -c '...'". For example, "!sh -c ': git commit ; ... '".
31+
#
32+
# You can set the following environment variables to influence the behavior of
33+
# the completion routines:
34+
#
35+
# GIT_COMPLETION_CHECKOUT_NO_GUESS
36+
#
37+
# When set to "1", do not include "DWIM" suggestions in git-checkout
38+
# completion (e.g., completing "foo" when "origin/foo" exists).
3139

3240
case "$COMP_WORDBREAKS" in
3341
*:*) : great ;;
@@ -1249,7 +1257,8 @@ _git_checkout ()
12491257
# check if --track, --no-track, or --no-guess was specified
12501258
# if so, disable DWIM mode
12511259
local flags="--track --no-track --no-guess" track_opt="--track"
1252-
if [ -n "$(__git_find_on_cmdline "$flags")" ]; then
1260+
if [ "$GIT_COMPLETION_CHECKOUT_NO_GUESS" = "1" ] ||
1261+
[ -n "$(__git_find_on_cmdline "$flags")" ]; then
12531262
track_opt=''
12541263
fi
12551264
__git_complete_refs $track_opt

0 commit comments

Comments
 (0)