From 624fe50512148f265cfde87b883486091bb0045a Mon Sep 17 00:00:00 2001 From: Stephen Haberman Date: Tue, 30 Sep 2008 11:34:47 -0500 Subject: [PATCH] Fix update-stable for 0-commit branches. --- server/update-stable | 34 +++++-------------- tests/t2102-server-update-stable-candidate.sh | 16 ++------- 2 files changed, 11 insertions(+), 39 deletions(-) diff --git a/server/update-stable b/server/update-stable index a8768c0..7caf865 100644 --- a/server/update-stable +++ b/server/update-stable @@ -40,8 +40,8 @@ # would insinuate qa didn't happen on the merged result). # # Also, we want to enforce that C does not actually introduce -# any diffs to the files between B and C--otherwise this changes -# would not have appeared in QA. +# any diffs to the files between B and C--as they would be changes +# that QA does not see. # . $(dirname $0)/functions @@ -64,31 +64,11 @@ 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 - display_error_message "Creating a branch must include new commits" - exit 1 - fi -fi - # create/delete is okay if [ "$change_type" != "update" ] ; then exit 0 fi -# # The tip must always be new -# already=$(git branch --contains "$newrev") -# if [ "$already" != "" ] ; then -# already=${already## } -# echo "----------------------------------------------------" -# echo -# echo "$short_refname is already referred to by $already" -# echo -# echo "----------------------------------------------------" -# exit 1 -#fi - if [ "$short_refname" == "stable" ] ; then # Stable enforcement @@ -122,10 +102,14 @@ if [ "$short_refname" == "stable" ] ; then fi else # Check if candidate/topic is already in stable - git branch --contains "$oldrev" | grep stable >/dev/null + git branch --contains "$oldrev" | grep --quiet stable if [ $? -eq 0 ] ; then - display_error_message "$short_refname has been merged into stable" - exit 1 + # Okay, it's in stable...but was it previously just a 0-commit initial banch? + git rev-list --first-parent stable | grep --quiet "$oldrev" + if [ $? -ne 0 ] ; then + display_error_message "$short_refname has been merged into stable" + exit 1 + fi fi # For now candidates can mix amongst each other so early exit diff --git a/tests/t2102-server-update-stable-candidate.sh b/tests/t2102-server-update-stable-candidate.sh index cf891bf..b36dd1f 100644 --- a/tests/t2102-server-update-stable-candidate.sh +++ b/tests/t2102-server-update-stable-candidate.sh @@ -86,10 +86,9 @@ test_expect_success 'topic1 cannot be changed' ' git reset --hard HEAD^ ' -test_expect_success 'topic3 cannot initially be created on stable' ' +test_expect_success 'topic3 can initially be created on stable and then moved' ' git checkout -b topic3 stable && - ! git push origin topic3 2>push.err && - cat push.err | grep "Creating a branch must include new commits" && + git push origin topic3 && echo "$test_name" >a.topic3 && git add a.topic3 && @@ -97,16 +96,5 @@ test_expect_success 'topic3 cannot initially be created on stable' ' git push origin topic3 ' -test_expect_failure 'topic4 cannot point to the same place as topic4' ' - git checkout -b topic4 topic3 && - echo "$test_name" >a.topic4 && - git add a.topic4 && - git commit -m "making topic4" && - git push origin topic4 && - - ! git push origin topic4:topic3 2>push.err && - cat push.err | grep "topic3 is already referred to by topic4" -' - test_done -- 2.39.5