summaryrefslogtreecommitdiff
path: root/t/t2024-checkout-dwim.sh
diff options
context:
space:
mode:
Diffstat (limited to 't/t2024-checkout-dwim.sh')
-rwxr-xr-xt/t2024-checkout-dwim.sh27
1 files changed, 24 insertions, 3 deletions
diff --git a/t/t2024-checkout-dwim.sh b/t/t2024-checkout-dwim.sh
index dee55e428f..6ecb559465 100755
--- a/t/t2024-checkout-dwim.sh
+++ b/t/t2024-checkout-dwim.sh
@@ -104,7 +104,7 @@ test_expect_success 'setup more remotes with unconventional refspecs' '
cd repo_c &&
test_commit c_master &&
git checkout -b bar &&
- test_commit c_bar
+ test_commit c_bar &&
git checkout -b spam &&
test_commit c_spam
) &&
@@ -113,9 +113,9 @@ test_expect_success 'setup more remotes with unconventional refspecs' '
cd repo_d &&
test_commit d_master &&
git checkout -b baz &&
- test_commit f_baz
+ test_commit d_baz &&
git checkout -b eggs &&
- test_commit c_eggs
+ test_commit d_eggs
) &&
git remote add repo_c repo_c &&
git config remote.repo_c.fetch \
@@ -164,4 +164,25 @@ test_expect_success 'checkout of branch from a single remote succeeds #4' '
test_branch_upstream eggs repo_d eggs
'
+test_expect_success 'checkout of branch with a file having the same name fails' '
+ git checkout -B master &&
+ test_might_fail git branch -D spam &&
+
+ >spam &&
+ test_must_fail git 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 &&
+
+ >spam &&
+ git checkout spam -- &&
+ test_branch spam &&
+ test_cmp_rev refs/remotes/extra_dir/repo_c/extra_dir/spam HEAD &&
+ test_branch_upstream spam repo_c spam
+'
+
test_done