3 test_description='checkout and pathspecs/refspecs ambiguities'
7 test_expect_success 'setup' '
11 git commit -m initial &&
15 test_expect_success 'reference must be a tree' '
16 test_must_fail git checkout $(git hash-object ./all) --
19 test_expect_success 'branch switching' '
20 test "refs/heads/master" = "$(git symbolic-ref HEAD)" &&
21 git checkout world -- &&
22 test "refs/heads/world" = "$(git symbolic-ref HEAD)"
25 test_expect_success 'checkout world from the index' '
27 git checkout -- world &&
28 git diff --exit-code --quiet
31 test_expect_success 'non ambiguous call' '
35 test_expect_success 'allow the most common case' '
37 test "refs/heads/world" = "$(git symbolic-ref HEAD)"
40 test_expect_success 'check ambiguity' '
41 test_must_fail git checkout world all
44 test_expect_success 'disambiguate checking out from a tree-ish' '
46 git checkout world -- world &&
47 git diff --exit-code --quiet
50 test_expect_success 'accurate error message with more than one ref' '
51 test_must_fail git checkout HEAD master -- 2>actual &&
52 test_i18ngrep 2 actual &&
53 test_i18ngrep "one reference expected, 2 given" actual