Imported Upstream version 2.28.0
[platform/upstream/git.git] / t / t0410-partial-clone.sh
1 #!/bin/sh
2
3 test_description='partial clone'
4
5 . ./test-lib.sh
6
7 delete_object () {
8         rm $1/.git/objects/$(echo $2 | sed -e 's|^..|&/|')
9 }
10
11 pack_as_from_promisor () {
12         HASH=$(git -C repo pack-objects .git/objects/pack/pack) &&
13         >repo/.git/objects/pack/pack-$HASH.promisor &&
14         echo $HASH
15 }
16
17 promise_and_delete () {
18         HASH=$(git -C repo rev-parse "$1") &&
19         git -C repo tag -a -m message my_annotated_tag "$HASH" &&
20         git -C repo rev-parse my_annotated_tag | pack_as_from_promisor &&
21         # tag -d prints a message to stdout, so redirect it
22         git -C repo tag -d my_annotated_tag >/dev/null &&
23         delete_object repo "$HASH"
24 }
25
26 test_expect_success 'extensions.partialclone without filter' '
27         test_create_repo server &&
28         git clone --filter="blob:none" "file://$(pwd)/server" client &&
29         git -C client config --unset remote.origin.partialclonefilter &&
30         git -C client fetch origin
31 '
32
33 test_expect_success 'convert shallow clone to partial clone' '
34         rm -fr server client &&
35         test_create_repo server &&
36         test_commit -C server my_commit 1 &&
37         test_commit -C server my_commit2 1 &&
38         git clone --depth=1 "file://$(pwd)/server" client &&
39         git -C client fetch --unshallow --filter="blob:none" &&
40         test_cmp_config -C client true remote.origin.promisor &&
41         test_cmp_config -C client blob:none remote.origin.partialclonefilter &&
42         test_cmp_config -C client 1 core.repositoryformatversion
43 '
44
45 test_expect_success 'convert to partial clone with noop extension' '
46         rm -fr server client &&
47         test_create_repo server &&
48         test_commit -C server my_commit 1 &&
49         test_commit -C server my_commit2 1 &&
50         git clone --depth=1 "file://$(pwd)/server" client &&
51         test_cmp_config -C client 0 core.repositoryformatversion &&
52         git -C client config extensions.noop true &&
53         git -C client fetch --unshallow --filter="blob:none"
54 '
55
56 test_expect_success 'converting to partial clone fails with unrecognized extension' '
57         rm -fr server client &&
58         test_create_repo server &&
59         test_commit -C server my_commit 1 &&
60         test_commit -C server my_commit2 1 &&
61         git clone --depth=1 "file://$(pwd)/server" client &&
62         test_cmp_config -C client 0 core.repositoryformatversion &&
63         git -C client config extensions.nonsense true &&
64         test_must_fail git -C client fetch --unshallow --filter="blob:none"
65 '
66
67 test_expect_success 'missing reflog object, but promised by a commit, passes fsck' '
68         rm -rf repo &&
69         test_create_repo repo &&
70         test_commit -C repo my_commit &&
71
72         A=$(git -C repo commit-tree -m a HEAD^{tree}) &&
73         C=$(git -C repo commit-tree -m c -p $A HEAD^{tree}) &&
74
75         # Reference $A only from reflog, and delete it
76         git -C repo branch my_branch "$A" &&
77         git -C repo branch -f my_branch my_commit &&
78         delete_object repo "$A" &&
79
80         # State that we got $C, which refers to $A, from promisor
81         printf "$C\n" | pack_as_from_promisor &&
82
83         # Normally, it fails
84         test_must_fail git -C repo fsck &&
85
86         # But with the extension, it succeeds
87         git -C repo config core.repositoryformatversion 1 &&
88         git -C repo config extensions.partialclone "arbitrary string" &&
89         git -C repo fsck
90 '
91
92 test_expect_success 'missing reflog object, but promised by a tag, passes fsck' '
93         rm -rf repo &&
94         test_create_repo repo &&
95         test_commit -C repo my_commit &&
96
97         A=$(git -C repo commit-tree -m a HEAD^{tree}) &&
98         git -C repo tag -a -m d my_tag_name $A &&
99         T=$(git -C repo rev-parse my_tag_name) &&
100         git -C repo tag -d my_tag_name &&
101
102         # Reference $A only from reflog, and delete it
103         git -C repo branch my_branch "$A" &&
104         git -C repo branch -f my_branch my_commit &&
105         delete_object repo "$A" &&
106
107         # State that we got $T, which refers to $A, from promisor
108         printf "$T\n" | pack_as_from_promisor &&
109
110         git -C repo config core.repositoryformatversion 1 &&
111         git -C repo config extensions.partialclone "arbitrary string" &&
112         git -C repo fsck
113 '
114
115 test_expect_success 'missing reflog object alone fails fsck, even with extension set' '
116         rm -rf repo &&
117         test_create_repo repo &&
118         test_commit -C repo my_commit &&
119
120         A=$(git -C repo commit-tree -m a HEAD^{tree}) &&
121         B=$(git -C repo commit-tree -m b HEAD^{tree}) &&
122
123         # Reference $A only from reflog, and delete it
124         git -C repo branch my_branch "$A" &&
125         git -C repo branch -f my_branch my_commit &&
126         delete_object repo "$A" &&
127
128         git -C repo config core.repositoryformatversion 1 &&
129         git -C repo config extensions.partialclone "arbitrary string" &&
130         test_must_fail git -C repo fsck
131 '
132
133 test_expect_success 'missing ref object, but promised, passes fsck' '
134         rm -rf repo &&
135         test_create_repo repo &&
136         test_commit -C repo my_commit &&
137
138         A=$(git -C repo commit-tree -m a HEAD^{tree}) &&
139
140         # Reference $A only from ref
141         git -C repo branch my_branch "$A" &&
142         promise_and_delete "$A" &&
143
144         git -C repo config core.repositoryformatversion 1 &&
145         git -C repo config extensions.partialclone "arbitrary string" &&
146         git -C repo fsck
147 '
148
149 test_expect_success 'missing object, but promised, passes fsck' '
150         rm -rf repo &&
151         test_create_repo repo &&
152         test_commit -C repo 1 &&
153         test_commit -C repo 2 &&
154         test_commit -C repo 3 &&
155         git -C repo tag -a annotated_tag -m "annotated tag" &&
156
157         C=$(git -C repo rev-parse 1) &&
158         T=$(git -C repo rev-parse 2^{tree}) &&
159         B=$(git hash-object repo/3.t) &&
160         AT=$(git -C repo rev-parse annotated_tag) &&
161
162         promise_and_delete "$C" &&
163         promise_and_delete "$T" &&
164         promise_and_delete "$B" &&
165         promise_and_delete "$AT" &&
166
167         git -C repo config core.repositoryformatversion 1 &&
168         git -C repo config extensions.partialclone "arbitrary string" &&
169         git -C repo fsck
170 '
171
172 test_expect_success 'missing CLI object, but promised, passes fsck' '
173         rm -rf repo &&
174         test_create_repo repo &&
175         test_commit -C repo my_commit &&
176
177         A=$(git -C repo commit-tree -m a HEAD^{tree}) &&
178         promise_and_delete "$A" &&
179
180         git -C repo config core.repositoryformatversion 1 &&
181         git -C repo config extensions.partialclone "arbitrary string" &&
182         git -C repo fsck "$A"
183 '
184
185 test_expect_success 'fetching of missing objects' '
186         rm -rf repo &&
187         test_create_repo server &&
188         test_commit -C server foo &&
189         git -C server repack -a -d --write-bitmap-index &&
190
191         git clone "file://$(pwd)/server" repo &&
192         HASH=$(git -C repo rev-parse foo) &&
193         rm -rf repo/.git/objects/* &&
194
195         git -C repo config core.repositoryformatversion 1 &&
196         git -C repo config extensions.partialclone "origin" &&
197         git -C repo cat-file -p "$HASH" &&
198
199         # Ensure that the .promisor file is written, and check that its
200         # associated packfile contains the object
201         ls repo/.git/objects/pack/pack-*.promisor >promisorlist &&
202         test_line_count = 1 promisorlist &&
203         IDX=$(sed "s/promisor$/idx/" promisorlist) &&
204         git verify-pack --verbose "$IDX" >out &&
205         grep "$HASH" out
206 '
207
208 test_expect_success 'fetching of missing objects works with ref-in-want enabled' '
209         # ref-in-want requires protocol version 2
210         git -C server config protocol.version 2 &&
211         git -C server config uploadpack.allowrefinwant 1 &&
212         git -C repo config protocol.version 2 &&
213
214         rm -rf repo/.git/objects/* &&
215         rm -f trace &&
216         GIT_TRACE_PACKET="$(pwd)/trace" git -C repo cat-file -p "$HASH" &&
217         grep "git< fetch=.*ref-in-want" trace
218 '
219
220 test_expect_success 'fetching of missing objects from another promisor remote' '
221         git clone "file://$(pwd)/server" server2 &&
222         test_commit -C server2 bar &&
223         git -C server2 repack -a -d --write-bitmap-index &&
224         HASH2=$(git -C server2 rev-parse bar) &&
225
226         git -C repo remote add server2 "file://$(pwd)/server2" &&
227         git -C repo config remote.server2.promisor true &&
228         git -C repo cat-file -p "$HASH2" &&
229
230         git -C repo fetch server2 &&
231         rm -rf repo/.git/objects/* &&
232         git -C repo cat-file -p "$HASH2" &&
233
234         # Ensure that the .promisor file is written, and check that its
235         # associated packfile contains the object
236         ls repo/.git/objects/pack/pack-*.promisor >promisorlist &&
237         test_line_count = 1 promisorlist &&
238         IDX=$(sed "s/promisor$/idx/" promisorlist) &&
239         git verify-pack --verbose "$IDX" >out &&
240         grep "$HASH2" out
241 '
242
243 test_expect_success 'fetching of missing objects configures a promisor remote' '
244         git clone "file://$(pwd)/server" server3 &&
245         test_commit -C server3 baz &&
246         git -C server3 repack -a -d --write-bitmap-index &&
247         HASH3=$(git -C server3 rev-parse baz) &&
248         git -C server3 config uploadpack.allowfilter 1 &&
249
250         rm repo/.git/objects/pack/pack-*.promisor &&
251
252         git -C repo remote add server3 "file://$(pwd)/server3" &&
253         git -C repo fetch --filter="blob:none" server3 $HASH3 &&
254
255         test_cmp_config -C repo true remote.server3.promisor &&
256
257         # Ensure that the .promisor file is written, and check that its
258         # associated packfile contains the object
259         ls repo/.git/objects/pack/pack-*.promisor >promisorlist &&
260         test_line_count = 1 promisorlist &&
261         IDX=$(sed "s/promisor$/idx/" promisorlist) &&
262         git verify-pack --verbose "$IDX" >out &&
263         grep "$HASH3" out
264 '
265
266 test_expect_success 'fetching of missing blobs works' '
267         rm -rf server server2 repo &&
268         rm -rf server server3 repo &&
269         test_create_repo server &&
270         test_commit -C server foo &&
271         git -C server repack -a -d --write-bitmap-index &&
272
273         git clone "file://$(pwd)/server" repo &&
274         git hash-object repo/foo.t >blobhash &&
275         rm -rf repo/.git/objects/* &&
276
277         git -C server config uploadpack.allowanysha1inwant 1 &&
278         git -C server config uploadpack.allowfilter 1 &&
279         git -C repo config core.repositoryformatversion 1 &&
280         git -C repo config extensions.partialclone "origin" &&
281
282         git -C repo cat-file -p $(cat blobhash)
283 '
284
285 test_expect_success 'fetching of missing trees does not fetch blobs' '
286         rm -rf server repo &&
287         test_create_repo server &&
288         test_commit -C server foo &&
289         git -C server repack -a -d --write-bitmap-index &&
290
291         git clone "file://$(pwd)/server" repo &&
292         git -C repo rev-parse foo^{tree} >treehash &&
293         git hash-object repo/foo.t >blobhash &&
294         rm -rf repo/.git/objects/* &&
295
296         git -C server config uploadpack.allowanysha1inwant 1 &&
297         git -C server config uploadpack.allowfilter 1 &&
298         git -C repo config core.repositoryformatversion 1 &&
299         git -C repo config extensions.partialclone "origin" &&
300         git -C repo cat-file -p $(cat treehash) &&
301
302         # Ensure that the tree, but not the blob, is fetched
303         git -C repo rev-list --objects --missing=print $(cat treehash) >objects &&
304         grep "^$(cat treehash)" objects &&
305         grep "^[?]$(cat blobhash)" objects
306 '
307
308 test_expect_success 'rev-list stops traversal at missing and promised commit' '
309         rm -rf repo &&
310         test_create_repo repo &&
311         test_commit -C repo foo &&
312         test_commit -C repo bar &&
313
314         FOO=$(git -C repo rev-parse foo) &&
315         promise_and_delete "$FOO" &&
316
317         git -C repo config core.repositoryformatversion 1 &&
318         git -C repo config extensions.partialclone "arbitrary string" &&
319         GIT_TEST_COMMIT_GRAPH=0 git -C repo -c core.commitGraph=false rev-list --exclude-promisor-objects --objects bar >out &&
320         grep $(git -C repo rev-parse bar) out &&
321         ! grep $FOO out
322 '
323
324 test_expect_success 'missing tree objects with --missing=allow-promisor and --exclude-promisor-objects' '
325         rm -rf repo &&
326         test_create_repo repo &&
327         test_commit -C repo foo &&
328         test_commit -C repo bar &&
329         test_commit -C repo baz &&
330
331         promise_and_delete $(git -C repo rev-parse bar^{tree}) &&
332         promise_and_delete $(git -C repo rev-parse foo^{tree}) &&
333
334         git -C repo config core.repositoryformatversion 1 &&
335         git -C repo config extensions.partialclone "arbitrary string" &&
336
337         git -C repo rev-list --missing=allow-promisor --objects HEAD >objs 2>rev_list_err &&
338         test_must_be_empty rev_list_err &&
339         # 3 commits, 3 blobs, and 1 tree
340         test_line_count = 7 objs &&
341
342         # Do the same for --exclude-promisor-objects, but with all trees gone.
343         promise_and_delete $(git -C repo rev-parse baz^{tree}) &&
344         git -C repo rev-list --exclude-promisor-objects --objects HEAD >objs 2>rev_list_err &&
345         test_must_be_empty rev_list_err &&
346         # 3 commits, no blobs or trees
347         test_line_count = 3 objs
348 '
349
350 test_expect_success 'missing non-root tree object and rev-list' '
351         rm -rf repo &&
352         test_create_repo repo &&
353         mkdir repo/dir &&
354         echo foo >repo/dir/foo &&
355         git -C repo add dir/foo &&
356         git -C repo commit -m "commit dir/foo" &&
357
358         promise_and_delete $(git -C repo rev-parse HEAD:dir) &&
359
360         git -C repo config core.repositoryformatversion 1 &&
361         git -C repo config extensions.partialclone "arbitrary string" &&
362
363         git -C repo rev-list --missing=allow-any --objects HEAD >objs 2>rev_list_err &&
364         test_must_be_empty rev_list_err &&
365         # 1 commit and 1 tree
366         test_line_count = 2 objs
367 '
368
369 test_expect_success 'rev-list stops traversal at missing and promised tree' '
370         rm -rf repo &&
371         test_create_repo repo &&
372         test_commit -C repo foo &&
373         mkdir repo/a_dir &&
374         echo something >repo/a_dir/something &&
375         git -C repo add a_dir/something &&
376         git -C repo commit -m bar &&
377
378         # foo^{tree} (tree referenced from commit)
379         TREE=$(git -C repo rev-parse foo^{tree}) &&
380
381         # a tree referenced by HEAD^{tree} (tree referenced from tree)
382         TREE2=$(git -C repo ls-tree HEAD^{tree} | grep " tree " | head -1 | cut -b13-52) &&
383
384         promise_and_delete "$TREE" &&
385         promise_and_delete "$TREE2" &&
386
387         git -C repo config core.repositoryformatversion 1 &&
388         git -C repo config extensions.partialclone "arbitrary string" &&
389         git -C repo rev-list --exclude-promisor-objects --objects HEAD >out &&
390         grep $(git -C repo rev-parse foo) out &&
391         ! grep $TREE out &&
392         grep $(git -C repo rev-parse HEAD) out &&
393         ! grep $TREE2 out
394 '
395
396 test_expect_success 'rev-list stops traversal at missing and promised blob' '
397         rm -rf repo &&
398         test_create_repo repo &&
399         echo something >repo/something &&
400         git -C repo add something &&
401         git -C repo commit -m foo &&
402
403         BLOB=$(git -C repo hash-object -w something) &&
404         promise_and_delete "$BLOB" &&
405
406         git -C repo config core.repositoryformatversion 1 &&
407         git -C repo config extensions.partialclone "arbitrary string" &&
408         git -C repo rev-list --exclude-promisor-objects --objects HEAD >out &&
409         grep $(git -C repo rev-parse HEAD) out &&
410         ! grep $BLOB out
411 '
412
413 test_expect_success 'rev-list stops traversal at promisor commit, tree, and blob' '
414         rm -rf repo &&
415         test_create_repo repo &&
416         test_commit -C repo foo &&
417         test_commit -C repo bar &&
418         test_commit -C repo baz &&
419
420         COMMIT=$(git -C repo rev-parse foo) &&
421         TREE=$(git -C repo rev-parse bar^{tree}) &&
422         BLOB=$(git hash-object repo/baz.t) &&
423         printf "%s\n%s\n%s\n" $COMMIT $TREE $BLOB | pack_as_from_promisor &&
424
425         git -C repo config core.repositoryformatversion 1 &&
426         git -C repo config extensions.partialclone "arbitrary string" &&
427         git -C repo rev-list --exclude-promisor-objects --objects HEAD >out &&
428         ! grep $COMMIT out &&
429         ! grep $TREE out &&
430         ! grep $BLOB out &&
431         grep $(git -C repo rev-parse bar) out  # sanity check that some walking was done
432 '
433
434 test_expect_success 'rev-list dies for missing objects on cmd line' '
435         rm -rf repo &&
436         test_create_repo repo &&
437         test_commit -C repo foo &&
438         test_commit -C repo bar &&
439         test_commit -C repo baz &&
440
441         COMMIT=$(git -C repo rev-parse foo) &&
442         TREE=$(git -C repo rev-parse bar^{tree}) &&
443         BLOB=$(git hash-object repo/baz.t) &&
444
445         promise_and_delete $COMMIT &&
446         promise_and_delete $TREE &&
447         promise_and_delete $BLOB &&
448
449         git -C repo config core.repositoryformatversion 1 &&
450         git -C repo config extensions.partialclone "arbitrary string" &&
451
452         for OBJ in "$COMMIT" "$TREE" "$BLOB"; do
453                 test_must_fail git -C repo rev-list --objects \
454                         --exclude-promisor-objects "$OBJ" &&
455                 test_must_fail git -C repo rev-list --objects-edge-aggressive \
456                         --exclude-promisor-objects "$OBJ" &&
457
458                 # Do not die or crash when --ignore-missing is passed.
459                 git -C repo rev-list --ignore-missing --objects \
460                         --exclude-promisor-objects "$OBJ" &&
461                 git -C repo rev-list --ignore-missing --objects-edge-aggressive \
462                         --exclude-promisor-objects "$OBJ"
463         done
464 '
465
466 test_expect_success 'single promisor remote can be re-initialized gracefully' '
467         # ensure one promisor is in the promisors list
468         rm -rf repo &&
469         test_create_repo repo &&
470         test_create_repo other &&
471         git -C repo remote add foo "file://$(pwd)/other" &&
472         git -C repo config remote.foo.promisor true &&
473         git -C repo config extensions.partialclone foo &&
474
475         # reinitialize the promisors list
476         git -C repo fetch --filter=blob:none foo
477 '
478
479 test_expect_success 'gc repacks promisor objects separately from non-promisor objects' '
480         rm -rf repo &&
481         test_create_repo repo &&
482         test_commit -C repo one &&
483         test_commit -C repo two &&
484
485         TREE_ONE=$(git -C repo rev-parse one^{tree}) &&
486         printf "$TREE_ONE\n" | pack_as_from_promisor &&
487         TREE_TWO=$(git -C repo rev-parse two^{tree}) &&
488         printf "$TREE_TWO\n" | pack_as_from_promisor &&
489
490         git -C repo config core.repositoryformatversion 1 &&
491         git -C repo config extensions.partialclone "arbitrary string" &&
492         git -C repo gc &&
493
494         # Ensure that exactly one promisor packfile exists, and that it
495         # contains the trees but not the commits
496         ls repo/.git/objects/pack/pack-*.promisor >promisorlist &&
497         test_line_count = 1 promisorlist &&
498         PROMISOR_PACKFILE=$(sed "s/.promisor/.pack/" <promisorlist) &&
499         git verify-pack $PROMISOR_PACKFILE -v >out &&
500         grep "$TREE_ONE" out &&
501         grep "$TREE_TWO" out &&
502         ! grep "$(git -C repo rev-parse one)" out &&
503         ! grep "$(git -C repo rev-parse two)" out &&
504
505         # Remove the promisor packfile and associated files
506         rm $(sed "s/.promisor//" <promisorlist).* &&
507
508         # Ensure that the single other pack contains the commits, but not the
509         # trees
510         ls repo/.git/objects/pack/pack-*.pack >packlist &&
511         test_line_count = 1 packlist &&
512         git verify-pack repo/.git/objects/pack/pack-*.pack -v >out &&
513         grep "$(git -C repo rev-parse one)" out &&
514         grep "$(git -C repo rev-parse two)" out &&
515         ! grep "$TREE_ONE" out &&
516         ! grep "$TREE_TWO" out
517 '
518
519 test_expect_success 'gc does not repack promisor objects if there are none' '
520         rm -rf repo &&
521         test_create_repo repo &&
522         test_commit -C repo one &&
523
524         git -C repo config core.repositoryformatversion 1 &&
525         git -C repo config extensions.partialclone "arbitrary string" &&
526         git -C repo gc &&
527
528         # Ensure that only one pack exists
529         ls repo/.git/objects/pack/pack-*.pack >packlist &&
530         test_line_count = 1 packlist
531 '
532
533 repack_and_check () {
534         rm -rf repo2 &&
535         cp -r repo repo2 &&
536         git -C repo2 repack $1 -d &&
537         git -C repo2 fsck &&
538
539         git -C repo2 cat-file -e $2 &&
540         git -C repo2 cat-file -e $3
541 }
542
543 test_expect_success 'repack -d does not irreversibly delete promisor objects' '
544         rm -rf repo &&
545         test_create_repo repo &&
546         git -C repo config core.repositoryformatversion 1 &&
547         git -C repo config extensions.partialclone "arbitrary string" &&
548
549         git -C repo commit --allow-empty -m one &&
550         git -C repo commit --allow-empty -m two &&
551         git -C repo commit --allow-empty -m three &&
552         git -C repo commit --allow-empty -m four &&
553         ONE=$(git -C repo rev-parse HEAD^^^) &&
554         TWO=$(git -C repo rev-parse HEAD^^) &&
555         THREE=$(git -C repo rev-parse HEAD^) &&
556
557         printf "$TWO\n" | pack_as_from_promisor &&
558         printf "$THREE\n" | pack_as_from_promisor &&
559         delete_object repo "$ONE" &&
560
561         repack_and_check -a "$TWO" "$THREE" &&
562         repack_and_check -A "$TWO" "$THREE" &&
563         repack_and_check -l "$TWO" "$THREE"
564 '
565
566 test_expect_success 'gc stops traversal when a missing but promised object is reached' '
567         rm -rf repo &&
568         test_create_repo repo &&
569         test_commit -C repo my_commit &&
570
571         TREE_HASH=$(git -C repo rev-parse HEAD^{tree}) &&
572         HASH=$(promise_and_delete $TREE_HASH) &&
573
574         git -C repo config core.repositoryformatversion 1 &&
575         git -C repo config extensions.partialclone "arbitrary string" &&
576         git -C repo gc &&
577
578         # Ensure that the promisor packfile still exists, and remove it
579         test -e repo/.git/objects/pack/pack-$HASH.pack &&
580         rm repo/.git/objects/pack/pack-$HASH.* &&
581
582         # Ensure that the single other pack contains the commit, but not the tree
583         ls repo/.git/objects/pack/pack-*.pack >packlist &&
584         test_line_count = 1 packlist &&
585         git verify-pack repo/.git/objects/pack/pack-*.pack -v >out &&
586         grep "$(git -C repo rev-parse HEAD)" out &&
587         ! grep "$TREE_HASH" out
588 '
589
590 test_expect_success 'do not fetch when checking existence of tree we construct ourselves' '
591         rm -rf repo &&
592         test_create_repo repo &&
593         test_commit -C repo base &&
594         test_commit -C repo side1 &&
595         git -C repo checkout base &&
596         test_commit -C repo side2 &&
597
598         git -C repo config core.repositoryformatversion 1 &&
599         git -C repo config extensions.partialclone "arbitrary string" &&
600
601         git -C repo cherry-pick side1
602 '
603
604 . "$TEST_DIRECTORY"/lib-httpd.sh
605 start_httpd
606
607 test_expect_success 'fetching of missing objects from an HTTP server' '
608         rm -rf repo &&
609         SERVER="$HTTPD_DOCUMENT_ROOT_PATH/server" &&
610         test_create_repo "$SERVER" &&
611         test_commit -C "$SERVER" foo &&
612         git -C "$SERVER" repack -a -d --write-bitmap-index &&
613
614         git clone $HTTPD_URL/smart/server repo &&
615         HASH=$(git -C repo rev-parse foo) &&
616         rm -rf repo/.git/objects/* &&
617
618         git -C repo config core.repositoryformatversion 1 &&
619         git -C repo config extensions.partialclone "origin" &&
620         git -C repo cat-file -p "$HASH" &&
621
622         # Ensure that the .promisor file is written, and check that its
623         # associated packfile contains the object
624         ls repo/.git/objects/pack/pack-*.promisor >promisorlist &&
625         test_line_count = 1 promisorlist &&
626         IDX=$(sed "s/promisor$/idx/" promisorlist) &&
627         git verify-pack --verbose "$IDX" >out &&
628         grep "$HASH" out
629 '
630
631 # DO NOT add non-httpd-specific tests here, because the last part of this
632 # test script is only executed when httpd is available and enabled.
633
634 test_done