]> git.ipfire.org Git - thirdparty/git.git/blame - t/t5550-http-fetch-dumb.sh
The fifteenth batch
[thirdparty/git.git] / t / t5550-http-fetch-dumb.sh
CommitLineData
119c8eee
JK
1#!/bin/sh
2
7da4e228 3test_description='test dumb fetching over http via static file'
028cb644 4GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
334afbc7
JS
5export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
6
119c8eee 7. ./test-lib.sh
7b6853a8
HWN
8
9if test_have_prereq !REFFILES
10then
11 skip_all='skipping test; dumb HTTP protocol not supported with reftable.'
12 test_done
13fi
14
55bc3dc4 15. "$TEST_DIRECTORY"/lib-httpd.sh
119c8eee
JK
16start_httpd
17
18test_expect_success 'setup repository' '
c9704aa7 19 git config push.default matching &&
5a9681f4 20 echo content1 >file &&
119c8eee 21 git add file &&
99094a7a 22 git commit -m one &&
5a9681f4
CB
23 echo content2 >file &&
24 git add file &&
25 git commit -m two
119c8eee
JK
26'
27
f6db603c
ÆAB
28setup_post_update_server_info_hook () {
29 test_hook --setup -C "$1" post-update <<-\EOF &&
30 exec git update-server-info
31 EOF
32 git -C "$1" update-server-info
33}
34
5a9681f4 35test_expect_success 'create http-accessible bare repository with loose objects' '
d4a7ffaa 36 cp -R .git "$HTTPD_DOCUMENT_ROOT_PATH/repo.git" &&
f6db603c
ÆAB
37 git -C "$HTTPD_DOCUMENT_ROOT_PATH/repo.git" config core.bare true &&
38 setup_post_update_server_info_hook "$HTTPD_DOCUMENT_ROOT_PATH/repo.git" &&
119c8eee 39 git remote add public "$HTTPD_DOCUMENT_ROOT_PATH/repo.git" &&
028cb644 40 git push public main:main
119c8eee
JK
41'
42
43test_expect_success 'clone http repository' '
6cfc0286
TRC
44 git clone $HTTPD_URL/dumb/repo.git clone-tmpl &&
45 cp -R clone-tmpl clone &&
119c8eee
JK
46 test_cmp file clone/file
47'
48
4b0c3c77
JN
49test_expect_success 'list refs from outside any repository' '
50 cat >expect <<-EOF &&
028cb644
JS
51 $(git rev-parse main) HEAD
52 $(git rev-parse main) refs/heads/main
4b0c3c77
JN
53 EOF
54 nongit git ls-remote "$HTTPD_URL/dumb/repo.git" >actual &&
55 test_cmp expect actual
56'
57
5232586c 58test_expect_success 'create password-protected repository' '
726800a8 59 mkdir -p "$HTTPD_DOCUMENT_ROOT_PATH/auth/dumb/" &&
5232586c 60 cp -Rf "$HTTPD_DOCUMENT_ROOT_PATH/repo.git" \
726800a8 61 "$HTTPD_DOCUMENT_ROOT_PATH/auth/dumb/repo.git"
5232586c
JK
62'
63
ac093d07 64test_expect_success 'create empty remote repository' '
65 git init --bare "$HTTPD_DOCUMENT_ROOT_PATH/empty.git" &&
f6db603c 66 setup_post_update_server_info_hook "$HTTPD_DOCUMENT_ROOT_PATH/empty.git"
ac093d07 67'
68
18c9cb75 69test_expect_success 'empty dumb HTTP repository falls back to SHA1' '
ac093d07 70 test_when_finished "rm -fr clone-empty" &&
71 git clone $HTTPD_URL/dumb/empty.git clone-empty &&
72 git -C clone-empty rev-parse --show-object-format >empty-format &&
18c9cb75 73 test "$(cat empty-format)" = sha1
ac093d07 74'
75
e837936c 76setup_askpass_helper
148bb6a7 77
5232586c 78test_expect_success 'cloning password-protected repository can fail' '
e837936c 79 set_askpass wrong &&
726800a8 80 test_must_fail git clone "$HTTPD_URL/auth/dumb/repo.git" clone-auth-fail &&
148bb6a7 81 expect_askpass both wrong
5232586c
JK
82'
83
84test_expect_success 'http auth can use user/pass in URL' '
e837936c 85 set_askpass wrong &&
726800a8 86 git clone "$HTTPD_URL_USER_PASS/auth/dumb/repo.git" clone-auth-none &&
148bb6a7 87 expect_askpass none
5232586c
JK
88'
89
dfa1725a 90test_expect_success 'http auth can use just user in URL' '
afbf5ca5 91 set_askpass wrong pass@host &&
726800a8 92 git clone "$HTTPD_URL_USER/auth/dumb/repo.git" clone-auth-pass &&
148bb6a7 93 expect_askpass pass user@host
5232586c
JK
94'
95
dfa1725a 96test_expect_success 'http auth can request both user and pass' '
afbf5ca5 97 set_askpass user@host pass@host &&
726800a8 98 git clone "$HTTPD_URL/auth/dumb/repo.git" clone-auth-both &&
148bb6a7 99 expect_askpass both user@host
3cf8fe1d
GC
100'
101
dfa1725a 102test_expect_success 'http auth respects credential helper config' '
11825072
JK
103 test_config_global credential.helper "!f() {
104 cat >/dev/null
105 echo username=user@host
afbf5ca5 106 echo password=pass@host
11825072 107 }; f" &&
e837936c 108 set_askpass wrong &&
726800a8 109 git clone "$HTTPD_URL/auth/dumb/repo.git" clone-auth-helper &&
11825072
JK
110 expect_askpass none
111'
112
dfa1725a 113test_expect_success 'http auth can get username from config' '
d5742425 114 test_config_global "credential.$HTTPD_URL.username" user@host &&
afbf5ca5 115 set_askpass wrong pass@host &&
726800a8 116 git clone "$HTTPD_URL/auth/dumb/repo.git" clone-auth-user &&
d5742425
JK
117 expect_askpass pass user@host
118'
119
dfa1725a 120test_expect_success 'configured username does not override URL' '
d5742425 121 test_config_global "credential.$HTTPD_URL.username" wrong &&
afbf5ca5 122 set_askpass wrong pass@host &&
726800a8 123 git clone "$HTTPD_URL_USER/auth/dumb/repo.git" clone-auth-user2 &&
d5742425
JK
124 expect_askpass pass user@host
125'
126
455d22c1 127test_expect_success 'set up repo with http submodules' '
14111fc4
JK
128 git init super &&
129 set_askpass user@host pass@host &&
130 (
131 cd super &&
132 git submodule add "$HTTPD_URL/auth/dumb/repo.git" sub &&
133 git commit -m "add submodule"
455d22c1
JK
134 )
135'
136
137test_expect_success 'cmdline credential config passes to submodule via clone' '
14111fc4
JK
138 set_askpass wrong pass@host &&
139 test_must_fail git clone --recursive super super-clone &&
140 rm -rf super-clone &&
455d22c1 141
14111fc4 142 set_askpass wrong pass@host &&
1149ee21 143 git -c "credential.$HTTPD_URL.username=user@host" \
14111fc4 144 clone --recursive super super-clone &&
c12e8656
JK
145 expect_askpass pass user@host
146'
147
148test_expect_success 'cmdline credential config passes submodule via fetch' '
149 set_askpass wrong pass@host &&
150 test_must_fail git -C super-clone fetch --recurse-submodules &&
151
152 set_askpass wrong pass@host &&
153 git -C super-clone \
154 -c "credential.$HTTPD_URL.username=user@host" \
155 fetch --recurse-submodules &&
14111fc4
JK
156 expect_askpass pass user@host
157'
158
860cba61
JK
159test_expect_success 'cmdline credential config passes submodule update' '
160 # advance the submodule HEAD so that a fetch is required
161 git commit --allow-empty -m foo &&
162 git push "$HTTPD_DOCUMENT_ROOT_PATH/auth/dumb/repo.git" HEAD &&
163 sha1=$(git rev-parse HEAD) &&
164 git -C super-clone update-index --cacheinfo 160000,$sha1,sub &&
165
166 set_askpass wrong pass@host &&
167 test_must_fail git -C super-clone submodule update &&
168
169 set_askpass wrong pass@host &&
170 git -C super-clone \
171 -c "credential.$HTTPD_URL.username=user@host" \
172 submodule update &&
173 expect_askpass pass user@host
174'
175
119c8eee
JK
176test_expect_success 'fetch changes via http' '
177 echo content >>file &&
178 git commit -a -m two &&
2bcd9ec5 179 git push public &&
119c8eee
JK
180 (cd clone && git pull) &&
181 test_cmp file clone/file
182'
183
6cfc0286
TRC
184test_expect_success 'fetch changes via manual http-fetch' '
185 cp -R clone-tmpl clone2 &&
186
187 HEAD=$(git rev-parse --verify HEAD) &&
188 (cd clone2 &&
028cb644
JS
189 git http-fetch -a -w heads/main-new $HEAD $(git config remote.origin.url) &&
190 git checkout main-new &&
6cfc0286
TRC
191 test $HEAD = $(git rev-parse --verify HEAD)) &&
192 test_cmp file clone2/file
193'
194
2e85a0c8
195test_expect_success 'manual http-fetch without -a works just as well' '
196 cp -R clone-tmpl clone3 &&
197
198 HEAD=$(git rev-parse --verify HEAD) &&
199 (cd clone3 &&
028cb644
JS
200 git http-fetch -w heads/main-new $HEAD $(git config remote.origin.url) &&
201 git checkout main-new &&
2e85a0c8
202 test $HEAD = $(git rev-parse --verify HEAD)) &&
203 test_cmp file clone3/file
204'
205
fbb074c2 206test_expect_success 'http remote detects correct HEAD' '
028cb644 207 git push public main:other &&
fbb074c2
JK
208 (cd clone &&
209 git remote set-head origin -d &&
210 git remote set-head origin -a &&
211 git symbolic-ref refs/remotes/origin/HEAD > output &&
028cb644 212 echo refs/remotes/origin/main > expect &&
fbb074c2
JK
213 test_cmp expect output
214 )
215'
216
96a4f187
TRC
217test_expect_success 'fetch packed objects' '
218 cp -R "$HTTPD_DOCUMENT_ROOT_PATH"/repo.git "$HTTPD_DOCUMENT_ROOT_PATH"/repo_pack.git &&
d761b2ac 219 (cd "$HTTPD_DOCUMENT_ROOT_PATH"/repo_pack.git &&
1327d839 220 git --bare repack -a -d
d761b2ac 221 ) &&
024bb125 222 git clone $HTTPD_URL/dumb/repo_pack.git
96a4f187
TRC
223'
224
8d5d2a34
JT
225test_expect_success 'http-fetch --packfile' '
226 # Arbitrary hash. Use rev-parse so that we get one of the correct
227 # length.
228 ARBITRARY=$(git -C "$HTTPD_DOCUMENT_ROOT_PATH"/repo_pack.git rev-parse HEAD) &&
229
230 git init packfileclient &&
231 p=$(cd "$HTTPD_DOCUMENT_ROOT_PATH"/repo_pack.git && ls objects/pack/pack-*.pack) &&
27e35ba6
JT
232 git -C packfileclient http-fetch --packfile=$ARBITRARY \
233 --index-pack-arg=index-pack --index-pack-arg=--stdin \
234 --index-pack-arg=--keep \
235 "$HTTPD_URL"/dumb/repo_pack.git/$p >out &&
8d5d2a34 236
a764c37b 237 grep -E "^keep.[0-9a-f]{16,}$" out &&
8d5d2a34
JT
238 cut -c6- out >packhash &&
239
240 # Ensure that the expected files are generated
241 test -e "packfileclient/.git/objects/pack/pack-$(cat packhash).pack" &&
242 test -e "packfileclient/.git/objects/pack/pack-$(cat packhash).idx" &&
243 test -e "packfileclient/.git/objects/pack/pack-$(cat packhash).keep" &&
244
245 # Ensure that it has the HEAD of repo_pack, at least
246 HASH=$(git -C "$HTTPD_DOCUMENT_ROOT_PATH"/repo_pack.git rev-parse HEAD) &&
247 git -C packfileclient cat-file -e "$HASH"
248'
249
fe72d420
SP
250test_expect_success 'fetch notices corrupt pack' '
251 cp -R "$HTTPD_DOCUMENT_ROOT_PATH"/repo_pack.git "$HTTPD_DOCUMENT_ROOT_PATH"/repo_bad1.git &&
252 (cd "$HTTPD_DOCUMENT_ROOT_PATH"/repo_bad1.git &&
bacb1c01 253 p=$(ls objects/pack/pack-*.pack) &&
fe72d420
SP
254 chmod u+w $p &&
255 printf %0256d 0 | dd of=$p bs=256 count=1 seek=1 conv=notrunc
256 ) &&
257 mkdir repo_bad1.git &&
258 (cd repo_bad1.git &&
259 git --bare init &&
260 test_must_fail git --bare fetch $HTTPD_URL/dumb/repo_bad1.git &&
bacb1c01 261 test 0 = $(ls objects/pack/pack-*.pack | wc -l)
fe72d420
SP
262 )
263'
264
8d5d2a34
JT
265test_expect_success 'http-fetch --packfile with corrupt pack' '
266 rm -rf packfileclient &&
267 git init packfileclient &&
268 p=$(cd "$HTTPD_DOCUMENT_ROOT_PATH"/repo_bad1.git && ls objects/pack/pack-*.pack) &&
269 test_must_fail git -C packfileclient http-fetch --packfile \
270 "$HTTPD_URL"/dumb/repo_bad1.git/$p
271'
272
750ef425
SP
273test_expect_success 'fetch notices corrupt idx' '
274 cp -R "$HTTPD_DOCUMENT_ROOT_PATH"/repo_pack.git "$HTTPD_DOCUMENT_ROOT_PATH"/repo_bad2.git &&
275 (cd "$HTTPD_DOCUMENT_ROOT_PATH"/repo_bad2.git &&
bacb1c01 276 p=$(ls objects/pack/pack-*.idx) &&
750ef425
SP
277 chmod u+w $p &&
278 printf %0256d 0 | dd of=$p bs=256 count=1 seek=1 conv=notrunc
279 ) &&
280 mkdir repo_bad2.git &&
281 (cd repo_bad2.git &&
282 git --bare init &&
283 test_must_fail git --bare fetch $HTTPD_URL/dumb/repo_bad2.git &&
bacb1c01 284 test 0 = $(ls objects/pack | wc -l)
750ef425
SP
285 )
286'
287
8b9c2dd4
JK
288test_expect_success 'fetch can handle previously-fetched .idx files' '
289 git checkout --orphan branch1 &&
290 echo base >file &&
291 git add file &&
292 git commit -m base &&
293 git --bare init "$HTTPD_DOCUMENT_ROOT_PATH"/repo_packed_branches.git &&
294 git push "$HTTPD_DOCUMENT_ROOT_PATH"/repo_packed_branches.git branch1 &&
295 git --git-dir="$HTTPD_DOCUMENT_ROOT_PATH"/repo_packed_branches.git repack -d &&
296 git checkout -b branch2 branch1 &&
297 echo b2 >>file &&
298 git commit -a -m b2 &&
299 git push "$HTTPD_DOCUMENT_ROOT_PATH"/repo_packed_branches.git branch2 &&
300 git --git-dir="$HTTPD_DOCUMENT_ROOT_PATH"/repo_packed_branches.git repack -d &&
301 git --bare init clone_packed_branches.git &&
302 git --git-dir=clone_packed_branches.git fetch "$HTTPD_URL"/dumb/repo_packed_branches.git branch1:branch1 &&
303 git --git-dir=clone_packed_branches.git fetch "$HTTPD_URL"/dumb/repo_packed_branches.git branch2:branch2
304'
305
7da4e228 306test_expect_success 'did not use upload-pack service' '
5a828bcf 307 ! grep "/git-upload-pack" "$HTTPD_ROOT_PATH/access.log"
7da4e228
SP
308'
309
dbcf2bd3
JK
310test_expect_success 'git client shows text/plain errors' '
311 test_must_fail git clone "$HTTPD_URL/error/text" 2>stderr &&
312 grep "this is the error message" stderr
313'
314
315test_expect_success 'git client does not show html errors' '
316 test_must_fail git clone "$HTTPD_URL/error/html" 2>stderr &&
317 ! grep "this is the error message" stderr
318'
319
bf197fd7
JK
320test_expect_success 'git client shows text/plain with a charset' '
321 test_must_fail git clone "$HTTPD_URL/error/charset" 2>stderr &&
322 grep "this is the error message" stderr
323'
324
fc1b774c
JK
325test_expect_success 'http error messages are reencoded' '
326 test_must_fail git clone "$HTTPD_URL/error/utf16" 2>stderr &&
327 grep "this is the error message" stderr
328'
329
f34a655d
YE
330test_expect_success 'reencoding is robust to whitespace oddities' '
331 test_must_fail git clone "$HTTPD_URL/error/odd-spacing" 2>stderr &&
332 grep "this is the error message" stderr
333'
334
f18604bb
YE
335check_language () {
336 case "$2" in
337 '')
338 >expect
339 ;;
340 ?*)
81590bf7 341 echo "=> Send header: Accept-Language: $1" >expect
f18604bb
YE
342 ;;
343 esac &&
81590bf7 344 GIT_TRACE_CURL=true \
f18604bb
YE
345 LANGUAGE=$2 \
346 git ls-remote "$HTTPD_URL/dumb/repo.git" >output 2>&1 &&
347 tr -d '\015' <output |
348 sort -u |
81590bf7 349 sed -ne '/^=> Send header: Accept-Language:/ p' >actual &&
f18604bb
YE
350 test_cmp expect actual
351}
352
353test_expect_success 'git client sends Accept-Language based on LANGUAGE' '
354 check_language "ko-KR, *;q=0.9" ko_KR.UTF-8'
355
356test_expect_success 'git client sends Accept-Language correctly with unordinary LANGUAGE' '
357 check_language "ko-KR, *;q=0.9" "ko_KR:" &&
358 check_language "ko-KR, en-US;q=0.9, *;q=0.8" "ko_KR::en_US" &&
359 check_language "ko-KR, *;q=0.9" ":::ko_KR" &&
360 check_language "ko-KR, en-US;q=0.9, *;q=0.8" "ko_KR!!:en_US" &&
361 check_language "ko-KR, ja-JP;q=0.9, *;q=0.8" "ko_KR en_US:ja_JP"'
362
363test_expect_success 'git client sends Accept-Language with many preferred languages' '
364 check_language "ko-KR, en-US;q=0.9, fr-CA;q=0.8, de;q=0.7, sr;q=0.6, \
365ja;q=0.5, zh;q=0.4, sv;q=0.3, pt;q=0.2, *;q=0.1" \
366 ko_KR.EUC-KR:en_US.UTF-8:fr_CA:de.UTF-8@euro:sr@latin:ja:zh:sv:pt &&
367 check_language "ko-KR, en-US;q=0.99, fr-CA;q=0.98, de;q=0.97, sr;q=0.96, \
368ja;q=0.95, zh;q=0.94, sv;q=0.93, pt;q=0.92, nb;q=0.91, *;q=0.90" \
369 ko_KR.EUC-KR:en_US.UTF-8:fr_CA:de.UTF-8@euro:sr@latin:ja:zh:sv:pt:nb
370'
371
b0c4adcd 372test_expect_success 'git client send an empty Accept-Language' '
81590bf7
EP
373 GIT_TRACE_CURL=true LANGUAGE= git ls-remote "$HTTPD_URL/dumb/repo.git" 2>stderr &&
374 ! grep "^=> Send header: Accept-Language:" stderr
f18604bb
YE
375'
376
d63ed6ef 377test_expect_success 'remote-http complains cleanly about malformed urls' '
c44088ec 378 test_must_fail git remote-http http::/example.com/repo.git 2>stderr &&
6789275d 379 test_grep "url has no scheme" stderr
d63ed6ef
JK
380'
381
e7fab62b
JN
382# NEEDSWORK: Writing commands to git-remote-curl can race against the latter
383# erroring out, producing SIGPIPE. Remove "ok=sigpipe" once transport-helper has
384# learned to handle early remote helper failures more cleanly.
385test_expect_success 'remote-http complains cleanly about empty scheme' '
386 test_must_fail ok=sigpipe git ls-remote \
387 http::${HTTPD_URL#http}/dumb/repo.git 2>stderr &&
6789275d 388 test_grep "url has no scheme" stderr
d63ed6ef
JK
389'
390
50d34137
JK
391test_expect_success 'redirects can be forbidden/allowed' '
392 test_must_fail git -c http.followRedirects=false \
393 clone $HTTPD_URL/dumb-redir/repo.git dumb-redir &&
394 git -c http.followRedirects=true \
395 clone $HTTPD_URL/dumb-redir/repo.git dumb-redir 2>stderr
396'
397
398test_expect_success 'redirects are reported to stderr' '
399 # just look for a snippet of the redirected-to URL
6789275d 400 test_grep /dumb/ stderr
50d34137
JK
401'
402
403test_expect_success 'non-initial redirects can be forbidden' '
404 test_must_fail git -c http.followRedirects=initial \
405 clone $HTTPD_URL/redir-objects/repo.git redir-objects &&
406 git -c http.followRedirects=true \
407 clone $HTTPD_URL/redir-objects/repo.git redir-objects
408'
409
410test_expect_success 'http.followRedirects defaults to "initial"' '
411 test_must_fail git clone $HTTPD_URL/redir-objects/repo.git default
412'
413
cb4d2d35
JK
414# The goal is for a clone of the "evil" repository, which has no objects
415# itself, to cause the client to fetch objects from the "victim" repository.
416test_expect_success 'set up evil alternates scheme' '
417 victim=$HTTPD_DOCUMENT_ROOT_PATH/victim.git &&
418 git init --bare "$victim" &&
419 git -C "$victim" --work-tree=. commit --allow-empty -m secret &&
420 git -C "$victim" repack -ad &&
421 git -C "$victim" update-server-info &&
422 sha1=$(git -C "$victim" rev-parse HEAD) &&
423
424 evil=$HTTPD_DOCUMENT_ROOT_PATH/evil.git &&
ce5369e3
ÆAB
425 git init --template= --bare "$evil" &&
426 mkdir "$evil/info" &&
cb4d2d35 427 # do this by hand to avoid object existence check
028cb644 428 printf "%s\\t%s\\n" $sha1 refs/heads/main >"$evil/info/refs"
cb4d2d35
JK
429'
430
431# Here we'll just redirect via HTTP. In a real-world attack these would be on
432# different servers, but we should reject it either way.
433test_expect_success 'http-alternates is a non-initial redirect' '
434 echo "$HTTPD_URL/dumb/victim.git/objects" \
435 >"$evil/objects/info/http-alternates" &&
436 test_must_fail git -c http.followRedirects=initial \
437 clone $HTTPD_URL/dumb/evil.git evil-initial &&
438 git -c http.followRedirects=true \
439 clone $HTTPD_URL/dumb/evil.git evil-initial
440'
441
442# Curl supports a lot of protocols that we'd prefer not to allow
443# http-alternates to use, but it's hard to test whether curl has
444# accessed, say, the SMTP protocol, because we are not running an SMTP server.
445# But we can check that it does not allow access to file://, which would
446# otherwise allow this clone to complete.
447test_expect_success 'http-alternates cannot point at funny protocols' '
448 echo "file://$victim/objects" >"$evil/objects/info/http-alternates" &&
449 test_must_fail git -c http.followRedirects=true \
450 clone "$HTTPD_URL/dumb/evil.git" evil-file
451'
452
abcbdc03
JK
453test_expect_success 'http-alternates triggers not-from-user protocol check' '
454 echo "$HTTPD_URL/dumb/victim.git/objects" \
455 >"$evil/objects/info/http-alternates" &&
456 test_config_global http.followRedirects true &&
457 test_must_fail git -c protocol.http.allow=user \
458 clone $HTTPD_URL/dumb/evil.git evil-user &&
459 git -c protocol.http.allow=always \
460 clone $HTTPD_URL/dumb/evil.git evil-user
461'
462
8e27391a
JT
463test_expect_success 'can redirect through non-"info/refs?service=git-upload-pack" URL' '
464 git clone "$HTTPD_URL/redir-to/dumb/repo.git"
465'
466
467test_expect_success 'print HTTP error when any intermediate redirect throws error' '
468 test_must_fail git clone "$HTTPD_URL/redir-to/502" 2> stderr &&
6789275d 469 test_grep "unable to access.*/redir-to/502" stderr
8e27391a
JT
470'
471
ccbbd8bf
JK
472test_expect_success 'fetching via http alternates works' '
473 parent=$HTTPD_DOCUMENT_ROOT_PATH/alt-parent.git &&
474 git init --bare "$parent" &&
475 git -C "$parent" --work-tree=. commit --allow-empty -m foo &&
476 git -C "$parent" update-server-info &&
477 commit=$(git -C "$parent" rev-parse HEAD) &&
478
479 child=$HTTPD_DOCUMENT_ROOT_PATH/alt-child.git &&
480 git init --bare "$child" &&
481 echo "../../alt-parent.git/objects" >"$child/objects/info/alternates" &&
482 git -C "$child" update-ref HEAD $commit &&
483 git -C "$child" update-server-info &&
484
485 git -c http.followredirects=true clone "$HTTPD_URL/dumb/alt-child.git"
486'
487
119c8eee 488test_done