summaryrefslogtreecommitdiff
path: root/contrib/completion
diff options
context:
space:
mode:
authorDenton Liu <liu.denton@gmail.com>2020-10-08 05:48:15 (GMT)
committerJunio C Hamano <gitster@pobox.com>2020-10-08 16:25:29 (GMT)
commit64f1f58fe7c0837bd0ae56ba83add5e1b84c54d3 (patch)
tree9ec6d813813db2e42f52855b96b0fb5abbe72a40 /contrib/completion
parentef09e7ddf3e77960ea24ea1580439fb725b4063a (diff)
downloadgit-64f1f58fe7c0837bd0ae56ba83add5e1b84c54d3.zip
git-64f1f58fe7c0837bd0ae56ba83add5e1b84c54d3.tar.gz
git-64f1f58fe7c0837bd0ae56ba83add5e1b84c54d3.tar.bz2
checkout: learn to respect checkout.guess
The current behavior of git checkout/switch is that --guess is currently enabled by default. However, some users may not wish for this to happen automatically. Instead of forcing users to specify --no-guess manually each time, teach these commands the checkout.guess configuration variable that gives users the option to set a default behavior. Teach the completion script to recognize the new config variable and disable DWIM logic if it is set to false. Signed-off-by: Denton Liu <liu.denton@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'contrib/completion')
-rw-r--r--contrib/completion/git-completion.bash25
1 files changed, 16 insertions, 9 deletions
diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash
index 0a96ad8..5f09dd9 100644
--- a/contrib/completion/git-completion.bash
+++ b/contrib/completion/git-completion.bash
@@ -1467,14 +1467,15 @@ _git_bundle ()
# Helper function to decide whether or not we should enable DWIM logic for
# git-switch and git-checkout.
#
-# To decide between the following rules in priority order
-# 1) the last provided of "--guess" or "--no-guess" explicitly enable or
-# disable completion of DWIM logic respectively.
-# 2) If the --no-track option is provided, take this as a hint to disable the
-# DWIM completion logic
-# 3) If GIT_COMPLETION_CHECKOUT_NO_GUESS is set, disable the DWIM completion
-# logic, as requested by the user.
-# 4) Enable DWIM logic otherwise.
+# To decide between the following rules in decreasing priority order:
+# - the last provided of "--guess" or "--no-guess" explicitly enable or
+# disable completion of DWIM logic respectively.
+# - If checkout.guess is false, disable completion of DWIM logic.
+# - If the --no-track option is provided, take this as a hint to disable the
+# DWIM completion logic
+# - If GIT_COMPLETION_CHECKOUT_NO_GUESS is set, disable the DWIM completion
+# logic, as requested by the user.
+# - Enable DWIM logic otherwise.
#
__git_checkout_default_dwim_mode ()
{
@@ -1485,11 +1486,17 @@ __git_checkout_default_dwim_mode ()
fi
# --no-track disables DWIM, but with lower priority than
- # --guess/--no-guess
+ # --guess/--no-guess/checkout.guess
if [ -n "$(__git_find_on_cmdline "--no-track")" ]; then
dwim_opt=""
fi
+ # checkout.guess = false disables DWIM, but with lower priority than
+ # --guess/--no-guess
+ if [ "$(__git config --type=bool checkout.guess)" = "false" ]; then
+ dwim_opt=""
+ fi
+
# Find the last provided --guess or --no-guess
last_option="$(__git_find_last_on_cmdline "--guess --no-guess")"
case "$last_option" in