Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.kernel.org/pub/scm/git/git.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/t
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2020-10-28 01:09:51 +0300
committerJunio C Hamano <gitster@pobox.com>2020-10-28 01:09:51 +0300
commit0e41cfad622dde07815d3d575fd3bf05db83da32 (patch)
tree16affb2e58940325541f73855d01387e42fd4bde /t
parentf3cfeb3078ce4af0ac764515795f7e0849a88931 (diff)
parent64f1f58fe7c0837bd0ae56ba83add5e1b84c54d3 (diff)
Merge branch 'dl/checkout-guess'
"git checkout" learned to use checkout.guess configuration variable and enable/disable its "--[no-]guess" option accordingly. * dl/checkout-guess: checkout: learn to respect checkout.guess Documentation/config/checkout: replace sq with backticks
Diffstat (limited to 't')
-rwxr-xr-xt/t2024-checkout-dwim.sh11
-rwxr-xr-xt/t2060-switch.sh5
-rwxr-xr-xt/t9902-completion.sh52
3 files changed, 67 insertions, 1 deletions
diff --git a/t/t2024-checkout-dwim.sh b/t/t2024-checkout-dwim.sh
index accfa9aa4b..a4f8d3a67e 100755
--- a/t/t2024-checkout-dwim.sh
+++ b/t/t2024-checkout-dwim.sh
@@ -166,6 +166,17 @@ test_expect_success '--no-guess suppresses branch auto-vivification' '
test_branch master
'
+test_expect_success 'checkout.guess = false suppresses branch auto-vivification' '
+ git checkout -B master &&
+ status_uno_is_clean &&
+ test_might_fail git branch -D bar &&
+
+ test_config checkout.guess false &&
+ test_must_fail git checkout bar &&
+ test_must_fail git rev-parse --verify refs/heads/bar &&
+ test_branch master
+'
+
test_expect_success 'setup more remotes with unconventional refspecs' '
git checkout -B master &&
status_uno_is_clean &&
diff --git a/t/t2060-switch.sh b/t/t2060-switch.sh
index 2c1b8c0d6d..68c9101b02 100755
--- a/t/t2060-switch.sh
+++ b/t/t2060-switch.sh
@@ -85,9 +85,12 @@ test_expect_success 'switching ignores file of same branch name' '
test_cmp expected actual
'
-test_expect_success 'guess and create branch ' '
+test_expect_success 'guess and create branch' '
test_when_finished git switch master &&
test_must_fail git switch --no-guess foo &&
+ test_config checkout.guess false &&
+ test_must_fail git switch foo &&
+ test_config checkout.guess true &&
git switch foo &&
echo refs/heads/foo >expected &&
git symbolic-ref HEAD >actual &&
diff --git a/t/t9902-completion.sh b/t/t9902-completion.sh
index 7b7bc6e4bd..eb9e56c39e 100755
--- a/t/t9902-completion.sh
+++ b/t/t9902-completion.sh
@@ -1360,6 +1360,58 @@ test_expect_success 'git checkout - a later --no-guess overrides previous --gues
EOF
'
+test_expect_success 'git checkout - with checkout.guess = false, only completes refs' '
+ test_config checkout.guess false &&
+ test_completion "git checkout " <<-\EOF
+ HEAD Z
+ master Z
+ matching-branch Z
+ matching-tag Z
+ other/branch-in-other Z
+ other/master-in-other Z
+ EOF
+'
+
+test_expect_success 'git checkout - with checkout.guess = true, completes refs and unique remote branches for DWIM' '
+ test_config checkout.guess true &&
+ test_completion "git checkout " <<-\EOF
+ HEAD Z
+ branch-in-other Z
+ master Z
+ master-in-other Z
+ matching-branch Z
+ matching-tag Z
+ other/branch-in-other Z
+ other/master-in-other Z
+ EOF
+'
+
+test_expect_success 'git checkout - a later --guess overrides previous checkout.guess = false, complete refs and unique remote branches for DWIM' '
+ test_config checkout.guess false &&
+ test_completion "git checkout --guess " <<-\EOF
+ HEAD Z
+ branch-in-other Z
+ master Z
+ master-in-other Z
+ matching-branch Z
+ matching-tag Z
+ other/branch-in-other Z
+ other/master-in-other Z
+ EOF
+'
+
+test_expect_success 'git checkout - a later --no-guess overrides previous checkout.guess = true, complete only refs' '
+ test_config checkout.guess true &&
+ test_completion "git checkout --no-guess " <<-\EOF
+ HEAD Z
+ master Z
+ matching-branch Z
+ matching-tag Z
+ other/branch-in-other Z
+ other/master-in-other Z
+ EOF
+'
+
test_expect_success 'git switch - with --detach, complete all references' '
test_completion "git switch --detach " <<-\EOF
HEAD Z