3 test_description='server update prefer rebase (with incoming merges)'
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 &&
18 # Specifically, setup a stable that we will merge and check for rebase
19 git checkout -b stable master &&
20 echo "setup.stable" >a &&
21 git commit -a -m "stable" &&
22 git push origin stable
25 install_server_hook 'update-prefer-rebase' 'update'
27 test_expect_success 'merging in stable does not fool the script' '
28 # start our branch, and share it
29 git checkout -b topic1 stable &&
30 git config --add branch.topic1.remote origin &&
31 git config --add branch.topic1.merge refs/heads/topic1 &&
32 echo "topic1" >a.topic1 &&
34 git commit -m "topic1" &&
35 git push origin topic1 &&
37 # now, separately, move ahead stable, and share it
39 echo "setup.stable.moved" >a &&
40 git commit -a -m "stable moved" &&
41 git push origin stable &&
43 # have another client commit (in this case, it is the server, but close enough) move topic1
45 git checkout topic1 &&
46 echo "$test_name" >a.client2 &&
48 git commit -m "topic1 changed by client2" &&
51 # now locally try and merge in stable (even though we are out of date)
52 git checkout topic1 &&
55 # We are shutdown for being a rewind
56 ! git push 2>push.err &&
57 cat push.err | grep "[rejected] topic1 -> topic1 (non-fast forward)"
59 # Make a new merge commit
61 ! git push 2>push.err &&
62 cat push.err | grep "It looks like you should rebase instead of merging"
68 # B -- D -- E -- F topic2
70 # G -- H ------- I attempted push
74 # merge-base(F, H) has two options: B and C
76 test_expect_success 'merging in stable with tricky double baserev does not fool the script' '
77 # start our branch, and share it--commit B
78 git checkout -b topic2 stable &&
79 git config --add branch.topic2.remote origin &&
80 git config --add branch.topic2.merge refs/heads/topic2 &&
81 echo "commit B" >a.topic2 &&
83 git commit -m "commit B created topic2" &&
84 git push origin topic2 &&
86 # now, separately, move ahead stable, and share it--commit C
89 git commit -a -m "commit C moved stable" &&
90 git push origin stable &&
92 # have another client commit (in this case, it is the server, but close enough) moves topic2
94 git checkout topic2 &&
95 echo "commit D continuing topic2" >a.client2 &&
97 git commit -m "commit D by client2" &&
99 # Go ahead and merge in stable by the other client--commit E
102 # Then move topic2 put to--commit F
103 echo "commit F" >a.client2 &&
104 git commit -a -m "commit F by client2" &&
107 # now locally try and merge in stable (even though we are out of date)--commit G
108 git checkout topic2 &&
111 # Go ahead and move our local topic2
112 echo "commit H" >a.topic2 &&
113 git commit -a -m "commit H continues local fork" &&
115 # Make a new merge commit
117 ! git push origin topic2
118 cat push.err | grep "It looks like you should rebase instead of merging"