Fix test-lib bug not &&'ing together the exit code for multiple update scripts.
[git-central.git] / tests / t5000-script-checkout.sh
1 #!/bin/sh
2
3 test_description='script checkout'
4
5 . ./test-lib.sh
6
7 export PATH=$PATH:../../scripts
8
9 test_expect_success 'setup' '
10         echo "setup" >a &&
11         git add a &&
12         git commit -m "setup" &&
13         git clone ./. server &&
14         rm -fr server/.git/hooks &&
15         git remote add origin ./server
16         git checkout -b stable &&
17         git push origin stable
18 '
19
20 test_expect_success 'checkout a new branch clones stable' '
21         gc-checkout topic1 &&
22         git branch | grep topic1 &&
23         git branch -r | grep origin/topic1 &&
24         git config --list | grep "branch.topic1.merge=refs/heads/topic1"
25 '
26
27 test_expect_success 'checkout an existing remote branch' '
28         cd server &&
29         git checkout -b topic2 stable &&
30         echo "$test_name" >a &&
31         git commit -a -m "Made topic2 on server" &&
32         cd .. &&
33
34         gc-checkout topic2
35         git branch | grep topic2
36         git branch -r | grep origin/topic2
37         git config --list | grep "branch.topic2.merge=refs/heads/topic2"
38 '
39
40 test_expect_success 'checkout an existing local branch' '
41         gc-checkout topic1
42 '
43
44 test_expect_success 'checkout a revision does not create a new branch' '
45         echo "$test_name" >a &&
46         git commit -a -m "$test_name" &&
47
48         prior=$(git rev-parse HEAD^) &&
49         gc-checkout $prior &&
50         git branch | grep "no branch"
51 '
52
53 test_done
54