t5509: add basic tests for hideRefs

Test whether regular and full hideRefs patterns work as expected when namespaces are used. Helped-by: Eric Sunshine <sunshine@sunshineco.com> Signed-off-by: Lukas Fleischer <lfleischer@lfos.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Lukas Fleischer committed Nov 5, 2015 at 07:07 UTC 948bfa2c0f40a97d670c6a3fc22c05ceb2ec2c3f
1 file changed +41
t/t5509-fetch-push-namespaces.sh
+41
@@ -82,4 +82,45 @@ test_expect_success 'mirroring a repository using a ref namespace' '
82 )
83 '
84
85 +test_expect_success 'hide namespaced refs with transfer.hideRefs' '
86 + GIT_NAMESPACE=namespace \
87 + git -C pushee -c transfer.hideRefs=refs/tags \
88 + ls-remote "ext::git %s ." >actual &&
89 + printf "$commit1\trefs/heads/master\n" >expected &&
90 + test_cmp expected actual
91 +'
92 +
93 +test_expect_success 'check that transfer.hideRefs does not match unstripped refs' '
94 + GIT_NAMESPACE=namespace \
95 + git -C pushee -c transfer.hideRefs=refs/namespaces/namespace/refs/tags \
96 + ls-remote "ext::git %s ." >actual &&
97 + printf "$commit1\trefs/heads/master\n" >expected &&
98 + printf "$commit0\trefs/tags/0\n" >>expected &&
99 + printf "$commit1\trefs/tags/1\n" >>expected &&
100 + test_cmp expected actual
101 +'
102 +
103 +test_expect_success 'hide full refs with transfer.hideRefs' '
104 + GIT_NAMESPACE=namespace \
105 + git -C pushee -c transfer.hideRefs="^refs/namespaces/namespace/refs/tags" \
106 + ls-remote "ext::git %s ." >actual &&
107 + printf "$commit1\trefs/heads/master\n" >expected &&
108 + test_cmp expected actual
109 +'
110 +
111 +test_expect_success 'try to update a hidden ref' '
112 + test_config -C pushee transfer.hideRefs refs/heads/master &&
113 + test_must_fail git -C original push pushee-namespaced master
114 +'
115 +
116 +test_expect_success 'try to update a ref that is not hidden' '
117 + test_config -C pushee transfer.hideRefs refs/namespaces/namespace/refs/heads/master &&
118 + git -C original push pushee-namespaced master
119 +'
120 +
121 +test_expect_success 'try to update a hidden full ref' '
122 + test_config -C pushee transfer.hideRefs "^refs/namespaces/namespace/refs/heads/master" &&
123 + test_must_fail git -C original push pushee-namespaced master
124 +'
125 +
126 test_done