Skip to content

Commit fbe4f44

Browse files
smoofragitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 7755585 commit fbe4f44

File tree

1 file changed

+50
-0
lines changed

1 file changed

+50
-0
lines changed

t/t5516-fetch-push.sh

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -660,4 +660,54 @@ test_expect_success 'push with branches containing #' '
660660
git checkout master
661661
'
662662

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+
663713
test_done

0 commit comments

Comments
 (0)