From: Junio C Hamano Date: Wed, 7 Jul 2010 17:25:15 +0000 (-0700) Subject: Merge branch 'tr/receive-pack-aliased-update-fix' into maint X-Git-Tag: v1.7.2-rc2~2^2~3 X-Git-Url: https://asedeno.scripts.mit.edu/gitweb/?a=commitdiff_plain;h=56bfacef7966553530532d58c07787754add2465;p=git.git Merge branch 'tr/receive-pack-aliased-update-fix' into maint * tr/receive-pack-aliased-update-fix: check_aliased_update: strcpy() instead of strcat() to copy receive-pack: detect aliased updates which can occur with symrefs receive-pack: switch global variable 'commands' to a parameter Conflicts: t/t5516-fetch-push.sh --- 56bfacef7966553530532d58c07787754add2465 diff --cc t/t5516-fetch-push.sh index 6a37a4d99,0f98332d5..b8f64e138 --- a/t/t5516-fetch-push.sh +++ b/t/t5516-fetch-push.sh @@@ -660,54 -660,53 +660,103 @@@ test_expect_success 'push with branche git checkout master ' + test_expect_success 'push into aliased refs (consistent)' ' + mk_test heads/master && + mk_child child1 && + mk_child child2 && + ( + cd child1 && + git branch foo && + git symbolic-ref refs/heads/bar refs/heads/foo + git config receive.denyCurrentBranch false + ) && + ( + cd child2 && + >path2 && + git add path2 && + test_tick && + git commit -a -m child2 && + git branch foo && + git branch bar && + git push ../child1 foo bar + ) + ' + + test_expect_success 'push into aliased refs (inconsistent)' ' + mk_test heads/master && + mk_child child1 && + mk_child child2 && + ( + cd child1 && + git branch foo && + git symbolic-ref refs/heads/bar refs/heads/foo + git config receive.denyCurrentBranch false + ) && + ( + cd child2 && + >path2 && + git add path2 && + test_tick && + git commit -a -m child2 && + git branch foo && + >path3 && + git add path3 && + test_tick && + git commit -a -m child2 && + git branch bar && + test_must_fail git push ../child1 foo bar 2>stderr && + grep "refusing inconsistent update" stderr + ) + ' + +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) + ) && + test_cmp .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 && + test_cmp .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 && + test_cmp .git/foo .git/bar +' + test_done