pretty: add support for separator option in %(trailers)
[gitweb.git] / t / t5509-fetch-push-namespaces.sh
index cc0b31f6b085dab117aff0b6d65841bcf656f265..c88df78c0bffaae8f09fc2db79427d85a6f8ff48 100755 (executable)
@@ -4,6 +4,7 @@ test_description='fetch/push involving ref namespaces'
 . ./test-lib.sh
 
 test_expect_success setup '
+       git config --global protocol.ext.allow user &&
        test_tick &&
        git init original &&
        (
@@ -43,7 +44,7 @@ test_expect_success 'pushing into a repository using a ref namespace' '
                test_cmp expected actual &&
                # Try a namespace with no content
                git ls-remote "ext::git --namespace=garbage %s ../pushee" >actual &&
-               test_cmp /dev/null actual &&
+               test_must_be_empty actual &&
                git ls-remote pushee-unnamespaced >actual &&
                sed -e "s|refs/|refs/namespaces/namespace/refs/|" expected >expected.unnamespaced &&
                test_cmp expected.unnamespaced actual
@@ -82,4 +83,45 @@ test_expect_success 'mirroring a repository using a ref namespace' '
        )
 '
 
+test_expect_success 'hide namespaced refs with transfer.hideRefs' '
+       GIT_NAMESPACE=namespace \
+               git -C pushee -c transfer.hideRefs=refs/tags \
+               ls-remote "ext::git %s ." >actual &&
+       printf "$commit1\trefs/heads/master\n" >expected &&
+       test_cmp expected actual
+'
+
+test_expect_success 'check that transfer.hideRefs does not match unstripped refs' '
+       GIT_NAMESPACE=namespace \
+               git -C pushee -c transfer.hideRefs=refs/namespaces/namespace/refs/tags \
+               ls-remote "ext::git %s ." >actual &&
+       printf "$commit1\trefs/heads/master\n" >expected &&
+       printf "$commit0\trefs/tags/0\n" >>expected &&
+       printf "$commit1\trefs/tags/1\n" >>expected &&
+       test_cmp expected actual
+'
+
+test_expect_success 'hide full refs with transfer.hideRefs' '
+       GIT_NAMESPACE=namespace \
+               git -C pushee -c transfer.hideRefs="^refs/namespaces/namespace/refs/tags" \
+               ls-remote "ext::git %s ." >actual &&
+       printf "$commit1\trefs/heads/master\n" >expected &&
+       test_cmp expected actual
+'
+
+test_expect_success 'try to update a hidden ref' '
+       test_config -C pushee transfer.hideRefs refs/heads/master &&
+       test_must_fail git -C original push pushee-namespaced master
+'
+
+test_expect_success 'try to update a ref that is not hidden' '
+       test_config -C pushee transfer.hideRefs refs/namespaces/namespace/refs/heads/master &&
+       git -C original push pushee-namespaced master
+'
+
+test_expect_success 'try to update a hidden full ref' '
+       test_config -C pushee transfer.hideRefs "^refs/namespaces/namespace/refs/heads/master" &&
+       test_must_fail git -C original push pushee-namespaced master
+'
+
 test_done