]> rtime.felk.cvut.cz Git - git.git/commitdiff
Merge branch 'js/maint-receive-pack-symref-alias'
authorJunio C Hamano <gitster@pobox.com>
Fri, 21 May 2010 11:02:19 +0000 (04:02 -0700)
committerJunio C Hamano <gitster@pobox.com>
Fri, 21 May 2010 11:02:19 +0000 (04:02 -0700)
* js/maint-receive-pack-symref-alias:
  t5516-fetch-push.sh: style cleanup
  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,f0813e0d0b2c339ecbc251acf602b53e6abc97d9..b11da79c9cafebb5af572bd8e9f85dfc6f3c3f77
@@@ -528,9 -538,10 +538,10 @@@ test_expect_success 'push does not upda
        mk_test heads/master &&
        mk_child child &&
        mkdir testrepo/.git/hooks &&
 -      echo exit 1 >testrepo/.git/hooks/pre-receive &&
 +      echo "#!/no/frobnication/today" >testrepo/.git/hooks/pre-receive &&
        chmod +x testrepo/.git/hooks/pre-receive &&
-       (cd child &&
+       (
+               cd child &&
                git pull .. master
                test_must_fail git push &&
                test $(git rev-parse master) != \
@@@ -660,54 -683,53 +683,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