receive-pack: add another option for receive.denyCurrentBranch
[gitweb.git] / t / t5516-fetch-push.sh
index 7c8a769a90e4554500d73506c1df41483d846d98..7b353d0b854b446085df306ed1b664f82a3a6f01 100755 (executable)
@@ -11,6 +11,7 @@ This test checks the following functionality:
 * hooks
 * --porcelain output format
 * hiderefs
+* reflogs
 '
 
 . ./test-lib.sh
@@ -1290,4 +1291,69 @@ test_expect_success 'pushing a tag pushes the tagged object' '
        test_cmp expect actual
 '
 
+test_expect_success 'push into bare respects core.logallrefupdates' '
+       rm -rf dst.git &&
+       git init --bare dst.git &&
+       git -C dst.git config core.logallrefupdates true &&
+
+       # double push to test both with and without
+       # the actual pack transfer
+       git push dst.git master:one &&
+       echo "one@{0} push" >expect &&
+       git -C dst.git log -g --format="%gd %gs" one >actual &&
+       test_cmp expect actual &&
+
+       git push dst.git master:two &&
+       echo "two@{0} push" >expect &&
+       git -C dst.git log -g --format="%gd %gs" two >actual &&
+       test_cmp expect actual
+'
+
+test_expect_success 'fetch into bare respects core.logallrefupdates' '
+       rm -rf dst.git &&
+       git init --bare dst.git &&
+       (
+               cd dst.git &&
+               git config core.logallrefupdates true &&
+
+               # as above, we double-fetch to test both
+               # with and without pack transfer
+               git fetch .. master:one &&
+               echo "one@{0} fetch .. master:one: storing head" >expect &&
+               git log -g --format="%gd %gs" one >actual &&
+               test_cmp expect actual &&
+
+               git fetch .. master:two &&
+               echo "two@{0} fetch .. master:two: storing head" >expect &&
+               git log -g --format="%gd %gs" two >actual &&
+               test_cmp expect actual
+       )
+'
+
+test_expect_success 'receive.denyCurrentBranch = updateInstead' '
+       git push testrepo master &&
+       (cd testrepo &&
+               git reset --hard &&
+               git config receive.denyCurrentBranch updateInstead
+       ) &&
+       test_commit third path2 &&
+       git push testrepo master &&
+       test $(git rev-parse HEAD) = $(cd testrepo && git rev-parse HEAD) &&
+       test third = "$(cat testrepo/path2)" &&
+       (cd testrepo &&
+               git update-index -q --refresh &&
+               git diff-files --quiet -- &&
+               git diff-index --quiet --cached HEAD -- &&
+               echo changed >path2 &&
+               git add path2
+       ) &&
+       test_commit fourth path2 &&
+       test_must_fail git push testrepo master &&
+       test $(git rev-parse HEAD^) = $(git -C testrepo rev-parse HEAD) &&
+       (cd testrepo &&
+               git diff --quiet &&
+               test changed = "$(cat path2)"
+       )
+'
+
 test_done