New branches should not get the update your local branch message.
[git-central.git] / tests / t2700-server-ensure-follows.sh
index a5eb1fa..514ca73 100644 (file)
@@ -11,8 +11,6 @@ test_expect_success 'setup' '
        git clone ./. server &&
        rm -fr server/.git/hooks &&
        git remote add origin ./server &&
-       git config --add branch.master.remote origin &&
-       git config --add branch.master.merge refs/heads/master &&
        git fetch
 '
 
@@ -51,6 +49,29 @@ test_expect_success 'branch with moved stable requires merge' '
        git push origin topic1
 '
 
+test_expect_success 'branch with moved stable is told to update first' '
+       git checkout stable &&
+       echo "$test_name" >a &&
+       git commit -a -m "Change on stable" &&
+       git push origin stable &&
+
+       # Someone fixes stable first
+       cd server &&
+       git checkout -f topic1 &&
+       git merge stable &&
+       cd .. &&
+
+       git checkout topic1 &&
+       echo "$test_name" >a.topic1 &&
+       git commit -a -m "Change on topic1." &&
+       ! git push --force origin topic1 2>push.err &&
+       cat push.err | grep "You need to update your local branch topic1" &&
+
+       # Now it will work as the teammate merged for us
+       git pull origin topic1 &&
+       git push origin topic1
+'
+
 test_expect_success 'branch with moved stable as second branch requires merge' '
        cd server &&
        git config hooks.update-ensure-follows.branches "foo stable" &&
@@ -114,5 +135,24 @@ test_expect_success 'excused branch with moved stable is okay' '
        git push origin topic2
 '
 
+test_expect_success 'new branch without stable gets nicer error' '
+       git checkout -b topic3 stable &&
+       echo "$test_name" >a.topic3 &&
+       git add a.topic3 &&
+       git commit -m "Change on topic3" &&
+
+       git checkout stable &&
+       echo "$test_name" >a &&
+       git commit -a -m "Change on stable" &&
+       git push origin stable &&
+
+       git checkout topic3 &&
+       ! git push origin topic3 2>push.err &&
+       grep "You need to merge stable into topic3" push.err &&
+
+       git merge stable &&
+       git push origin topic3
+'
+
 test_done