Cleaning up scripts to only include useful stuff.
[git-central.git] / tests / t2400-server-pre-receive-only-one.sh
1 #!/bin/sh
2
3 test_description='server pre-receive only one branch/push'
4
5 . ./test-lib.sh
6
7 test_expect_success 'setup' '
8         echo "setup" >a &&
9         git add a &&
10         git commit -m "setup" &&
11         git clone ./. server &&
12         rm -fr server/.git/hooks &&
13         git remote add origin ./server &&
14         git config --add branch.master.remote origin &&
15         git config --add branch.master.merge refs/heads/master &&
16         git fetch
17 '
18
19 install_server_hook 'pre-receive-only-one' 'pre-receive'
20
21 test_expect_success 'pushing just topic is okay' '
22         git checkout -b topic &&
23         echo "$test_name" >a &&
24         git commit -a -m "$test_name on topic" &&
25         git push origin topic
26 '
27
28 test_expect_success 'pushing just master is okay' '
29         git checkout master &&
30         echo "$test_name" >a &&
31         git commit -a -m "$test_name on master" &&
32         git push
33 '
34
35 test_expect_success 'pushing both master and topic fails' '
36         echo "$test_name" >a &&
37         git commit -a -m "$test_name on master" &&
38
39         git checkout topic &&
40         echo "$test_name" >a &&
41         git commit -a -m "$test_name on topic" &&
42
43         ! git push 2>push.err &&
44         cat push.err | grep "Only push one branch at a time"
45 '
46
47
48 test_done
49