]> asedeno.scripts.mit.edu Git - git.git/commitdiff
Merge branch 'tr/receive-pack-aliased-update-fix' into maint
authorJunio C Hamano <gitster@pobox.com>
Wed, 7 Jul 2010 17:25:15 +0000 (10:25 -0700)
committerJunio C Hamano <gitster@pobox.com>
Wed, 7 Jul 2010 17:25:15 +0000 (10:25 -0700)
* 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

1  2 
builtin/receive-pack.c
t/t5516-fetch-push.sh

Simple merge
index 6a37a4d993df3fa4958a719fdfdb82f0dd2de623,0f98332d5e5cea3a54ce53981e038cc2e91de910..b8f64e13865a0f5fe24d90e6864b58962e8d384c
@@@ -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