path: root/t/
diff options
authorJunio C Hamano <>2016-09-26 23:09:18 (GMT)
committerJunio C Hamano <>2016-09-26 23:09:18 (GMT)
commit31b83f361bd962e9c5f96bf7714051d77f592af2 (patch)
tree457f3839db3bba30e984dfc9d973fa0e7c981c8e /t/
parent8969feac7ee119dc3cdae0e2d8c65516aa8f4045 (diff)
parentb829b9439adc12fa4fb33338694e7f1ad40254c1 (diff)
Merge branch 'nd/checkout-disambiguation'
"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/')
1 files changed, 12 insertions, 0 deletions
diff --git a/t/ b/t/
index 468a000..3e5ac81 100755
--- a/t/
+++ b/t/
@@ -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 &&