Merge branch 'gp/add-u-A-documentation'
[gitweb.git] / t / t5516-fetch-push.sh
index 60093728fecd626ae5e005c4d41cee330ac1112c..c31e5c1c525eea5a9f4677b03c5d7314d70c6136 100755 (executable)
@@ -950,27 +950,6 @@ test_expect_success 'push requires --force to update lightweight tag' '
        )
 '
 
-test_expect_success 'push requires --force to update annotated tag' '
-       mk_test heads/master &&
-       mk_child child1 &&
-       mk_child child2 &&
-       (
-               cd child1 &&
-               git tag -a -m "message 1" Tag &&
-               git push ../child2 Tag:refs/tmp/Tag &&
-               git push ../child2 Tag:refs/tmp/Tag &&
-               >file1 &&
-               git add file1 &&
-               git commit -m "file1" &&
-               git tag -f -a -m "message 2" Tag &&
-               test_must_fail git push ../child2 Tag:refs/tmp/Tag &&
-               git push --force ../child2 Tag:refs/tmp/Tag &&
-               git tag -f -a -m "message 3" Tag HEAD~ &&
-               test_must_fail git push ../child2 Tag:refs/tmp/Tag &&
-               git push --force ../child2 Tag:refs/tmp/Tag
-       )
-'
-
 test_expect_success 'push --porcelain' '
        mk_empty &&
        echo >.git/foo  "To testrepo" &&
@@ -1037,4 +1016,31 @@ test_expect_success 'push --prune refspec' '
        ! check_push_result $the_first_commit tmp/foo tmp/bar
 '
 
+for configsection in transfer receive
+do
+       test_expect_success "push to update a ref hidden by $configsection.hiderefs" '
+               mk_test heads/master hidden/one hidden/two hidden/three &&
+               (
+                       cd testrepo &&
+                       git config $configsection.hiderefs refs/hidden
+               ) &&
+
+               # push to unhidden ref succeeds normally
+               git push testrepo master:refs/heads/master &&
+               check_push_result $the_commit heads/master &&
+
+               # push to update a hidden ref should fail
+               test_must_fail git push testrepo master:refs/hidden/one &&
+               check_push_result $the_first_commit hidden/one &&
+
+               # push to delete a hidden ref should fail
+               test_must_fail git push testrepo :refs/hidden/two &&
+               check_push_result $the_first_commit hidden/two &&
+
+               # idempotent push to update a hidden ref should fail
+               test_must_fail git push testrepo $the_first_commit:refs/hidden/three &&
+               check_push_result $the_first_commit hidden/three
+       '
+done
+
 test_done