3 test_description='server update prefer rebase'
7 test_expect_success 'setup' '
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 &&
19 install_update_hook 'update-prefer-rebase'
21 test_expect_success 'merge local changes is caught' '
22 # make an outstanding change for us--but do not push
23 echo "$test_name" >a.client1 &&
25 git commit -m "$test_name on client1" &&
27 # have another client commit (in this case, it is the server, but close enough)
29 echo "$test_name" >a.client2 &&
31 git commit -m "$test_name on client2" &&
33 # go back to our client and it will merge in our changes
36 merge=$(git rev-parse HEAD) &&
38 ! git push 2>push.err &&
39 cat push.err | grep "It looks like you should rebase instead of merging $merge" &&
40 git reset --hard origin/master
43 test_expect_success 'merge local changes followed by more commits is caught' '
44 # make an outstanding change for us--but do not push
45 echo "$test_name" >a.client1 &&
47 git commit -m "$test_name on client1" &&
49 # have another client commit (in this case, it is the server, but close enough)
51 echo "$test_name" >a.client2 &&
53 git commit -m "$test_name on client2" &&
55 # go back to our client and it will merge in our changes
58 merge=$(git rev-parse HEAD) &&
60 # To complicate things, have them add another change
61 echo "$test_name again" >a.client1 &&
62 git commit -a -m "$test_name on client1 again" &&
64 ! git push 2>push.err &&
65 cat push.err | grep "It looks like you should rebase instead of merging $merge" &&
66 git reset --hard origin/master
69 test_expect_success 'merge shared changes from another topic is okay' '
70 # make a change on topic for us and share it
71 git checkout -b topic master &&
72 echo "$test_name" >a.client1 &&
74 git commit -m "$test_name on client1 and topic" &&
75 git push origin topic &&
77 # make an outstanding on topic that is not pushed
78 echo "$test_name again" >>a.client1 &&
79 git commit -a -m "$test_name on client1 and topic again" &&
81 # have another client commit to master (in this case, it is the server, but close enough)
83 echo "$test_name" >a.client2 &&
85 git commit -m "$test_name on client2" &&
87 # go back to our client and it will merge in our changes
89 git checkout master &&
90 # this should fast fwd
92 # this pulls in the shared branch+its new tip
98 test_expect_success 'simple commit' '
99 # go back to topic and make a simple commit/push as a sanity check
100 git checkout topic &&
101 echo "$test_name" >>a.client1 &&
102 git commit -a -m "$test_name on client1 and topic" &&