]> git.ipfire.org Git - thirdparty/git.git/blame - t/lib-bundle-uri-protocol.sh
Merge branch 'fc/doc-stop-using-manversion'
[thirdparty/git.git] / t / lib-bundle-uri-protocol.sh
CommitLineData
8f788eb8
ÆAB
1# Set up and run tests of the 'bundle-uri' command in protocol v2
2#
3# The test that includes this script should set BUNDLE_URI_PROTOCOL
4# to one of "file", "git", or "http".
5
6BUNDLE_URI_TEST_PARENT=
7BUNDLE_URI_TEST_URI=
8BUNDLE_URI_TEST_BUNDLE_URI=
9case "$BUNDLE_URI_PROTOCOL" in
10file)
11 BUNDLE_URI_PARENT=file_parent
12 BUNDLE_URI_REPO_URI="file://$PWD/file_parent"
13 BUNDLE_URI_BUNDLE_URI="$BUNDLE_URI_REPO_URI/fake.bdl"
14 test_set_prereq BUNDLE_URI_FILE
15 ;;
16git)
17 . "$TEST_DIRECTORY"/lib-git-daemon.sh
18 start_git_daemon --export-all --enable=receive-pack
19 BUNDLE_URI_PARENT="$GIT_DAEMON_DOCUMENT_ROOT_PATH/parent"
20 BUNDLE_URI_REPO_URI="$GIT_DAEMON_URL/parent"
21 BUNDLE_URI_BUNDLE_URI="https://example.com/fake.bdl"
22 test_set_prereq BUNDLE_URI_GIT
23 ;;
24http)
25 . "$TEST_DIRECTORY"/lib-httpd.sh
26 start_httpd
27 BUNDLE_URI_PARENT="$HTTPD_DOCUMENT_ROOT_PATH/http_parent"
28 BUNDLE_URI_REPO_URI="$HTTPD_URL/smart/http_parent"
29 BUNDLE_URI_BUNDLE_URI="https://example.com/fake.bdl"
30 test_set_prereq BUNDLE_URI_HTTP
31 ;;
32*)
33 BUG "Need to pass valid BUNDLE_URI_PROTOCOL (was \"$BUNDLE_URI_PROTOCOL\")"
34 ;;
35esac
36
37test_expect_success "setup protocol v2 $BUNDLE_URI_PROTOCOL:// tests" '
38 git init "$BUNDLE_URI_PARENT" &&
39 test_commit -C "$BUNDLE_URI_PARENT" one &&
40 git -C "$BUNDLE_URI_PARENT" config uploadpack.advertiseBundleURIs true
41'
42
43case "$BUNDLE_URI_PROTOCOL" in
44http)
45 test_expect_success "setup config for $BUNDLE_URI_PROTOCOL:// tests" '
46 git -C "$BUNDLE_URI_PARENT" config http.receivepack true
47 '
48 ;;
49*)
50 ;;
51esac
52BUNDLE_URI_BUNDLE_URI_ESCAPED=$(echo "$BUNDLE_URI_BUNDLE_URI" | test_uri_escape)
53
54test_expect_success "connect with $BUNDLE_URI_PROTOCOL:// using protocol v2: no bundle-uri" '
55 test_when_finished "rm -f log" &&
56 test_when_finished "git -C \"$BUNDLE_URI_PARENT\" config uploadpack.advertiseBundleURIs true" &&
57 git -C "$BUNDLE_URI_PARENT" config uploadpack.advertiseBundleURIs false &&
58
59 GIT_TRACE_PACKET="$PWD/log" \
60 git \
61 -c protocol.version=2 \
62 ls-remote --symref "$BUNDLE_URI_REPO_URI" \
63 >actual 2>err &&
64
65 # Server responded using protocol v2
66 grep "< version 2" log &&
67
68 ! grep bundle-uri log
69'
70
71test_expect_success "connect with $BUNDLE_URI_PROTOCOL:// using protocol v2: have bundle-uri" '
72 test_when_finished "rm -f log" &&
73
74 GIT_TRACE_PACKET="$PWD/log" \
75 git \
76 -c protocol.version=2 \
77 ls-remote --symref "$BUNDLE_URI_REPO_URI" \
78 >actual 2>err &&
79
80 # Server responded using protocol v2
81 grep "< version 2" log &&
82
83 # Server advertised bundle-uri capability
84 grep "< bundle-uri" log
85'
0cfde740
ÆAB
86
87test_expect_success "clone with $BUNDLE_URI_PROTOCOL:// using protocol v2: request bundle-uris" '
876094ac 88 test_when_finished "rm -rf log* cloned*" &&
0cfde740
ÆAB
89
90 GIT_TRACE_PACKET="$PWD/log" \
91 git \
7cce9074 92 -c transfer.bundleURI=false \
0cfde740
ÆAB
93 -c protocol.version=2 \
94 clone "$BUNDLE_URI_REPO_URI" cloned \
95 >actual 2>err &&
96
97 # Server responded using protocol v2
98 grep "< version 2" log &&
99
100 # Server advertised bundle-uri capability
101 grep "< bundle-uri" log &&
102
7cce9074
ÆAB
103 # Client did not issue bundle-uri command
104 ! grep "> command=bundle-uri" log &&
105
106 GIT_TRACE_PACKET="$PWD/log" \
107 git \
108 -c transfer.bundleURI=true \
109 -c protocol.version=2 \
110 clone "$BUNDLE_URI_REPO_URI" cloned2 \
111 >actual 2>err &&
112
113 # Server responded using protocol v2
114 grep "< version 2" log &&
115
116 # Server advertised bundle-uri capability
117 grep "< bundle-uri" log &&
118
0cfde740 119 # Client issued bundle-uri command
876094ac
DS
120 grep "> command=bundle-uri" log &&
121
122 GIT_TRACE_PACKET="$PWD/log3" \
123 git \
124 -c transfer.bundleURI=true \
125 -c protocol.version=2 \
126 clone --bundle-uri="$BUNDLE_URI_BUNDLE_URI" \
127 "$BUNDLE_URI_REPO_URI" cloned3 \
128 >actual 2>err &&
129
130 # Server responded using protocol v2
131 grep "< version 2" log3 &&
132
133 # Server advertised bundle-uri capability
134 grep "< bundle-uri" log3 &&
135
136 # Client did not issue bundle-uri command (--bundle-uri override)
137 ! grep "> command=bundle-uri" log3
0cfde740 138'
70b9c103
ÆAB
139
140# The remaining tests will all assume transfer.bundleURI=true
141#
142# This test can be removed when transfer.bundleURI is enabled by default.
143test_expect_success 'enable transfer.bundleURI for remaining tests' '
144 git config --global transfer.bundleURI true
145'
146
147test_expect_success "test bundle-uri with $BUNDLE_URI_PROTOCOL:// using protocol v2" '
148 test_config -C "$BUNDLE_URI_PARENT" \
149 bundle.only.uri "$BUNDLE_URI_BUNDLE_URI_ESCAPED" &&
150
151 # All data about bundle URIs
152 cat >expect <<-EOF &&
153 [bundle]
154 version = 1
155 mode = all
738dc7d4
DS
156 [bundle "only"]
157 uri = $BUNDLE_URI_BUNDLE_URI_ESCAPED
70b9c103
ÆAB
158 EOF
159
160 test-tool bundle-uri \
161 ls-remote \
162 "$BUNDLE_URI_REPO_URI" \
163 >actual &&
164 test_cmp_config_output expect actual
165'
166
167test_expect_success "test bundle-uri with $BUNDLE_URI_PROTOCOL:// using protocol v2 and extra data" '
168 test_config -C "$BUNDLE_URI_PARENT" \
169 bundle.only.uri "$BUNDLE_URI_BUNDLE_URI_ESCAPED" &&
170
171 # Extra data should be ignored
172 test_config -C "$BUNDLE_URI_PARENT" bundle.only.extra bogus &&
173
174 # All data about bundle URIs
175 cat >expect <<-EOF &&
176 [bundle]
177 version = 1
178 mode = all
738dc7d4
DS
179 [bundle "only"]
180 uri = $BUNDLE_URI_BUNDLE_URI_ESCAPED
181 EOF
182
183 test-tool bundle-uri \
184 ls-remote \
185 "$BUNDLE_URI_REPO_URI" \
186 >actual &&
187 test_cmp_config_output expect actual
188'
189
190test_expect_success "test bundle-uri with $BUNDLE_URI_PROTOCOL:// using protocol v2 with list" '
191 test_config -C "$BUNDLE_URI_PARENT" \
192 bundle.bundle1.uri "$BUNDLE_URI_BUNDLE_URI_ESCAPED-1.bdl" &&
193 test_config -C "$BUNDLE_URI_PARENT" \
194 bundle.bundle2.uri "$BUNDLE_URI_BUNDLE_URI_ESCAPED-2.bdl" &&
195 test_config -C "$BUNDLE_URI_PARENT" \
196 bundle.bundle3.uri "$BUNDLE_URI_BUNDLE_URI_ESCAPED-3.bdl" &&
197
198 # All data about bundle URIs
199 cat >expect <<-EOF &&
200 [bundle]
201 version = 1
202 mode = all
203 [bundle "bundle1"]
204 uri = $BUNDLE_URI_BUNDLE_URI_ESCAPED-1.bdl
205 [bundle "bundle2"]
206 uri = $BUNDLE_URI_BUNDLE_URI_ESCAPED-2.bdl
207 [bundle "bundle3"]
208 uri = $BUNDLE_URI_BUNDLE_URI_ESCAPED-3.bdl
70b9c103
ÆAB
209 EOF
210
211 test-tool bundle-uri \
212 ls-remote \
213 "$BUNDLE_URI_REPO_URI" \
214 >actual &&
215 test_cmp_config_output expect actual
216'