Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/git/blob/master/t/t2010-checkout-ambiguous.sh # git [Ported from github.com/git/git] Sync with Git 2.56.1 Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `master` Branches Tags History `git / t / t2010-checkout-ambiguous.sh` 68 lines ยท 1655 bytes Raw Blame History 1 #!/bin/sh 2 3 test_description='checkout and pathspecs/refspecs ambiguities' 4 5 GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main 6 export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME 7 8 . ./test-lib.sh 9 10 test_expect_success 'setup' ' 11 echo hello >world && 12 echo hello >all && 13 git add all world && 14 git commit -m initial && 15 git branch world 16 ' 17 18 test_expect_success 'reference must be a tree' ' 19 test_must_fail git checkout $(git hash-object ./all) -- 20 ' 21 22 test_expect_success 'branch switching' ' 23 test "refs/heads/main" = "$(git symbolic-ref HEAD)" && 24 git checkout world -- && 25 test "refs/heads/world" = "$(git symbolic-ref HEAD)" 26 ' 27 28 test_expect_success 'checkout world from the index' ' 29 echo bye > world && 30 git checkout -- world && 31 git diff --exit-code --quiet 32 ' 33 34 test_expect_success 'non ambiguous call' ' 35 git checkout all 36 ' 37 38 test_expect_success 'allow the most common case' ' 39 git checkout world && 40 test "refs/heads/world" = "$(git symbolic-ref HEAD)" 41 ' 42 43 test_expect_success 'check ambiguity' ' 44 test_must_fail git checkout world all 45 ' 46 47 test_expect_success 'check ambiguity in subdir' ' 48 mkdir sub && 49 # not ambiguous because sub/world does not exist 50 git -C sub checkout world ../all && 51 echo hello >sub/world && 52 # ambiguous because sub/world does exist 53 test_must_fail git -C sub checkout world ../all 54 ' 55 56 test_expect_success 'disambiguate checking out from a tree-ish' ' 57 echo bye > world && 58 git checkout world -- world && 59 git diff --exit-code --quiet 60 ' 61 62 test_expect_success 'accurate error message with more than one ref' ' 63 test_must_fail git checkout HEAD main -- 2>actual && 64 test_grep 2 actual && 65 test_grep "one reference expected, 2 given" actual 66 ' 67 68 test_done