Code

Sync with 1.7.9.5
[git.git] / t / t2010-checkout-ambiguous.sh
1 #!/bin/sh
3 test_description='checkout and pathspecs/refspecs ambiguities'
5 . ./test-lib.sh
7 test_expect_success 'setup' '
8         echo hello >world &&
9         echo hello >all &&
10         git add all world &&
11         git commit -m initial &&
12         git branch world
13 '
15 test_expect_success 'reference must be a tree' '
16         test_must_fail git checkout $(git hash-object ./all) --
17 '
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)"
23 '
25 test_expect_success 'checkout world from the index' '
26         echo bye > world &&
27         git checkout -- world &&
28         git diff --exit-code --quiet
29 '
31 test_expect_success 'non ambiguous call' '
32         git checkout all
33 '
35 test_expect_success 'allow the most common case' '
36         git checkout world &&
37         test "refs/heads/world" = "$(git symbolic-ref HEAD)"
38 '
40 test_expect_success 'check ambiguity' '
41         test_must_fail git checkout world all
42 '
44 test_expect_success 'disambiguate checking out from a tree-ish' '
45         echo bye > world &&
46         git checkout world -- world &&
47         git diff --exit-code --quiet
48 '
50 test_done