Sync with 2.38.5
[git.git] / t / t5300-pack-object.sh
blobf8a0f309e2dec0f2ab864851730446bdc7102818
1 #!/bin/sh
3 # Copyright (c) 2005 Junio C Hamano
6 test_description='git pack-object
9 . ./test-lib.sh
11 test_expect_success 'setup' '
12 rm -f .git/index* &&
13 perl -e "print \"a\" x 4096;" >a &&
14 perl -e "print \"b\" x 4096;" >b &&
15 perl -e "print \"c\" x 4096;" >c &&
16 test-tool genrandom "seed a" 2097152 >a_big &&
17 test-tool genrandom "seed b" 2097152 >b_big &&
18 git update-index --add a a_big b b_big c &&
19 cat c >d && echo foo >>d && git update-index --add d &&
20 tree=$(git write-tree) &&
21 commit=$(git commit-tree $tree </dev/null) &&
23 echo $tree &&
24 echo $commit &&
25 git ls-tree $tree | sed -e "s/.* \\([0-9a-f]*\\) .*/\\1/"
26 } >obj-list &&
28 git diff-tree --root -p $commit &&
29 while read object
31 t=$(git cat-file -t $object) &&
32 git cat-file $t $object || return 1
33 done <obj-list
34 } >expect
37 test_expect_success 'setup pack-object <stdin' '
38 git init pack-object-stdin &&
39 test_commit -C pack-object-stdin one &&
40 test_commit -C pack-object-stdin two
44 test_expect_success 'pack-object <stdin parsing: basic [|--revs]' '
45 cat >in <<-EOF &&
46 $(git -C pack-object-stdin rev-parse one)
47 EOF
49 git -C pack-object-stdin pack-objects basic-stdin <in &&
50 idx=$(echo pack-object-stdin/basic-stdin-*.idx) &&
51 git show-index <"$idx" >actual &&
52 test_line_count = 1 actual &&
54 git -C pack-object-stdin pack-objects --revs basic-stdin-revs <in &&
55 idx=$(echo pack-object-stdin/basic-stdin-revs-*.idx) &&
56 git show-index <"$idx" >actual &&
57 test_line_count = 3 actual
60 test_expect_success 'pack-object <stdin parsing: [|--revs] bad line' '
61 cat >in <<-EOF &&
62 $(git -C pack-object-stdin rev-parse one)
63 garbage
64 $(git -C pack-object-stdin rev-parse two)
65 EOF
67 sed "s/^> //g" >err.expect <<-EOF &&
68 fatal: expected object ID, got garbage:
69 > garbage
71 EOF
72 test_must_fail git -C pack-object-stdin pack-objects bad-line-stdin <in 2>err.actual &&
73 test_cmp err.expect err.actual &&
75 cat >err.expect <<-EOF &&
76 fatal: bad revision '"'"'garbage'"'"'
77 EOF
78 test_must_fail git -C pack-object-stdin pack-objects --revs bad-line-stdin-revs <in 2>err.actual &&
79 test_cmp err.expect err.actual
82 test_expect_success 'pack-object <stdin parsing: [|--revs] empty line' '
83 cat >in <<-EOF &&
84 $(git -C pack-object-stdin rev-parse one)
86 $(git -C pack-object-stdin rev-parse two)
87 EOF
89 sed -e "s/^> //g" -e "s/Z$//g" >err.expect <<-EOF &&
90 fatal: expected object ID, got garbage:
91 > Z
93 EOF
94 test_must_fail git -C pack-object-stdin pack-objects empty-line-stdin <in 2>err.actual &&
95 test_cmp err.expect err.actual &&
97 git -C pack-object-stdin pack-objects --revs empty-line-stdin-revs <in &&
98 idx=$(echo pack-object-stdin/empty-line-stdin-revs-*.idx) &&
99 git show-index <"$idx" >actual &&
100 test_line_count = 3 actual
103 test_expect_success 'pack-object <stdin parsing: [|--revs] with --stdin' '
104 cat >in <<-EOF &&
105 $(git -C pack-object-stdin rev-parse one)
106 $(git -C pack-object-stdin rev-parse two)
109 # There is the "--stdin-packs is incompatible with --revs"
110 # test below, but we should make sure that the revision.c
111 # --stdin is not picked up
112 cat >err.expect <<-EOF &&
113 fatal: disallowed abbreviated or ambiguous option '"'"'stdin'"'"'
115 test_must_fail git -C pack-object-stdin pack-objects stdin-with-stdin-option --stdin <in 2>err.actual &&
116 test_cmp err.expect err.actual &&
118 test_must_fail git -C pack-object-stdin pack-objects --stdin --revs stdin-with-stdin-option-revs 2>err.actual <in &&
119 test_cmp err.expect err.actual
122 test_expect_success 'pack-object <stdin parsing: --stdin-packs handles garbage' '
123 cat >in <<-EOF &&
124 $(git -C pack-object-stdin rev-parse one)
125 $(git -C pack-object-stdin rev-parse two)
128 # That we get "two" and not "one" has to do with OID
129 # ordering. It happens to be the same here under SHA-1 and
130 # SHA-256. See commentary in pack-objects.c
131 cat >err.expect <<-EOF &&
132 fatal: could not find pack '"'"'$(git -C pack-object-stdin rev-parse two)'"'"'
134 test_must_fail git \
135 -C pack-object-stdin \
136 pack-objects stdin-with-stdin-option --stdin-packs \
137 <in 2>err.actual &&
138 test_cmp err.expect err.actual
141 # usage: check_deltas <stderr_from_pack_objects> <cmp_op> <nr_deltas>
142 # e.g.: check_deltas stderr -gt 0
143 check_deltas() {
144 deltas=$(perl -lne '/delta (\d+)/ and print $1' "$1") &&
145 shift &&
146 if ! test "$deltas" "$@"
147 then
148 echo >&2 "unexpected number of deltas (compared $delta $*)"
149 return 1
153 test_expect_success 'pack without delta' '
154 packname_1=$(git pack-objects --progress --window=0 test-1 \
155 <obj-list 2>stderr) &&
156 check_deltas stderr = 0
159 test_expect_success 'pack-objects with bogus arguments' '
160 test_must_fail git pack-objects --window=0 test-1 blah blah <obj-list
163 check_unpack () {
164 local packname="$1" &&
165 local object_list="$2" &&
166 local git_config="$3" &&
167 test_when_finished "rm -rf git2" &&
168 git $git_config init --bare git2 &&
170 git $git_config -C git2 unpack-objects -n <"$packname".pack &&
171 git $git_config -C git2 unpack-objects <"$packname".pack &&
172 git $git_config -C git2 cat-file --batch-check="%(objectname)"
173 ) <"$object_list" >current &&
174 cmp "$object_list" current
177 test_expect_success 'unpack without delta' '
178 check_unpack test-1-${packname_1} obj-list
181 BATCH_CONFIGURATION='-c core.fsync=loose-object -c core.fsyncmethod=batch'
183 test_expect_success 'unpack without delta (core.fsyncmethod=batch)' '
184 check_unpack test-1-${packname_1} obj-list "$BATCH_CONFIGURATION"
187 test_expect_success 'pack with REF_DELTA' '
188 packname_2=$(git pack-objects --progress test-2 <obj-list 2>stderr) &&
189 check_deltas stderr -gt 0
192 test_expect_success 'unpack with REF_DELTA' '
193 check_unpack test-2-${packname_2} obj-list
196 test_expect_success 'unpack with REF_DELTA (core.fsyncmethod=batch)' '
197 check_unpack test-2-${packname_2} obj-list "$BATCH_CONFIGURATION"
200 test_expect_success 'pack with OFS_DELTA' '
201 packname_3=$(git pack-objects --progress --delta-base-offset test-3 \
202 <obj-list 2>stderr) &&
203 check_deltas stderr -gt 0
206 test_expect_success 'unpack with OFS_DELTA' '
207 check_unpack test-3-${packname_3} obj-list
210 test_expect_success 'unpack with OFS_DELTA (core.fsyncmethod=batch)' '
211 check_unpack test-3-${packname_3} obj-list "$BATCH_CONFIGURATION"
214 test_expect_success 'compare delta flavors' '
215 perl -e '\''
216 defined($_ = -s $_) or die for @ARGV;
217 exit 1 if $ARGV[0] <= $ARGV[1];
218 '\'' test-2-$packname_2.pack test-3-$packname_3.pack
221 check_use_objects () {
222 test_when_finished "rm -rf git2" &&
223 git init --bare git2 &&
224 cp "$1".pack "$1".idx git2/objects/pack &&
226 cd git2 &&
227 git diff-tree --root -p $commit &&
228 while read object
230 t=$(git cat-file -t $object) &&
231 git cat-file $t $object || exit 1
232 done
233 ) <obj-list >current &&
234 cmp expect current
237 test_expect_success 'use packed objects' '
238 check_use_objects test-1-${packname_1}
241 test_expect_success 'use packed deltified (REF_DELTA) objects' '
242 check_use_objects test-2-${packname_2}
245 test_expect_success 'use packed deltified (OFS_DELTA) objects' '
246 check_use_objects test-3-${packname_3}
249 test_expect_success 'survive missing objects/pack directory' '
251 rm -fr missing-pack &&
252 mkdir missing-pack &&
253 cd missing-pack &&
254 git init &&
255 GOP=.git/objects/pack &&
256 rm -fr $GOP &&
257 git index-pack --stdin --keep=test <../test-3-${packname_3}.pack &&
258 test -f $GOP/pack-${packname_3}.pack &&
259 cmp $GOP/pack-${packname_3}.pack ../test-3-${packname_3}.pack &&
260 test -f $GOP/pack-${packname_3}.idx &&
261 cmp $GOP/pack-${packname_3}.idx ../test-3-${packname_3}.idx &&
262 test -f $GOP/pack-${packname_3}.keep
266 test_expect_success \
267 'verify pack' \
268 'git verify-pack test-1-${packname_1}.idx \
269 test-2-${packname_2}.idx \
270 test-3-${packname_3}.idx'
272 test_expect_success \
273 'verify pack -v' \
274 'git verify-pack -v test-1-${packname_1}.idx \
275 test-2-${packname_2}.idx \
276 test-3-${packname_3}.idx'
278 test_expect_success \
279 'verify-pack catches mismatched .idx and .pack files' \
280 'cat test-1-${packname_1}.idx >test-3.idx &&
281 cat test-2-${packname_2}.pack >test-3.pack &&
282 if git verify-pack test-3.idx
283 then false
284 else :;
287 test_expect_success \
288 'verify-pack catches a corrupted pack signature' \
289 'cat test-1-${packname_1}.pack >test-3.pack &&
290 echo | dd of=test-3.pack count=1 bs=1 conv=notrunc seek=2 &&
291 if git verify-pack test-3.idx
292 then false
293 else :;
296 test_expect_success \
297 'verify-pack catches a corrupted pack version' \
298 'cat test-1-${packname_1}.pack >test-3.pack &&
299 echo | dd of=test-3.pack count=1 bs=1 conv=notrunc seek=7 &&
300 if git verify-pack test-3.idx
301 then false
302 else :;
305 test_expect_success \
306 'verify-pack catches a corrupted type/size of the 1st packed object data' \
307 'cat test-1-${packname_1}.pack >test-3.pack &&
308 echo | dd of=test-3.pack count=1 bs=1 conv=notrunc seek=12 &&
309 if git verify-pack test-3.idx
310 then false
311 else :;
314 test_expect_success \
315 'verify-pack catches a corrupted sum of the index file itself' \
316 'l=$(wc -c <test-3.idx) &&
317 l=$(expr $l - 20) &&
318 cat test-1-${packname_1}.pack >test-3.pack &&
319 printf "%20s" "" | dd of=test-3.idx count=20 bs=1 conv=notrunc seek=$l &&
320 if git verify-pack test-3.pack
321 then false
322 else :;
325 test_expect_success \
326 'build pack index for an existing pack' \
327 'cat test-1-${packname_1}.pack >test-3.pack &&
328 git index-pack -o tmp.idx test-3.pack &&
329 cmp tmp.idx test-1-${packname_1}.idx &&
331 git index-pack --promisor=message test-3.pack &&
332 cmp test-3.idx test-1-${packname_1}.idx &&
333 echo message >expect &&
334 test_cmp expect test-3.promisor &&
336 cat test-2-${packname_2}.pack >test-3.pack &&
337 git index-pack -o tmp.idx test-2-${packname_2}.pack &&
338 cmp tmp.idx test-2-${packname_2}.idx &&
340 git index-pack test-3.pack &&
341 cmp test-3.idx test-2-${packname_2}.idx &&
343 cat test-3-${packname_3}.pack >test-3.pack &&
344 git index-pack -o tmp.idx test-3-${packname_3}.pack &&
345 cmp tmp.idx test-3-${packname_3}.idx &&
347 git index-pack test-3.pack &&
348 cmp test-3.idx test-3-${packname_3}.idx &&
350 cat test-1-${packname_1}.pack >test-4.pack &&
351 rm -f test-4.keep &&
352 git index-pack --keep=why test-4.pack &&
353 cmp test-1-${packname_1}.idx test-4.idx &&
354 test -f test-4.keep &&
358 test_expect_success 'unpacking with --strict' '
360 for j in a b c d e f g
362 for i in 0 1 2 3 4 5 6 7 8 9
364 o=$(echo $j$i | git hash-object -w --stdin) &&
365 echo "100644 $o 0 $j$i" || return 1
366 done
367 done >LIST &&
368 rm -f .git/index &&
369 git update-index --index-info <LIST &&
370 LIST=$(git write-tree) &&
371 rm -f .git/index &&
372 head -n 10 LIST | git update-index --index-info &&
373 LI=$(git write-tree) &&
374 rm -f .git/index &&
375 tail -n 10 LIST | git update-index --index-info &&
376 ST=$(git write-tree) &&
377 git rev-list --objects "$LIST" "$LI" "$ST" >actual &&
378 PACK5=$( git pack-objects test-5 <actual ) &&
379 PACK6=$( test_write_lines "$LIST" "$LI" "$ST" | git pack-objects test-6 ) &&
380 test_create_repo test-5 &&
382 cd test-5 &&
383 git unpack-objects --strict <../test-5-$PACK5.pack &&
384 git ls-tree -r $LIST &&
385 git ls-tree -r $LI &&
386 git ls-tree -r $ST
387 ) &&
388 test_create_repo test-6 &&
390 # tree-only into empty repo -- many unreachables
391 cd test-6 &&
392 test_must_fail git unpack-objects --strict <../test-6-$PACK6.pack
393 ) &&
395 # already populated -- no unreachables
396 cd test-5 &&
397 git unpack-objects --strict <../test-6-$PACK6.pack
401 test_expect_success 'index-pack with --strict' '
403 for j in a b c d e f g
405 for i in 0 1 2 3 4 5 6 7 8 9
407 o=$(echo $j$i | git hash-object -w --stdin) &&
408 echo "100644 $o 0 $j$i" || return 1
409 done
410 done >LIST &&
411 rm -f .git/index &&
412 git update-index --index-info <LIST &&
413 LIST=$(git write-tree) &&
414 rm -f .git/index &&
415 head -n 10 LIST | git update-index --index-info &&
416 LI=$(git write-tree) &&
417 rm -f .git/index &&
418 tail -n 10 LIST | git update-index --index-info &&
419 ST=$(git write-tree) &&
420 git rev-list --objects "$LIST" "$LI" "$ST" >actual &&
421 PACK5=$( git pack-objects test-5 <actual ) &&
422 PACK6=$( test_write_lines "$LIST" "$LI" "$ST" | git pack-objects test-6 ) &&
423 test_create_repo test-7 &&
425 cd test-7 &&
426 git index-pack --strict --stdin <../test-5-$PACK5.pack &&
427 git ls-tree -r $LIST &&
428 git ls-tree -r $LI &&
429 git ls-tree -r $ST
430 ) &&
431 test_create_repo test-8 &&
433 # tree-only into empty repo -- many unreachables
434 cd test-8 &&
435 test_must_fail git index-pack --strict --stdin <../test-6-$PACK6.pack
436 ) &&
438 # already populated -- no unreachables
439 cd test-7 &&
440 git index-pack --strict --stdin <../test-6-$PACK6.pack
444 test_expect_success 'honor pack.packSizeLimit' '
445 git config pack.packSizeLimit 3m &&
446 packname_10=$(git pack-objects test-10 <obj-list) &&
447 test 2 = $(ls test-10-*.pack | wc -l)
450 test_expect_success 'verify resulting packs' '
451 git verify-pack test-10-*.pack
454 test_expect_success 'tolerate packsizelimit smaller than biggest object' '
455 git config pack.packSizeLimit 1 &&
456 packname_11=$(git pack-objects test-11 <obj-list) &&
457 test 5 = $(ls test-11-*.pack | wc -l)
460 test_expect_success 'verify resulting packs' '
461 git verify-pack test-11-*.pack
464 test_expect_success 'set up pack for non-repo tests' '
465 # make sure we have a pack with no matching index file
466 cp test-1-*.pack foo.pack
469 test_expect_success 'index-pack --stdin complains of non-repo' '
470 nongit test_must_fail git index-pack --object-format=$(test_oid algo) --stdin <foo.pack &&
471 test_path_is_missing non-repo/.git
474 test_expect_success 'index-pack <pack> works in non-repo' '
475 nongit git index-pack --object-format=$(test_oid algo) ../foo.pack &&
476 test_path_is_file foo.idx
479 test_expect_success 'index-pack --strict <pack> works in non-repo' '
480 rm -f foo.idx &&
481 nongit git index-pack --strict --object-format=$(test_oid algo) ../foo.pack &&
482 test_path_is_file foo.idx
485 test_expect_success !PTHREADS,!FAIL_PREREQS \
486 'index-pack --threads=N or pack.threads=N warns when no pthreads' '
487 test_must_fail git index-pack --threads=2 2>err &&
488 grep ^warning: err >warnings &&
489 test_line_count = 1 warnings &&
490 grep -F "no threads support, ignoring --threads=2" err &&
492 test_must_fail git -c pack.threads=2 index-pack 2>err &&
493 grep ^warning: err >warnings &&
494 test_line_count = 1 warnings &&
495 grep -F "no threads support, ignoring pack.threads" err &&
497 test_must_fail git -c pack.threads=2 index-pack --threads=4 2>err &&
498 grep ^warning: err >warnings &&
499 test_line_count = 2 warnings &&
500 grep -F "no threads support, ignoring --threads=4" err &&
501 grep -F "no threads support, ignoring pack.threads" err
504 test_expect_success !PTHREADS,!FAIL_PREREQS \
505 'pack-objects --threads=N or pack.threads=N warns when no pthreads' '
506 git pack-objects --threads=2 --stdout --all </dev/null >/dev/null 2>err &&
507 grep ^warning: err >warnings &&
508 test_line_count = 1 warnings &&
509 grep -F "no threads support, ignoring --threads" err &&
511 git -c pack.threads=2 pack-objects --stdout --all </dev/null >/dev/null 2>err &&
512 grep ^warning: err >warnings &&
513 test_line_count = 1 warnings &&
514 grep -F "no threads support, ignoring pack.threads" err &&
516 git -c pack.threads=2 pack-objects --threads=4 --stdout --all </dev/null >/dev/null 2>err &&
517 grep ^warning: err >warnings &&
518 test_line_count = 2 warnings &&
519 grep -F "no threads support, ignoring --threads" err &&
520 grep -F "no threads support, ignoring pack.threads" err
523 test_expect_success 'pack-objects in too-many-packs mode' '
524 GIT_TEST_FULL_IN_PACK_ARRAY=1 git repack -ad &&
525 git fsck
528 test_expect_success 'setup: fake a SHA1 hash collision' '
529 git init corrupt &&
531 cd corrupt &&
532 long_a=$(git hash-object -w ../a | sed -e "s!^..!&/!") &&
533 long_b=$(git hash-object -w ../b | sed -e "s!^..!&/!") &&
534 test -f .git/objects/$long_b &&
535 cp -f .git/objects/$long_a \
536 .git/objects/$long_b
540 test_expect_success 'make sure index-pack detects the SHA1 collision' '
542 cd corrupt &&
543 test_must_fail git index-pack -o ../bad.idx ../test-3.pack 2>msg &&
544 test_i18ngrep "SHA1 COLLISION FOUND" msg
548 test_expect_success 'make sure index-pack detects the SHA1 collision (large blobs)' '
550 cd corrupt &&
551 test_must_fail git -c core.bigfilethreshold=1 index-pack -o ../bad.idx ../test-3.pack 2>msg &&
552 test_i18ngrep "SHA1 COLLISION FOUND" msg
556 test_expect_success 'prefetch objects' '
557 rm -rf server client &&
559 git init server &&
560 test_config -C server uploadpack.allowanysha1inwant 1 &&
561 test_config -C server uploadpack.allowfilter 1 &&
562 test_config -C server protocol.version 2 &&
564 echo one >server/one &&
565 git -C server add one &&
566 git -C server commit -m one &&
567 git -C server branch one_branch &&
569 echo two_a >server/two_a &&
570 echo two_b >server/two_b &&
571 git -C server add two_a two_b &&
572 git -C server commit -m two &&
574 echo three >server/three &&
575 git -C server add three &&
576 git -C server commit -m three &&
577 git -C server branch three_branch &&
579 # Clone, fetch "two" with blobs excluded, and re-push it. This requires
580 # the client to have the blobs of "two" - verify that these are
581 # prefetched in one batch.
582 git clone --filter=blob:none --single-branch -b one_branch \
583 "file://$(pwd)/server" client &&
584 test_config -C client protocol.version 2 &&
585 TWO=$(git -C server rev-parse three_branch^) &&
586 git -C client fetch --filter=blob:none origin "$TWO" &&
587 GIT_TRACE_PACKET=$(pwd)/trace git -C client push origin "$TWO":refs/heads/two_branch &&
588 grep "fetch> done" trace >donelines &&
589 test_line_count = 1 donelines
592 test_expect_success 'setup for --stdin-packs tests' '
593 git init stdin-packs &&
595 cd stdin-packs &&
597 test_commit A &&
598 test_commit B &&
599 test_commit C &&
601 for id in A B C
603 git pack-objects .git/objects/pack/pack-$id \
604 --incremental --revs <<-EOF || exit 1
605 refs/tags/$id
607 done &&
609 ls -la .git/objects/pack
613 test_expect_success '--stdin-packs with excluded packs' '
615 cd stdin-packs &&
617 PACK_A="$(basename .git/objects/pack/pack-A-*.pack)" &&
618 PACK_B="$(basename .git/objects/pack/pack-B-*.pack)" &&
619 PACK_C="$(basename .git/objects/pack/pack-C-*.pack)" &&
621 git pack-objects test --stdin-packs <<-EOF &&
622 $PACK_A
623 ^$PACK_B
624 $PACK_C
628 git show-index <$(ls .git/objects/pack/pack-A-*.idx) &&
629 git show-index <$(ls .git/objects/pack/pack-C-*.idx)
630 ) >expect.raw &&
631 git show-index <$(ls test-*.idx) >actual.raw &&
633 cut -d" " -f2 <expect.raw | sort >expect &&
634 cut -d" " -f2 <actual.raw | sort >actual &&
635 test_cmp expect actual
639 test_expect_success '--stdin-packs is incompatible with --filter' '
641 cd stdin-packs &&
642 test_must_fail git pack-objects --stdin-packs --stdout \
643 --filter=blob:none </dev/null 2>err &&
644 test_i18ngrep "cannot use --filter with --stdin-packs" err
648 test_expect_success '--stdin-packs is incompatible with --revs' '
650 cd stdin-packs &&
651 test_must_fail git pack-objects --stdin-packs --revs out \
652 </dev/null 2>err &&
653 test_i18ngrep "cannot use internal rev list with --stdin-packs" err
657 test_expect_success '--stdin-packs with loose objects' '
659 cd stdin-packs &&
661 PACK_A="$(basename .git/objects/pack/pack-A-*.pack)" &&
662 PACK_B="$(basename .git/objects/pack/pack-B-*.pack)" &&
663 PACK_C="$(basename .git/objects/pack/pack-C-*.pack)" &&
665 test_commit D && # loose
667 git pack-objects test2 --stdin-packs --unpacked <<-EOF &&
668 $PACK_A
669 ^$PACK_B
670 $PACK_C
674 git show-index <$(ls .git/objects/pack/pack-A-*.idx) &&
675 git show-index <$(ls .git/objects/pack/pack-C-*.idx) &&
676 git rev-list --objects --no-object-names \
677 refs/tags/C..refs/tags/D
679 ) >expect.raw &&
680 ls -la . &&
681 git show-index <$(ls test2-*.idx) >actual.raw &&
683 cut -d" " -f2 <expect.raw | sort >expect &&
684 cut -d" " -f2 <actual.raw | sort >actual &&
685 test_cmp expect actual
689 test_expect_success '--stdin-packs with broken links' '
691 cd stdin-packs &&
693 # make an unreachable object with a bogus parent
694 git cat-file -p HEAD >commit &&
695 sed "s/$(git rev-parse HEAD^)/$(test_oid zero)/" <commit |
696 git hash-object -w -t commit --stdin >in &&
698 git pack-objects .git/objects/pack/pack-D <in &&
700 PACK_A="$(basename .git/objects/pack/pack-A-*.pack)" &&
701 PACK_B="$(basename .git/objects/pack/pack-B-*.pack)" &&
702 PACK_C="$(basename .git/objects/pack/pack-C-*.pack)" &&
703 PACK_D="$(basename .git/objects/pack/pack-D-*.pack)" &&
705 git pack-objects test3 --stdin-packs --unpacked <<-EOF &&
706 $PACK_A
707 ^$PACK_B
708 $PACK_C
709 $PACK_D
713 git show-index <$(ls .git/objects/pack/pack-A-*.idx) &&
714 git show-index <$(ls .git/objects/pack/pack-C-*.idx) &&
715 git show-index <$(ls .git/objects/pack/pack-D-*.idx) &&
716 git rev-list --objects --no-object-names \
717 refs/tags/C..refs/tags/D
718 ) >expect.raw &&
719 git show-index <$(ls test3-*.idx) >actual.raw &&
721 cut -d" " -f2 <expect.raw | sort >expect &&
722 cut -d" " -f2 <actual.raw | sort >actual &&
723 test_cmp expect actual
727 test_expect_success 'negative window clamps to 0' '
728 git pack-objects --progress --window=-1 neg-window <obj-list 2>stderr &&
729 check_deltas stderr = 0
732 test_done