git-push: add tests for git push --porcelain
Verify that the output format is correct for successful, rejected, and flagrantly erroneous pushes. Signed-off-by: Larry D'Anna <larry@elder-gods.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Larry D'Anna committed
Feb 26, 2010 at 23:52 UTC
fbe4f447ec60ffa760cfb586708ddbddee789733
1 file changed
+50
t/t5516-fetch-push.sh
+50
@@ -660,4 +660,54 @@ test_expect_success 'push with branches containing #' '
660
git checkout master
661
'
662
663
+test_expect_success 'push --porcelain' '
664
+ mk_empty &&
665
+ echo >.git/foo "To testrepo" &&
666
+ echo >>.git/foo "* refs/heads/master:refs/remotes/origin/master [new branch]" &&
667
+ echo >>.git/foo "Done" &&
668
+ git push >.git/bar --porcelain testrepo refs/heads/master:refs/remotes/origin/master &&
669
+ (
670
+ cd testrepo &&
671
+ r=$(git show-ref -s --verify refs/remotes/origin/master) &&
672
+ test "z$r" = "z$the_commit" &&
673
+ test 1 = $(git for-each-ref refs/remotes/origin | wc -l)
674
+ ) &&
675
+ diff -q .git/foo .git/bar
676
+'
677
+
678
+test_expect_success 'push --porcelain bad url' '
679
+ mk_empty &&
680
+ test_must_fail git push >.git/bar --porcelain asdfasdfasd refs/heads/master:refs/remotes/origin/master &&
681
+ test_must_fail grep -q Done .git/bar
682
+'
683
+
684
+test_expect_success 'push --porcelain rejected' '
685
+ mk_empty &&
686
+ git push testrepo refs/heads/master:refs/remotes/origin/master &&
687
+ (cd testrepo &&
688
+ git reset --hard origin/master^
689
+ git config receive.denyCurrentBranch true) &&
690
+
691
+ echo >.git/foo "To testrepo" &&
692
+ echo >>.git/foo "! refs/heads/master:refs/heads/master [remote rejected] (branch is currently checked out)" &&
693
+
694
+ test_must_fail git push >.git/bar --porcelain testrepo refs/heads/master:refs/heads/master &&
695
+ diff -q .git/foo .git/bar
696
+'
697
+
698
+test_expect_success 'push --porcelain --dry-run rejected' '
699
+ mk_empty &&
700
+ git push testrepo refs/heads/master:refs/remotes/origin/master &&
701
+ (cd testrepo &&
702
+ git reset --hard origin/master
703
+ git config receive.denyCurrentBranch true) &&
704
+
705
+ echo >.git/foo "To testrepo" &&
706
+ echo >>.git/foo "! refs/heads/master^:refs/heads/master [rejected] (non-fast-forward)" &&
707
+ echo >>.git/foo "Done" &&
708
+
709
+ test_must_fail git push >.git/bar --porcelain --dry-run testrepo refs/heads/master^:refs/heads/master &&
710
+ diff -q .git/foo .git/bar
711
+'
712
+
713
test_done