From: Stephen Haberman Date: Sat, 21 Jun 2008 16:19:29 +0000 (-0500) Subject: Only one branch push/recive. X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=4644baffdd3be74ea8273bced3aeef8570fe182f;p=git-central.git Only one branch push/recive. --- diff --git a/server/pre-receive-only-one b/server/pre-receive-only-one new file mode 100644 index 0000000..819167a --- /dev/null +++ b/server/pre-receive-only-one @@ -0,0 +1,16 @@ +#!/bin/sh + +i=0 +while read oldrev newrev refname ; do + i=$(($i + 1)) +done + +if [ $i -ne 1 ] ; then + echo "----------------------------------------------------" + echo + echo "Only push one branch at a time" + echo + echo "----------------------------------------------------" + exit 1 +fi + diff --git a/tests/t2400-server-pre-receive-only-one.sh b/tests/t2400-server-pre-receive-only-one.sh new file mode 100644 index 0000000..8a07a9f --- /dev/null +++ b/tests/t2400-server-pre-receive-only-one.sh @@ -0,0 +1,49 @@ +#!/bin/sh + +test_description='server pre-receive only one branch/push' + +. ./test-lib.sh + +test_expect_success 'setup' ' + echo "setup" >a && + git add a && + git commit -m "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 +' + +install_server_hook 'pre-receive-only-one' 'pre-receive' + +test_expect_success 'pushing just topic is okay' ' + git checkout -b topic && + echo "$test_name" >a && + git commit -a -m "$test_name on topic" && + git push origin topic +' + +test_expect_success 'pushing just master is okay' ' + git checkout master && + echo "$test_name" >a && + git commit -a -m "$test_name on master" && + git push +' + +test_expect_success 'pushing both master and topic fails' ' + echo "$test_name" >a && + git commit -a -m "$test_name on master" && + + git checkout topic && + echo "$test_name" >a && + git commit -a -m "$test_name on topic" && + + ! git push 2>push.err && + cat push.err | grep "Only push one branch at a time" +' + + +test_done +