Fix missing -r in gc-checkout looking for existing tracking branches.
[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 on server" >a &&
31         git commit -a -m "Made topic2 on server" &&
32         cd .. &&
33
34         ! git branch | grep topic2 &&
35         gc-checkout topic2 &&
36         git branch | grep topic2 &&
37         git branch -r | grep origin/topic2 &&
38         git config --list | grep "branch.topic2.merge=refs/heads/topic2" &&
39
40         echo "$test_name on client" >a &&
41         git commit -a -m "Move topic2 on client" &&
42         git push origin topic2
43 '
44
45 test_expect_success 'checkout an existing local branch' '
46         gc-checkout topic1
47 '
48
49 test_expect_success 'checkout a revision does not create a new branch' '
50         echo "$test_name" >a &&
51         git commit -a -m "$test_name" &&
52
53         prior=$(git rev-parse HEAD^) &&
54         gc-checkout $prior &&
55         git branch | grep "no branch"
56 '
57
58 test_done
59