From d1e1e7bb5740372e001813cba756bd1c6a80ed1b Mon Sep 17 00:00:00 2001 From: Stephen Haberman Date: Wed, 27 Aug 2008 12:13:01 -0500 Subject: [PATCH] Disallow creating branches that are directly (no-commit) on stable. --- server/update-stable | 16 ++++++++++++++++ tests/t2102-server-update-stable-candidate.sh | 6 ++++++ 2 files changed, 22 insertions(+) diff --git a/server/update-stable b/server/update-stable index 6e1264b..020cd90 100644 --- a/server/update-stable +++ b/server/update-stable @@ -60,6 +60,22 @@ case "$refname" in ;; esac +if [ "$change_type" == "delete" ] ; then + exit 0 +fi + +if [ "$change_type" == "create" -a "$short_refname" != "stable" ] ; then + not_on_stable=$(git rev-list stable..$newrev) + if [ "$not_on_stable" == "" ] ; then + echo "----------------------------------------------------" + echo + echo "Creating a branch must include new commits" + echo + echo "----------------------------------------------------" + exit 1 + fi +fi + # create/delete is okay if [ "$change_type" != "update" ] ; then exit 0 diff --git a/tests/t2102-server-update-stable-candidate.sh b/tests/t2102-server-update-stable-candidate.sh index 45f1782..8a5711d 100644 --- a/tests/t2102-server-update-stable-candidate.sh +++ b/tests/t2102-server-update-stable-candidate.sh @@ -85,5 +85,11 @@ test_expect_success 'topic1 cannot be changed' ' cat push.err | grep "topic1 has been merged into stable" ' +test_expect_success 'topic3 cannot initially be created on stable' ' + git checkout -b topic3 stable && + ! git push origin topic3 2>push.err && + cat push.err | grep "Creating a branch must include new commits" +' + test_done -- 2.39.5