Remove the server-/client- prefixes in the tests.
[git-central.git] / tests / t2302-update-prefer-rebase-new-parent.sh
1 #!/bin/sh
2
3 test_description='server update prefer rebase'
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_update_hook 'update-prefer-rebase'
20
21 test_expect_success 'one new, one old parent is okay' '
22         # server is on "setup"
23
24         # make an outstanding change for us--but do not push
25         echo "$test_name" >a.client1 &&
26         git add a.client1 &&
27         git commit -m "$test_name on client1" &&
28
29         # have another client commit (in this case, it is the server, but close enough)
30         cd server &&
31         echo "$test_name" >a.client2 &&
32         git add a.client2 &&
33         git commit -m "$test_name on client2" &&
34         cd .. &&
35
36         # go back to our client and it will merge in our changes
37         git pull &&
38         merge=$(git rev-parse HEAD) &&
39
40         ! git push 2>push.err &&
41         cat push.err | grep "It looks like you should rebase instead of merging $merge" &&
42         git reset --hard origin/master
43 '
44
45 test_done
46
47 test_expect_success 'all local changes do not need a merge even with more commits after' '
48         # server is on "setup"
49
50         # make an outstanding change for us--but do not push
51         echo "$test_name" >a.client1 &&
52         git add a.client1 &&
53         git commit -m "$test_name on client1" &&
54
55         # have another client commit (in this case, it is the server, but close enough)
56         cd server &&
57         echo "$test_name" >a.client2 &&
58         git add a.client2 &&
59         git commit -m "$test_name on client2" &&
60
61         # go back to our client and it will merge in our changes
62         cd .. &&
63         git pull &&
64         merge=$(git rev-parse HEAD) &&
65
66         # To complicate things, have them add another change
67         echo "$test_name again" >a.client1 &&
68         git commit -a -m "$test_name on client1 again" &&
69
70         ! git push 2>push.err &&
71         cat push.err | grep "It looks like you should rebase instead of merging $merge" &&
72         git reset --hard origin/master
73 '
74
75 test_expect_success 'already shared topic changes do warrant a merge' '
76         # server is on "setup"
77
78         # make a change on topic for us and share it
79         git checkout -b topic master &&
80         echo "$test_name" >a.client1 &&
81         git add a.client1 &&
82         git commit -m "$test_name on client1 and topic" &&
83         git push origin topic &&
84
85         # make an outstanding change that we will have to merge later
86         echo "$test_name again" >>a.client1 &&
87         git commit -a -m "$test_name on client1 and topic again" &&
88
89         # have another client commit to master (in this case, it is the server, but close enough)
90         cd server &&
91         echo "$test_name" >a.client2 &&
92         git add a.client2 &&
93         git commit -m "$test_name on client2" &&
94
95         # go back to our client and it will merge in our changes
96         cd .. &&
97         git checkout master &&
98         git pull &&
99         git merge topic &&
100
101         git push
102 '
103
104 test_expect_success 'simple commit' '
105         # go back to topic and make a simple commit/push as a sanity check
106         git checkout topic &&
107         echo "$test_name" >>a.client1 &&
108         git commit -a -m "$test_name on client1 and topic" &&
109         git push
110 '
111
112 test_done
113