From 97ed685701a6df0273f7d29fd5bc0a0658a63cad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nguy=E1=BB=85n=20Th=C3=A1i=20Ng=E1=BB=8Dc=20Duy?= Date: Thu, 20 Jun 2019 16:55:22 +0700 Subject: completion: disable dwim on "git switch -d" MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Signed-off-by: Junio C Hamano diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash index 58d18d4..656e497 100644 --- a/contrib/completion/git-completion.bash +++ b/contrib/completion/git-completion.bash @@ -2183,6 +2183,10 @@ _git_switch () fi if [ -z "$(__git_find_on_cmdline "-d --detach")" ]; then only_local_ref=y + else + # --guess --detach is invalid combination, no + # dwim will be done when --detach is specified + track_opt= fi if [ $only_local_ref = y -a -z "$track_opt" ]; then __gitcomp_direct "$(__git_heads "" "$cur" " ")" -- cgit v0.10.2-6-g49f6