aboutsummaryrefslogtreecommitdiff
path: root/t/t5528-push-default.sh
diff options
context:
space:
mode:
authorMatthieu Moy <Matthieu.Moy@imag.fr>2012-04-24 09:50:02 +0200
committerJunio C Hamano <gitster@pobox.com>2012-04-24 12:11:58 -0700
commit321e75c5dc6d6abc76e2349000e93c809ddfcdab (patch)
treef2b580d33f185d6809f3bd6ca03b465f8b332172 /t/t5528-push-default.sh
parent628ab0ea1046800b9520c07d809db886b1ec3693 (diff)
downloadgit-321e75c5dc6d6abc76e2349000e93c809ddfcdab.tar.gz
git-321e75c5dc6d6abc76e2349000e93c809ddfcdab.tar.xz
t5528-push-default.sh: add helper functions
Signed-off-by: Matthieu Moy <Matthieu.Moy@imag.fr> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't/t5528-push-default.sh')
-rwxr-xr-xt/t5528-push-default.sh34
1 files changed, 27 insertions, 7 deletions
diff --git a/t/t5528-push-default.sh b/t/t5528-push-default.sh
index c334c51a0..99e551926 100755
--- a/t/t5528-push-default.sh
+++ b/t/t5528-push-default.sh
@@ -13,16 +13,36 @@ test_expect_success 'setup bare remotes' '
git push parent2 HEAD
'
+# $1 = local revision
+# $2 = remote revision (tested to be equal to the local one)
+check_pushed_commit () {
+ git log -1 --format='%h %s' "$1" >expect &&
+ git --git-dir=repo1 log -1 --format='%h %s' "$2" >actual &&
+ test_cmp expect actual
+}
+
+# $1 = push.default value
+# $2 = expected target branch for the push
+test_push_success () {
+ git -c push.default="$1" push &&
+ check_pushed_commit HEAD "$2"
+}
+
+# $1 = push.default value
+# check that push fails and does not modify any remote branch
+test_push_failure () {
+ git --git-dir=repo1 log --no-walk --format='%h %s' --all >expect &&
+ test_must_fail git -c push.default="$1" push &&
+ git --git-dir=repo1 log --no-walk --format='%h %s' --all >actual &&
+ test_cmp expect actual
+}
+
test_expect_success '"upstream" pushes to configured upstream' '
git checkout master &&
test_config branch.master.remote parent1 &&
test_config branch.master.merge refs/heads/foo &&
- test_config push.default upstream &&
test_commit two &&
- git push &&
- echo two >expect &&
- git --git-dir=repo1 log -1 --format=%s foo >actual &&
- test_cmp expect actual
+ test_push_success upstream foo
'
test_expect_success '"upstream" does not push on unconfigured remote' '
@@ -30,7 +50,7 @@ test_expect_success '"upstream" does not push on unconfigured remote' '
test_unconfig branch.master.remote &&
test_config push.default upstream &&
test_commit three &&
- test_must_fail git push
+ test_push_failure upstream
'
test_expect_success '"upstream" does not push on unconfigured branch' '
@@ -39,7 +59,7 @@ test_expect_success '"upstream" does not push on unconfigured branch' '
test_unconfig branch.master.merge &&
test_config push.default upstream
test_commit four &&
- test_must_fail git push
+ test_push_failure upstream
'
test_expect_success '"upstream" does not push when remotes do not match' '