Skip to content

Commit 97ed685

Browse files
pcloudsgitster
authored andcommitted
completion: disable dwim on "git switch -d"
Even though dwim is enabled by default, it will never be done when --detached is specified. If you force "-d --guess" you will get an error because --guess then implies -c which cannot be used with -d. So we can disable dwim in "switch -d". It makes the completion list in this case a bit shorter. Signed-off-by: Nguyễn Thái Ngọc Duy <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent d16dc42 commit 97ed685

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

contrib/completion/git-completion.bash

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2183,6 +2183,10 @@ _git_switch ()
21832183
fi
21842184
if [ -z "$(__git_find_on_cmdline "-d --detach")" ]; then
21852185
only_local_ref=y
2186+
else
2187+
# --guess --detach is invalid combination, no
2188+
# dwim will be done when --detach is specified
2189+
track_opt=
21862190
fi
21872191
if [ $only_local_ref = y -a -z "$track_opt" ]; then
21882192
__gitcomp_direct "$(__git_heads "" "$cur" " ")"

0 commit comments

Comments
 (0)