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_server_hook 'update-prefer-rebase' 'update'
21 test_expect_success 'all local changes do not need a merge' '
22 # server is on "setup"
24 # make an outstanding change for us--but do not push
25 echo "$test_name" >a.client1 &&
27 git commit -m "$test_name on client1" &&
29 # have another client commit (in this case, it is the server, but close enough)
31 echo "$test_name" >a.client2 &&
33 git commit -m "$test_name on client2" &&
35 # go back to our client and it will merge in our changes
38 merge=$(git rev-parse HEAD) &&
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
45 test_expect_success 'all local changes do not need a merge even with more commits after' '
46 # server is on "setup"
48 # make an outstanding change for us--but do not push
49 echo "$test_name" >a.client1 &&
51 git commit -m "$test_name on client1" &&
53 # have another client commit (in this case, it is the server, but close enough)
55 echo "$test_name" >a.client2 &&
57 git commit -m "$test_name on client2" &&
59 # go back to our client and it will merge in our changes
62 merge=$(git rev-parse HEAD) &&
64 # To complicate things, have them add another change
65 echo "$test_name again" >a.client1 &&
66 git commit -a -m "$test_name on client1 again" &&
68 ! git push 2>push.err &&
69 cat push.err | grep "It looks like you should rebase instead of merging $merge" &&
70 git reset --hard origin/master
73 test_expect_success 'already shared topic changes do warrant a merge' '
74 # server is on "setup"
76 # make a change on topic for us and share it
77 git checkout -b topic master &&
78 echo "$test_name" >a.client1 &&
80 git commit -m "$test_name on client1 and topic" &&
81 git push origin topic &&
83 # make an outstanding change that we will have to merge later
84 echo "$test_name again" >>a.client1 &&
85 git commit -a -m "$test_name on client1 and topic again" &&
87 # have another client commit to master (in this case, it is the server, but close enough)
89 echo "$test_name" >a.client2 &&
91 git commit -m "$test_name on client2" &&
93 # go back to our client and it will merge in our changes
95 git checkout master &&
102 test_expect_success 'simple commit' '
103 # go back to topic and make a simple commit/push as a sanity check
104 git checkout topic &&
105 echo "$test_name" >>a.client1 &&
106 git commit -a -m "$test_name on client1 and topic" &&