aboutsummaryrefslogtreecommitdiff
path: root/t
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2016-09-29 16:49:43 -0700
committerJunio C Hamano <gitster@pobox.com>2016-09-29 16:49:44 -0700
commitd336b675680c7d4adc9f7190b7974b2ef10c0af4 (patch)
treef27b45c24a78fecac73f6bf5407d9450052ab8aa /t
parent710658413712fd4c4abe539d4788aa954a36734a (diff)
parentb829b9439adc12fa4fb33338694e7f1ad40254c1 (diff)
downloadgit-d336b675680c7d4adc9f7190b7974b2ef10c0af4.tar.gz
git-d336b675680c7d4adc9f7190b7974b2ef10c0af4.tar.xz
Merge branch 'nd/checkout-disambiguation' into maint
"git checkout <word>" does not follow the usual disambiguation rules when the <word> can be both a rev and a path, to allow checking out a branch 'foo' in a project that happens to have a file 'foo' in the working tree without having to disambiguate. This was poorly documented and the check was incorrect when the command was run from a subdirectory. * nd/checkout-disambiguation: checkout: fix ambiguity check in subdir checkout.txt: document a common case that ignores ambiguation rules checkout: add some spaces between code and comment
Diffstat (limited to 't')
-rwxr-xr-xt/t2010-checkout-ambiguous.sh9
-rwxr-xr-xt/t2024-checkout-dwim.sh12
2 files changed, 21 insertions, 0 deletions
diff --git a/t/t2010-checkout-ambiguous.sh b/t/t2010-checkout-ambiguous.sh
index e76e84afb..2e47fe01c 100755
--- a/t/t2010-checkout-ambiguous.sh
+++ b/t/t2010-checkout-ambiguous.sh
@@ -41,6 +41,15 @@ test_expect_success 'check ambiguity' '
test_must_fail git checkout world all
'
+test_expect_success 'check ambiguity in subdir' '
+ mkdir sub &&
+ # not ambiguous because sub/world does not exist
+ git -C sub checkout world ../all &&
+ echo hello >sub/world &&
+ # ambiguous because sub/world does exist
+ test_must_fail git -C sub checkout world ../all
+'
+
test_expect_success 'disambiguate checking out from a tree-ish' '
echo bye > world &&
git checkout world -- world &&
diff --git a/t/t2024-checkout-dwim.sh b/t/t2024-checkout-dwim.sh
index 468a000e4..3e5ac81bd 100755
--- a/t/t2024-checkout-dwim.sh
+++ b/t/t2024-checkout-dwim.sh
@@ -174,6 +174,18 @@ test_expect_success 'checkout of branch with a file having the same name fails'
test_branch master
'
+test_expect_success 'checkout of branch with a file in subdir having the same name fails' '
+ git checkout -B master &&
+ test_might_fail git branch -D spam &&
+
+ >spam &&
+ mkdir sub &&
+ mv spam sub/spam &&
+ test_must_fail git -C sub checkout spam &&
+ test_must_fail git rev-parse --verify refs/heads/spam &&
+ test_branch master
+'
+
test_expect_success 'checkout <branch> -- succeeds, even if a file with the same name exists' '
git checkout -B master &&
test_might_fail git branch -D spam &&