Skip to content

Commit

Permalink
git-push: add tests for git push --porcelain
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
smoofra authored and gitster committed Feb 28, 2010
1 parent 7755585 commit fbe4f44
Showing 1 changed file with 50 additions and 0 deletions.
50 changes: 50 additions & 0 deletions t/t5516-fetch-push.sh
Original file line number Diff line number Diff line change
Expand Up @@ -660,4 +660,54 @@ test_expect_success 'push with branches containing #' '
git checkout master
'

test_expect_success 'push --porcelain' '
mk_empty &&
echo >.git/foo "To testrepo" &&
echo >>.git/foo "* refs/heads/master:refs/remotes/origin/master [new branch]" &&
echo >>.git/foo "Done" &&
git push >.git/bar --porcelain testrepo refs/heads/master:refs/remotes/origin/master &&
(
cd testrepo &&
r=$(git show-ref -s --verify refs/remotes/origin/master) &&
test "z$r" = "z$the_commit" &&
test 1 = $(git for-each-ref refs/remotes/origin | wc -l)
) &&
diff -q .git/foo .git/bar
'

test_expect_success 'push --porcelain bad url' '
mk_empty &&
test_must_fail git push >.git/bar --porcelain asdfasdfasd refs/heads/master:refs/remotes/origin/master &&
test_must_fail grep -q Done .git/bar
'

test_expect_success 'push --porcelain rejected' '
mk_empty &&
git push testrepo refs/heads/master:refs/remotes/origin/master &&
(cd testrepo &&
git reset --hard origin/master^
git config receive.denyCurrentBranch true) &&
echo >.git/foo "To testrepo" &&
echo >>.git/foo "! refs/heads/master:refs/heads/master [remote rejected] (branch is currently checked out)" &&
test_must_fail git push >.git/bar --porcelain testrepo refs/heads/master:refs/heads/master &&
diff -q .git/foo .git/bar
'

test_expect_success 'push --porcelain --dry-run rejected' '
mk_empty &&
git push testrepo refs/heads/master:refs/remotes/origin/master &&
(cd testrepo &&
git reset --hard origin/master
git config receive.denyCurrentBranch true) &&
echo >.git/foo "To testrepo" &&
echo >>.git/foo "! refs/heads/master^:refs/heads/master [rejected] (non-fast-forward)" &&
echo >>.git/foo "Done" &&
test_must_fail git push >.git/bar --porcelain --dry-run testrepo refs/heads/master^:refs/heads/master &&
diff -q .git/foo .git/bar
'

test_done

0 comments on commit fbe4f44

Please sign in to comment.