bundle verify: error out if called without an object database
[gitweb.git] / t / t2024-checkout-dwim.sh
index d640e00e77ce0733fa5bc78342d2f1db37eb0e6a..fa0718c730c322bfe5f9e6642c4136a7533be5dc 100755 (executable)
@@ -24,9 +24,8 @@ test_branch_upstream () {
 }
 
 status_uno_is_clean () {
-       >status.expect &&
        git status -uno --porcelain >status.actual &&
-       test_cmp status.expect status.actual
+       test_must_be_empty status.actual
 }
 
 test_expect_success 'setup' '
@@ -279,4 +278,35 @@ test_expect_success 'loosely defined local base branch is reported correctly' '
        test_cmp expect actual
 '
 
+test_expect_success 'reject when arg could be part of dwim branch' '
+       git remote add foo file://non-existent-place &&
+       git update-ref refs/remotes/foo/dwim-arg HEAD &&
+       echo foo >dwim-arg &&
+       git add dwim-arg &&
+       echo bar >dwim-arg &&
+       test_must_fail git checkout dwim-arg &&
+       test_must_fail git rev-parse refs/heads/dwim-arg -- &&
+       grep bar dwim-arg
+'
+
+test_expect_success 'disambiguate dwim branch and checkout path (1)' '
+       git update-ref refs/remotes/foo/dwim-arg1 HEAD &&
+       echo foo >dwim-arg1 &&
+       git add dwim-arg1 &&
+       echo bar >dwim-arg1 &&
+       git checkout -- dwim-arg1 &&
+       test_must_fail git rev-parse refs/heads/dwim-arg1 -- &&
+       grep foo dwim-arg1
+'
+
+test_expect_success 'disambiguate dwim branch and checkout path (2)' '
+       git update-ref refs/remotes/foo/dwim-arg2 HEAD &&
+       echo foo >dwim-arg2 &&
+       git add dwim-arg2 &&
+       echo bar >dwim-arg2 &&
+       git checkout dwim-arg2 -- &&
+       git rev-parse refs/heads/dwim-arg2 -- &&
+       grep bar dwim-arg2
+'
+
 test_done