From: Stefan Beller <sbeller@google.com>
To: git@vger.kernel.org, gitster@pobox.com, mhagger@alum.mit.edu
Cc: Ronnie Sahlberg <sahlberg@google.com>,
Stefan Beller <sbeller@google.com>
Subject: [PATCH v4 5/7] t5543-atomic-push.sh: add basic tests for atomic pushes
Date: Mon, 17 Nov 2014 18:00:38 -0800 [thread overview]
Message-ID: <1416276040-5303-6-git-send-email-sbeller@google.com> (raw)
In-Reply-To: <1416276040-5303-1-git-send-email-sbeller@google.com>
From: Ronnie Sahlberg <sahlberg@google.com>
Signed-off-by: Ronnie Sahlberg <sahlberg@google.com>
Signed-off-by: Stefan Beller <sbeller@google.com>
---
t/t5543-atomic-push.sh | 101 +++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 101 insertions(+)
create mode 100755 t/t5543-atomic-push.sh
diff --git a/t/t5543-atomic-push.sh b/t/t5543-atomic-push.sh
new file mode 100755
index 0000000..4903227
--- /dev/null
+++ b/t/t5543-atomic-push.sh
@@ -0,0 +1,101 @@
+#!/bin/sh
+
+test_description='pushing to a mirror repository'
+
+. ./test-lib.sh
+
+D=`pwd`
+
+invert () {
+ if "$@"; then
+ return 1
+ else
+ return 0
+ fi
+}
+
+mk_repo_pair () {
+ rm -rf master mirror &&
+ mkdir mirror &&
+ (
+ cd mirror &&
+ git init &&
+ git config receive.denyCurrentBranch warn
+ ) &&
+ mkdir master &&
+ (
+ cd master &&
+ git init &&
+ git remote add $1 up ../mirror
+ )
+}
+
+
+test_expect_success 'atomic push works for a single branch' '
+
+ mk_repo_pair &&
+ (
+ cd master &&
+ echo one >foo && git add foo && git commit -m one &&
+ git push --mirror up
+ echo two >foo && git add foo && git commit -m two &&
+ git push --atomic-push --mirror up
+ ) &&
+ master_master=$(cd master && git show-ref -s --verify refs/heads/master) &&
+ mirror_master=$(cd mirror && git show-ref -s --verify refs/heads/master) &&
+ test "$master_master" = "$mirror_master"
+
+'
+
+test_expect_success 'atomic push works for two branches' '
+
+ mk_repo_pair &&
+ (
+ cd master &&
+ echo one >foo && git add foo && git commit -m one &&
+ git branch second &&
+ git push --mirror up
+ echo two >foo && git add foo && git commit -m two &&
+ git checkout second &&
+ echo three >foo && git add foo && git commit -m three &&
+ git checkout master &&
+ git push --atomic-push --mirror up
+ ) &&
+ master_master=$(cd master && git show-ref -s --verify refs/heads/master) &&
+ mirror_master=$(cd mirror && git show-ref -s --verify refs/heads/master) &&
+ test "$master_master" = "$mirror_master"
+
+ master_second=$(cd master && git show-ref -s --verify refs/heads/second) &&
+ mirror_second=$(cd mirror && git show-ref -s --verify refs/heads/second) &&
+ test "$master_second" = "$mirror_second"
+'
+
+# set up two branches where master can be pushed but second can not
+# (non-fast-forward). Since second can not be pushed the whole operation
+# will fail and leave master untouched.
+test_expect_success 'atomic push fails if one branch fails' '
+ mk_repo_pair &&
+ (
+ cd master &&
+ echo one >foo && git add foo && git commit -m one &&
+ git branch second &&
+ git checkout second &&
+ echo two >foo && git add foo && git commit -m two &&
+ echo three >foo && git add foo && git commit -m three &&
+ echo four >foo && git add foo && git commit -m four &&
+ git push --mirror up
+ git reset --hard HEAD~2 &&
+ git checkout master
+ echo five >foo && git add foo && git commit -m five &&
+ ! git push --atomic-push --all up
+ ) &&
+ master_master=$(cd master && git show-ref -s --verify refs/heads/master) &&
+ mirror_master=$(cd mirror && git show-ref -s --verify refs/heads/master) &&
+ test "$master_master" != "$mirror_master" &&
+
+ master_second=$(cd master && git show-ref -s --verify refs/heads/second) &&
+ mirror_second=$(cd mirror && git show-ref -s --verify refs/heads/second) &&
+ test "$master_second" != "$mirror_second"
+'
+
+test_done
--
2.2.0.rc2.5.gf7b9fb2
next prev parent reply other threads:[~2014-11-18 2:01 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-11-18 2:00 [PATCH v4 0/7] ref-transaction-send-pack Stefan Beller
2014-11-18 2:00 ` [PATCH v4 1/7] receive-pack.c: add protocol support to negotiate atomic-push Stefan Beller
2014-11-18 2:00 ` [PATCH v4 2/7] send-pack.c: add an --atomic-push command line argument Stefan Beller
2014-11-18 2:00 ` [PATCH v4 3/7] receive-pack.c: use a single transaction when atomic-push is negotiated Stefan Beller
2014-11-18 2:00 ` [PATCH v4 4/7] push.c: add an --atomic-push argument Stefan Beller
2014-11-18 2:00 ` Stefan Beller [this message]
2014-11-18 2:00 ` [PATCH v4 6/7] refs.c: add an err argument to create_reflog Stefan Beller
2014-11-18 2:00 ` [PATCH v4 7/7] refs.c: add an err argument to create_symref Stefan Beller
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1416276040-5303-6-git-send-email-sbeller@google.com \
--to=sbeller@google.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=mhagger@alum.mit.edu \
--cc=sahlberg@google.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).