3 test_description
='partial clone'
7 # missing promisor objects cause repacks which write bitmaps to fail
8 GIT_TEST_MULTI_PACK_INDEX_WRITE_BITMAP
=0
9 # When enabled, some commands will write commit-graphs. This causes fsck
10 # to fail when delete_object() is called because fsck will attempt to
11 # verify the out-of-sync commit graph.
12 GIT_TEST_COMMIT_GRAPH
=0
15 rm $1/.git
/objects
/$
(echo $2 |
sed -e 's|^..|&/|')
18 pack_as_from_promisor
() {
19 HASH
=$
(git
-C repo pack-objects .git
/objects
/pack
/pack
) &&
20 >repo
/.git
/objects
/pack
/pack-
$HASH.promisor
&&
24 promise_and_delete
() {
25 HASH
=$
(git
-C repo rev-parse
"$1") &&
26 git
-C repo tag
-a -m message my_annotated_tag
"$HASH" &&
27 git
-C repo rev-parse my_annotated_tag | pack_as_from_promisor
&&
28 # tag -d prints a message to stdout, so redirect it
29 git
-C repo tag
-d my_annotated_tag
>/dev
/null
&&
30 delete_object repo
"$HASH"
33 test_expect_success
'extensions.partialclone without filter' '
34 test_create_repo server &&
35 git clone --filter="blob:none" "file://$(pwd)/server" client &&
36 git -C client config --unset remote.origin.partialclonefilter &&
37 git -C client fetch origin
40 test_expect_success
'convert shallow clone to partial clone' '
41 rm -fr server client &&
42 test_create_repo server &&
43 test_commit -C server my_commit 1 &&
44 test_commit -C server my_commit2 1 &&
45 git clone --depth=1 "file://$(pwd)/server" client &&
46 git -C client fetch --unshallow --filter="blob:none" &&
47 test_cmp_config -C client true remote.origin.promisor &&
48 test_cmp_config -C client blob:none remote.origin.partialclonefilter &&
49 test_cmp_config -C client 1 core.repositoryformatversion
52 test_expect_success SHA1
'convert to partial clone with noop extension' '
53 rm -fr server client &&
54 test_create_repo server &&
55 test_commit -C server my_commit 1 &&
56 test_commit -C server my_commit2 1 &&
57 git clone --depth=1 "file://$(pwd)/server" client &&
58 test_cmp_config -C client 0 core.repositoryformatversion &&
59 git -C client config extensions.noop true &&
60 git -C client fetch --unshallow --filter="blob:none"
63 test_expect_success SHA1
'converting to partial clone fails with unrecognized extension' '
64 rm -fr server client &&
65 test_create_repo server &&
66 test_commit -C server my_commit 1 &&
67 test_commit -C server my_commit2 1 &&
68 git clone --depth=1 "file://$(pwd)/server" client &&
69 test_cmp_config -C client 0 core.repositoryformatversion &&
70 git -C client config extensions.nonsense true &&
71 test_must_fail git -C client fetch --unshallow --filter="blob:none"
74 test_expect_success
'missing reflog object, but promised by a commit, passes fsck' '
76 test_create_repo repo &&
77 test_commit -C repo my_commit &&
79 A=$(git -C repo commit-tree -m a HEAD^{tree}) &&
80 C=$(git -C repo commit-tree -m c -p $A HEAD^{tree}) &&
82 # Reference $A only from reflog, and delete it
83 git -C repo branch my_branch "$A" &&
84 git -C repo branch -f my_branch my_commit &&
85 delete_object repo "$A" &&
87 # State that we got $C, which refers to $A, from promisor
88 printf "$C\n" | pack_as_from_promisor &&
91 test_must_fail git -C repo fsck &&
93 # But with the extension, it succeeds
94 git -C repo config core.repositoryformatversion 1 &&
95 git -C repo config extensions.partialclone "arbitrary string" &&
99 test_expect_success
'missing reflog object, but promised by a tag, passes fsck' '
101 test_create_repo repo &&
102 test_commit -C repo my_commit &&
104 A=$(git -C repo commit-tree -m a HEAD^{tree}) &&
105 git -C repo tag -a -m d my_tag_name $A &&
106 T=$(git -C repo rev-parse my_tag_name) &&
107 git -C repo tag -d my_tag_name &&
109 # Reference $A only from reflog, and delete it
110 git -C repo branch my_branch "$A" &&
111 git -C repo branch -f my_branch my_commit &&
112 delete_object repo "$A" &&
114 # State that we got $T, which refers to $A, from promisor
115 printf "$T\n" | pack_as_from_promisor &&
117 git -C repo config core.repositoryformatversion 1 &&
118 git -C repo config extensions.partialclone "arbitrary string" &&
122 test_expect_success
'missing reflog object alone fails fsck, even with extension set' '
124 test_create_repo repo &&
125 test_commit -C repo my_commit &&
127 A=$(git -C repo commit-tree -m a HEAD^{tree}) &&
128 B=$(git -C repo commit-tree -m b HEAD^{tree}) &&
130 # Reference $A only from reflog, and delete it
131 git -C repo branch my_branch "$A" &&
132 git -C repo branch -f my_branch my_commit &&
133 delete_object repo "$A" &&
135 git -C repo config core.repositoryformatversion 1 &&
136 git -C repo config extensions.partialclone "arbitrary string" &&
137 test_must_fail git -C repo fsck
140 test_expect_success
'missing ref object, but promised, passes fsck' '
142 test_create_repo repo &&
143 test_commit -C repo my_commit &&
145 A=$(git -C repo commit-tree -m a HEAD^{tree}) &&
147 # Reference $A only from ref
148 git -C repo branch my_branch "$A" &&
149 promise_and_delete "$A" &&
151 git -C repo config core.repositoryformatversion 1 &&
152 git -C repo config extensions.partialclone "arbitrary string" &&
156 test_expect_success
'missing object, but promised, passes fsck' '
158 test_create_repo repo &&
159 test_commit -C repo 1 &&
160 test_commit -C repo 2 &&
161 test_commit -C repo 3 &&
162 git -C repo tag -a annotated_tag -m "annotated tag" &&
164 C=$(git -C repo rev-parse 1) &&
165 T=$(git -C repo rev-parse 2^{tree}) &&
166 B=$(git hash-object repo/3.t) &&
167 AT=$(git -C repo rev-parse annotated_tag) &&
169 promise_and_delete "$C" &&
170 promise_and_delete "$T" &&
171 promise_and_delete "$B" &&
172 promise_and_delete "$AT" &&
174 git -C repo config core.repositoryformatversion 1 &&
175 git -C repo config extensions.partialclone "arbitrary string" &&
179 test_expect_success
'missing CLI object, but promised, passes fsck' '
181 test_create_repo repo &&
182 test_commit -C repo my_commit &&
184 A=$(git -C repo commit-tree -m a HEAD^{tree}) &&
185 promise_and_delete "$A" &&
187 git -C repo config core.repositoryformatversion 1 &&
188 git -C repo config extensions.partialclone "arbitrary string" &&
189 git -C repo fsck "$A"
192 test_expect_success
'fetching of missing objects' '
194 test_create_repo server &&
195 test_commit -C server foo &&
196 git -C server repack -a -d --write-bitmap-index &&
198 git clone "file://$(pwd)/server" repo &&
199 HASH=$(git -C repo rev-parse foo) &&
200 rm -rf repo/.git/objects/* &&
202 git -C repo config core.repositoryformatversion 1 &&
203 git -C repo config extensions.partialclone "origin" &&
204 git -C repo cat-file -p "$HASH" 2>err &&
206 # Ensure that no spurious FETCH_HEAD messages are written
207 ! grep FETCH_HEAD err &&
209 # Ensure that the .promisor file is written, and check that its
210 # associated packfile contains the object
211 ls repo/.git/objects/pack/pack-*.promisor >promisorlist &&
212 test_line_count = 1 promisorlist &&
213 IDX=$(sed "s/promisor$/idx/" promisorlist) &&
214 git verify-pack --verbose "$IDX" >out &&
218 test_expect_success
'fetching of a promised object that promisor remote no longer has' '
220 test_create_repo unreliable-server &&
221 git -C unreliable-server config uploadpack.allowanysha1inwant 1 &&
222 git -C unreliable-server config uploadpack.allowfilter 1 &&
223 test_commit -C unreliable-server foo &&
225 git clone --filter=blob:none --no-checkout "file://$(pwd)/unreliable-server" unreliable-client &&
227 rm -rf unreliable-server/.git/objects/* &&
228 test_must_fail git -C unreliable-client checkout HEAD 2>err &&
229 grep "could not fetch.*from promisor remote" err
232 test_expect_success
'fetching of missing objects works with ref-in-want enabled' '
233 # ref-in-want requires protocol version 2
234 git -C server config protocol.version 2 &&
235 git -C server config uploadpack.allowrefinwant 1 &&
236 git -C repo config protocol.version 2 &&
238 rm -rf repo/.git/objects/* &&
240 GIT_TRACE_PACKET="$(pwd)/trace" git -C repo cat-file -p "$HASH" &&
241 grep "fetch< fetch=.*ref-in-want" trace
244 test_expect_success
'fetching of missing objects from another promisor remote' '
245 git clone "file://$(pwd)/server" server2 &&
246 test_commit -C server2 bar &&
247 git -C server2 repack -a -d --write-bitmap-index &&
248 HASH2=$(git -C server2 rev-parse bar) &&
250 git -C repo remote add server2 "file://$(pwd)/server2" &&
251 git -C repo config remote.server2.promisor true &&
252 git -C repo cat-file -p "$HASH2" &&
254 git -C repo fetch server2 &&
255 rm -rf repo/.git/objects/* &&
256 git -C repo cat-file -p "$HASH2" &&
258 # Ensure that the .promisor file is written, and check that its
259 # associated packfile contains the object
260 ls repo/.git/objects/pack/pack-*.promisor >promisorlist &&
261 test_line_count = 1 promisorlist &&
262 IDX=$(sed "s/promisor$/idx/" promisorlist) &&
263 git verify-pack --verbose "$IDX" >out &&
267 test_expect_success
'fetching of missing objects configures a promisor remote' '
268 git clone "file://$(pwd)/server" server3 &&
269 test_commit -C server3 baz &&
270 git -C server3 repack -a -d --write-bitmap-index &&
271 HASH3=$(git -C server3 rev-parse baz) &&
272 git -C server3 config uploadpack.allowfilter 1 &&
274 rm repo/.git/objects/pack/pack-*.promisor &&
276 git -C repo remote add server3 "file://$(pwd)/server3" &&
277 git -C repo fetch --filter="blob:none" server3 $HASH3 &&
279 test_cmp_config -C repo true remote.server3.promisor &&
281 # Ensure that the .promisor file is written, and check that its
282 # associated packfile contains the object
283 ls repo/.git/objects/pack/pack-*.promisor >promisorlist &&
284 test_line_count = 1 promisorlist &&
285 IDX=$(sed "s/promisor$/idx/" promisorlist) &&
286 git verify-pack --verbose "$IDX" >out &&
290 test_expect_success
'fetching of missing blobs works' '
291 rm -rf server server2 repo &&
292 rm -rf server server3 repo &&
293 test_create_repo server &&
294 test_commit -C server foo &&
295 git -C server repack -a -d --write-bitmap-index &&
297 git clone "file://$(pwd)/server" repo &&
298 git hash-object repo/foo.t >blobhash &&
299 rm -rf repo/.git/objects/* &&
301 git -C server config uploadpack.allowanysha1inwant 1 &&
302 git -C server config uploadpack.allowfilter 1 &&
303 git -C repo config core.repositoryformatversion 1 &&
304 git -C repo config extensions.partialclone "origin" &&
306 git -C repo cat-file -p $(cat blobhash)
309 test_expect_success
'fetching of missing trees does not fetch blobs' '
310 rm -rf server repo &&
311 test_create_repo server &&
312 test_commit -C server foo &&
313 git -C server repack -a -d --write-bitmap-index &&
315 git clone "file://$(pwd)/server" repo &&
316 git -C repo rev-parse foo^{tree} >treehash &&
317 git hash-object repo/foo.t >blobhash &&
318 rm -rf repo/.git/objects/* &&
320 git -C server config uploadpack.allowanysha1inwant 1 &&
321 git -C server config uploadpack.allowfilter 1 &&
322 git -C repo config core.repositoryformatversion 1 &&
323 git -C repo config extensions.partialclone "origin" &&
324 git -C repo cat-file -p $(cat treehash) &&
326 # Ensure that the tree, but not the blob, is fetched
327 git -C repo rev-list --objects --missing=print $(cat treehash) >objects &&
328 grep "^$(cat treehash)" objects &&
329 grep "^[?]$(cat blobhash)" objects
332 test_expect_success
'rev-list stops traversal at missing and promised commit' '
334 test_create_repo repo &&
335 test_commit -C repo foo &&
336 test_commit -C repo bar &&
338 FOO=$(git -C repo rev-parse foo) &&
339 promise_and_delete "$FOO" &&
341 git -C repo config core.repositoryformatversion 1 &&
342 git -C repo config extensions.partialclone "arbitrary string" &&
343 git -C repo rev-list --exclude-promisor-objects --objects bar >out &&
344 grep $(git -C repo rev-parse bar) out &&
348 test_expect_success
'missing tree objects with --missing=allow-promisor and --exclude-promisor-objects' '
350 test_create_repo repo &&
351 test_commit -C repo foo &&
352 test_commit -C repo bar &&
353 test_commit -C repo baz &&
355 promise_and_delete $(git -C repo rev-parse bar^{tree}) &&
356 promise_and_delete $(git -C repo rev-parse foo^{tree}) &&
358 git -C repo config core.repositoryformatversion 1 &&
359 git -C repo config extensions.partialclone "arbitrary string" &&
361 git -C repo rev-list --missing=allow-promisor --objects HEAD >objs 2>rev_list_err &&
362 test_must_be_empty rev_list_err &&
363 # 3 commits, 3 blobs, and 1 tree
364 test_line_count = 7 objs &&
366 # Do the same for --exclude-promisor-objects, but with all trees gone.
367 promise_and_delete $(git -C repo rev-parse baz^{tree}) &&
368 git -C repo rev-list --exclude-promisor-objects --objects HEAD >objs 2>rev_list_err &&
369 test_must_be_empty rev_list_err &&
370 # 3 commits, no blobs or trees
371 test_line_count = 3 objs
374 test_expect_success
'missing non-root tree object and rev-list' '
376 test_create_repo repo &&
378 echo foo >repo/dir/foo &&
379 git -C repo add dir/foo &&
380 git -C repo commit -m "commit dir/foo" &&
382 promise_and_delete $(git -C repo rev-parse HEAD:dir) &&
384 git -C repo config core.repositoryformatversion 1 &&
385 git -C repo config extensions.partialclone "arbitrary string" &&
387 git -C repo rev-list --missing=allow-any --objects HEAD >objs 2>rev_list_err &&
388 test_must_be_empty rev_list_err &&
389 # 1 commit and 1 tree
390 test_line_count = 2 objs
393 test_expect_success
'rev-list stops traversal at missing and promised tree' '
395 test_create_repo repo &&
396 test_commit -C repo foo &&
398 echo something >repo/a_dir/something &&
399 git -C repo add a_dir/something &&
400 git -C repo commit -m bar &&
402 # foo^{tree} (tree referenced from commit)
403 TREE=$(git -C repo rev-parse foo^{tree}) &&
405 # a tree referenced by HEAD^{tree} (tree referenced from tree)
406 TREE2=$(git -C repo ls-tree HEAD^{tree} | grep " tree " | head -1 | cut -b13-52) &&
408 promise_and_delete "$TREE" &&
409 promise_and_delete "$TREE2" &&
411 git -C repo config core.repositoryformatversion 1 &&
412 git -C repo config extensions.partialclone "arbitrary string" &&
413 git -C repo rev-list --exclude-promisor-objects --objects HEAD >out &&
414 grep $(git -C repo rev-parse foo) out &&
416 grep $(git -C repo rev-parse HEAD) out &&
420 test_expect_success
'rev-list stops traversal at missing and promised blob' '
422 test_create_repo repo &&
423 echo something >repo/something &&
424 git -C repo add something &&
425 git -C repo commit -m foo &&
427 BLOB=$(git -C repo hash-object -w something) &&
428 promise_and_delete "$BLOB" &&
430 git -C repo config core.repositoryformatversion 1 &&
431 git -C repo config extensions.partialclone "arbitrary string" &&
432 git -C repo rev-list --exclude-promisor-objects --objects HEAD >out &&
433 grep $(git -C repo rev-parse HEAD) out &&
437 test_expect_success
'rev-list stops traversal at promisor commit, tree, and blob' '
439 test_create_repo repo &&
440 test_commit -C repo foo &&
441 test_commit -C repo bar &&
442 test_commit -C repo baz &&
444 COMMIT=$(git -C repo rev-parse foo) &&
445 TREE=$(git -C repo rev-parse bar^{tree}) &&
446 BLOB=$(git hash-object repo/baz.t) &&
447 printf "%s\n%s\n%s\n" $COMMIT $TREE $BLOB | pack_as_from_promisor &&
449 git -C repo config core.repositoryformatversion 1 &&
450 git -C repo config extensions.partialclone "arbitrary string" &&
451 git -C repo rev-list --exclude-promisor-objects --objects HEAD >out &&
452 ! grep $COMMIT out &&
455 grep $(git -C repo rev-parse bar) out # sanity check that some walking was done
458 test_expect_success
'rev-list dies for missing objects on cmd line' '
460 test_create_repo repo &&
461 test_commit -C repo foo &&
462 test_commit -C repo bar &&
463 test_commit -C repo baz &&
465 COMMIT=$(git -C repo rev-parse foo) &&
466 TREE=$(git -C repo rev-parse bar^{tree}) &&
467 BLOB=$(git hash-object repo/baz.t) &&
469 promise_and_delete $COMMIT &&
470 promise_and_delete $TREE &&
471 promise_and_delete $BLOB &&
473 git -C repo config core.repositoryformatversion 1 &&
474 git -C repo config extensions.partialclone "arbitrary string" &&
476 for OBJ in "$COMMIT" "$TREE" "$BLOB"; do
477 test_must_fail git -C repo rev-list --objects \
478 --exclude-promisor-objects "$OBJ" &&
479 test_must_fail git -C repo rev-list --objects-edge-aggressive \
480 --exclude-promisor-objects "$OBJ" &&
482 # Do not die or crash when --ignore-missing is passed.
483 git -C repo rev-list --ignore-missing --objects \
484 --exclude-promisor-objects "$OBJ" &&
485 git -C repo rev-list --ignore-missing --objects-edge-aggressive \
486 --exclude-promisor-objects "$OBJ" || return 1
490 test_expect_success
'single promisor remote can be re-initialized gracefully' '
491 # ensure one promisor is in the promisors list
493 test_create_repo repo &&
494 test_create_repo other &&
495 git -C repo remote add foo "file://$(pwd)/other" &&
496 git -C repo config remote.foo.promisor true &&
497 git -C repo config extensions.partialclone foo &&
499 # reinitialize the promisors list
500 git -C repo fetch --filter=blob:none foo
503 test_expect_success
'gc repacks promisor objects separately from non-promisor objects' '
505 test_create_repo repo &&
506 test_commit -C repo one &&
507 test_commit -C repo two &&
509 TREE_ONE=$(git -C repo rev-parse one^{tree}) &&
510 printf "$TREE_ONE\n" | pack_as_from_promisor &&
511 TREE_TWO=$(git -C repo rev-parse two^{tree}) &&
512 printf "$TREE_TWO\n" | pack_as_from_promisor &&
514 git -C repo config core.repositoryformatversion 1 &&
515 git -C repo config extensions.partialclone "arbitrary string" &&
518 # Ensure that exactly one promisor packfile exists, and that it
519 # contains the trees but not the commits
520 ls repo/.git/objects/pack/pack-*.promisor >promisorlist &&
521 test_line_count = 1 promisorlist &&
522 PROMISOR_PACKFILE=$(sed "s/.promisor/.pack/" <promisorlist) &&
523 git verify-pack $PROMISOR_PACKFILE -v >out &&
524 grep "$TREE_ONE" out &&
525 grep "$TREE_TWO" out &&
526 ! grep "$(git -C repo rev-parse one)" out &&
527 ! grep "$(git -C repo rev-parse two)" out &&
529 # Remove the promisor packfile and associated files
530 rm $(sed "s/.promisor//" <promisorlist).* &&
532 # Ensure that the single other pack contains the commits, but not the
534 ls repo/.git/objects/pack/pack-*.pack >packlist &&
535 test_line_count = 1 packlist &&
536 git verify-pack repo/.git/objects/pack/pack-*.pack -v >out &&
537 grep "$(git -C repo rev-parse one)" out &&
538 grep "$(git -C repo rev-parse two)" out &&
539 ! grep "$TREE_ONE" out &&
540 ! grep "$TREE_TWO" out
543 test_expect_success
'gc does not repack promisor objects if there are none' '
545 test_create_repo repo &&
546 test_commit -C repo one &&
548 git -C repo config core.repositoryformatversion 1 &&
549 git -C repo config extensions.partialclone "arbitrary string" &&
552 # Ensure that only one pack exists
553 ls repo/.git/objects/pack/pack-*.pack >packlist &&
554 test_line_count = 1 packlist
557 repack_and_check
() {
560 if test x
"$1" = "x--must-fail"
563 test_must_fail git
-C repo2 repack
$1 -d
565 git
-C repo2 repack
$1 -d
569 git
-C repo2 cat-file
-e $2 &&
570 git
-C repo2 cat-file
-e $3
573 test_expect_success
'repack -d does not irreversibly delete promisor objects' '
575 test_create_repo repo &&
576 git -C repo config core.repositoryformatversion 1 &&
577 git -C repo config extensions.partialclone "arbitrary string" &&
579 git -C repo commit --allow-empty -m one &&
580 git -C repo commit --allow-empty -m two &&
581 git -C repo commit --allow-empty -m three &&
582 git -C repo commit --allow-empty -m four &&
583 ONE=$(git -C repo rev-parse HEAD^^^) &&
584 TWO=$(git -C repo rev-parse HEAD^^) &&
585 THREE=$(git -C repo rev-parse HEAD^) &&
587 printf "$TWO\n" | pack_as_from_promisor &&
588 printf "$THREE\n" | pack_as_from_promisor &&
589 delete_object repo "$ONE" &&
591 repack_and_check --must-fail -ab "$TWO" "$THREE" &&
592 repack_and_check -a "$TWO" "$THREE" &&
593 repack_and_check -A "$TWO" "$THREE" &&
594 repack_and_check -l "$TWO" "$THREE"
597 test_expect_success
'gc stops traversal when a missing but promised object is reached' '
599 test_create_repo repo &&
600 test_commit -C repo my_commit &&
602 TREE_HASH=$(git -C repo rev-parse HEAD^{tree}) &&
603 HASH=$(promise_and_delete $TREE_HASH) &&
605 git -C repo config core.repositoryformatversion 1 &&
606 git -C repo config extensions.partialclone "arbitrary string" &&
609 # Ensure that the promisor packfile still exists, and remove it
610 test -e repo/.git/objects/pack/pack-$HASH.pack &&
611 rm repo/.git/objects/pack/pack-$HASH.* &&
613 # Ensure that the single other pack contains the commit, but not the tree
614 ls repo/.git/objects/pack/pack-*.pack >packlist &&
615 test_line_count = 1 packlist &&
616 git verify-pack repo/.git/objects/pack/pack-*.pack -v >out &&
617 grep "$(git -C repo rev-parse HEAD)" out &&
618 ! grep "$TREE_HASH" out
621 test_expect_success
'do not fetch when checking existence of tree we construct ourselves' '
623 test_create_repo repo &&
624 test_commit -C repo base &&
625 test_commit -C repo side1 &&
626 git -C repo checkout base &&
627 test_commit -C repo side2 &&
629 git -C repo config core.repositoryformatversion 1 &&
630 git -C repo config extensions.partialclone "arbitrary string" &&
632 git -C repo cherry-pick side1
635 test_expect_success
'exact rename does not need to fetch the blob lazily' '
636 rm -rf repo partial.git &&
637 test_create_repo repo &&
638 content="some dummy content" &&
639 test_commit -C repo create-a-file file.txt "$content" &&
640 git -C repo mv file.txt new-file.txt &&
641 git -C repo commit -m rename-the-file &&
642 FILE_HASH=$(git -C repo rev-parse HEAD:new-file.txt) &&
643 test_config -C repo uploadpack.allowfilter 1 &&
644 test_config -C repo uploadpack.allowanysha1inwant 1 &&
646 git clone --filter=blob:none --bare "file://$(pwd)/repo" partial.git &&
647 git -C partial.git rev-list --objects --missing=print HEAD >out &&
648 grep "[?]$FILE_HASH" out &&
649 git -C partial.git log --follow -- new-file.txt &&
650 git -C partial.git rev-list --objects --missing=print HEAD >out &&
651 grep "[?]$FILE_HASH" out
654 test_expect_success
'lazy-fetch when accessing object not in the_repository' '
655 rm -rf full partial.git &&
656 test_create_repo full &&
657 test_commit -C full create-a-file file.txt &&
659 test_config -C full uploadpack.allowfilter 1 &&
660 test_config -C full uploadpack.allowanysha1inwant 1 &&
661 git clone --filter=blob:none --bare "file://$(pwd)/full" partial.git &&
662 FILE_HASH=$(git -C full rev-parse HEAD:file.txt) &&
664 # Sanity check that the file is missing
665 git -C partial.git rev-list --objects --missing=print HEAD >out &&
666 grep "[?]$FILE_HASH" out &&
668 git -C full cat-file -s "$FILE_HASH" >expect &&
669 test-tool partial-clone object-info partial.git "$FILE_HASH" >actual &&
670 test_cmp expect actual &&
672 # Sanity check that the file is now present
673 git -C partial.git rev-list --objects --missing=print HEAD >out &&
674 ! grep "[?]$FILE_HASH" out
677 .
"$TEST_DIRECTORY"/lib-httpd.sh
680 test_expect_success
'fetching of missing objects from an HTTP server' '
682 SERVER="$HTTPD_DOCUMENT_ROOT_PATH/server" &&
683 test_create_repo "$SERVER" &&
684 test_commit -C "$SERVER" foo &&
685 git -C "$SERVER" repack -a -d --write-bitmap-index &&
687 git clone $HTTPD_URL/smart/server repo &&
688 HASH=$(git -C repo rev-parse foo) &&
689 rm -rf repo/.git/objects/* &&
691 git -C repo config core.repositoryformatversion 1 &&
692 git -C repo config extensions.partialclone "origin" &&
693 git -C repo cat-file -p "$HASH" &&
695 # Ensure that the .promisor file is written, and check that its
696 # associated packfile contains the object
697 ls repo/.git/objects/pack/pack-*.promisor >promisorlist &&
698 test_line_count = 1 promisorlist &&
699 IDX=$(sed "s/promisor$/idx/" promisorlist) &&
700 git verify-pack --verbose "$IDX" >out &&
704 # DO NOT add non-httpd-specific tests here, because the last part of this
705 # test script is only executed when httpd is available and enabled.