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 'one new, one old parent is okay' '
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" &&
36 # 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
47 test_expect_success 'all local changes do not need a merge even with more commits after' '
48 # server is on "setup"
50 # make an outstanding change for us--but do not push
51 echo "$test_name" >a.client1 &&
53 git commit -m "$test_name on client1" &&
55 # have another client commit (in this case, it is the server, but close enough)
57 echo "$test_name" >a.client2 &&
59 git commit -m "$test_name on client2" &&
61 # go back to our client and it will merge in our changes
64 merge=$(git rev-parse HEAD) &&
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" &&
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
75 test_expect_success 'already shared topic changes do warrant a merge' '
76 # server is on "setup"
78 # make a change on topic for us and share it
79 git checkout -b topic master &&
80 echo "$test_name" >a.client1 &&
82 git commit -m "$test_name on client1 and topic" &&
83 git push origin topic &&
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" &&
89 # have another client commit to master (in this case, it is the server, but close enough)
91 echo "$test_name" >a.client2 &&
93 git commit -m "$test_name on client2" &&
95 # go back to our client and it will merge in our changes
97 git checkout master &&
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" &&