(CommandList children: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:test_description) op: Equal rhs: {(SQ <'git pack-object\n'> <'\n'>)} spids: [13] ) ] spids: [13] ) (C {(.)} {(./test-lib.sh)}) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:TRASH) op: Equal rhs: { (CommandSubPart command_list: (CommandList children:[(C {(pwd)})]) left_token: <Left_CommandSub '$('> spids: [25 27] ) } spids: [24] ) ] spids: [24] ) (C {(test_expect_success)} {(SQ <setup>)} { (SQ <'rm -f .git/index* &&\n'> <' perl -e "print \\"a\\" x 4096;" > a &&\n'> <' perl -e "print \\"b\\" x 4096;" > b &&\n'> <' perl -e "print \\"c\\" x 4096;" > c &&\n'> <' test-genrandom "seed a" 2097152 > a_big &&\n'> <' test-genrandom "seed b" 2097152 > b_big &&\n'> <' git update-index --add a a_big b b_big c &&\n'> <' cat c >d && echo foo >>d && git update-index --add d &&\n'> <' tree=$(git write-tree) &&\n'> <' commit=$(git commit-tree $tree </dev/null) && {\n'> <'\t echo $tree &&\n'> <'\t echo $commit &&\n'> <'\t git ls-tree $tree | sed -e "s/.* \\\\([0-9a-f]*\\\\)\t.*/\\\\1/"\n'> <' } >obj-list && {\n'> <'\t git diff-tree --root -p $commit &&\n'> <'\t while read object\n'> <'\t do\n'> <'\t t=$(git cat-file -t $object) &&\n'> <'\t git cat-file $t $object || return 1\n'> <'\t done <obj-list\n'> <' } >expect'> ) } ) (C {(test_expect_success)} {(SQ <'pack without delta'>)} {(SQ <'packname_1=$(git pack-objects --window=0 test-1 <obj-list)'>)} ) (C {(test_expect_success)} {(SQ <'pack-objects with bogus arguments'>)} {(SQ <'test_must_fail git pack-objects --window=0 test-1 blah blah <obj-list'>)} ) (C {(rm)} {(-fr)} {(.git2)}) (C {(mkdir)} {(.git2)}) (C {(test_expect_success)} {(SQ <'unpack without delta'>)} { (DQ ('GIT_OBJECT_DIRECTORY=.git2/objects &&\n') (' export GIT_OBJECT_DIRECTORY &&\n') (' git init &&\n') (' git unpack-objects -n <test-1-') (${ VSub_Name packname_1) ('.pack &&\n') (' git unpack-objects <test-1-') (${ VSub_Name packname_1) (.pack) ) } ) (C {(unset)} {(GIT_OBJECT_DIRECTORY)}) (C {(cd)} {(DQ ($ VSub_Name '$TRASH') (/.git2))}) (C {(test_expect_success)} {(SQ <'check unpack without delta'>)} { (SQ <'(cd ../.git && find objects -type f -print) |\n'> <' while read path\n'> <' do\n'> <' cmp $path ../.git/$path || {\n'> <'\t echo $path differs.\n'> <'\t return 1\n'> <'\t }\n'> <' done'> ) } ) (C {(cd)} {(DQ ($ VSub_Name '$TRASH'))}) (C {(test_expect_success)} {(SQ <'pack with REF_DELTA'>)} {(SQ <'pwd &&\n'> <' packname_2=$(git pack-objects test-2 <obj-list)'>)} ) (C {(rm)} {(-fr)} {(.git2)}) (C {(mkdir)} {(.git2)}) (C {(test_expect_success)} {(SQ <'unpack with REF_DELTA'>)} { (SQ <'GIT_OBJECT_DIRECTORY=.git2/objects &&\n'> <' export GIT_OBJECT_DIRECTORY &&\n'> <' git init &&\n'> <' git unpack-objects -n <test-2-${packname_2}.pack &&\n'> <' git unpack-objects <test-2-${packname_2}.pack'> ) } ) (C {(unset)} {(GIT_OBJECT_DIRECTORY)}) (C {(cd)} {(DQ ($ VSub_Name '$TRASH') (/.git2))}) (C {(test_expect_success)} {(SQ <'check unpack with REF_DELTA'>)} { (SQ <'(cd ../.git && find objects -type f -print) |\n'> <' while read path\n'> <' do\n'> <' cmp $path ../.git/$path || {\n'> <'\t echo $path differs.\n'> <'\t return 1\n'> <'\t }\n'> <' done'> ) } ) (C {(cd)} {(DQ ($ VSub_Name '$TRASH'))}) (C {(test_expect_success)} {(SQ <'pack with OFS_DELTA'>)} { (SQ <'pwd &&\n'> <' packname_3=$(git pack-objects --delta-base-offset test-3 <obj-list)'>) } ) (C {(rm)} {(-fr)} {(.git2)}) (C {(mkdir)} {(.git2)}) (C {(test_expect_success)} {(SQ <'unpack with OFS_DELTA'>)} { (SQ <'GIT_OBJECT_DIRECTORY=.git2/objects &&\n'> <' export GIT_OBJECT_DIRECTORY &&\n'> <' git init &&\n'> <' git unpack-objects -n <test-3-${packname_3}.pack &&\n'> <' git unpack-objects <test-3-${packname_3}.pack'> ) } ) (C {(unset)} {(GIT_OBJECT_DIRECTORY)}) (C {(cd)} {(DQ ($ VSub_Name '$TRASH') (/.git2))}) (C {(test_expect_success)} {(SQ <'check unpack with OFS_DELTA'>)} { (SQ <'(cd ../.git && find objects -type f -print) |\n'> <' while read path\n'> <' do\n'> <' cmp $path ../.git/$path || {\n'> <'\t echo $path differs.\n'> <'\t return 1\n'> <'\t }\n'> <' done'> ) } ) (C {(cd)} {(DQ ($ VSub_Name '$TRASH'))}) (C {(test_expect_success)} {(SQ <'compare delta flavors'>)} {(SQ <'\n'> <'\tperl -e '>) (EscapedLiteralPart token:<Lit_EscapedChar "\\'">) (SQ <'\n'> <'\t\tdefined($_ = -s $_) or die for @ARGV;\n'> <'\t\texit 1 if $ARGV[0] <= $ARGV[1];\n'> <'\t'> ) (EscapedLiteralPart token:<Lit_EscapedChar "\\'">) (SQ <' test-2-$packname_2.pack test-3-$packname_3.pack\n'>) } ) (C {(rm)} {(-fr)} {(.git2)}) (C {(mkdir)} {(.git2)}) (C {(test_expect_success)} {(SQ <'use packed objects'>)} { (SQ <'GIT_OBJECT_DIRECTORY=.git2/objects &&\n'> <' export GIT_OBJECT_DIRECTORY &&\n'> <' git init &&\n'> <' cp test-1-${packname_1}.pack test-1-${packname_1}.idx .git2/objects/pack && {\n'> <'\t git diff-tree --root -p $commit &&\n'> <'\t while read object\n'> <'\t do\n'> <'\t t=$(git cat-file -t $object) &&\n'> <'\t git cat-file $t $object || return 1\n'> <'\t done <obj-list\n'> <' } >current &&\n'> <' cmp expect current'> ) } ) (C {(test_expect_success)} {(SQ <'use packed deltified (REF_DELTA) objects'>)} { (SQ <'GIT_OBJECT_DIRECTORY=.git2/objects &&\n'> <' export GIT_OBJECT_DIRECTORY &&\n'> <' rm -f .git2/objects/pack/test-* &&\n'> <' cp test-2-${packname_2}.pack test-2-${packname_2}.idx .git2/objects/pack && {\n'> <'\t git diff-tree --root -p $commit &&\n'> <'\t while read object\n'> <'\t do\n'> <'\t t=$(git cat-file -t $object) &&\n'> <'\t git cat-file $t $object || return 1\n'> <'\t done <obj-list\n'> <' } >current &&\n'> <' cmp expect current'> ) } ) (C {(test_expect_success)} {(SQ <'use packed deltified (OFS_DELTA) objects'>)} { (SQ <'GIT_OBJECT_DIRECTORY=.git2/objects &&\n'> <' export GIT_OBJECT_DIRECTORY &&\n'> <' rm -f .git2/objects/pack/test-* &&\n'> <' cp test-3-${packname_3}.pack test-3-${packname_3}.idx .git2/objects/pack && {\n'> <'\t git diff-tree --root -p $commit &&\n'> <'\t while read object\n'> <'\t do\n'> <'\t t=$(git cat-file -t $object) &&\n'> <'\t git cat-file $t $object || return 1\n'> <'\t done <obj-list\n'> <' } >current &&\n'> <' cmp expect current'> ) } ) (C {(unset)} {(GIT_OBJECT_DIRECTORY)}) (C {(test_expect_success)} {(SQ <'survive missing objects/pack directory'>)} { (SQ <'\n'> <'\t(\n'> <'\t\trm -fr missing-pack &&\n'> <'\t\tmkdir missing-pack &&\n'> <'\t\tcd missing-pack &&\n'> <'\t\tgit init &&\n'> <'\t\tGOP=.git/objects/pack\n'> <'\t\trm -fr $GOP &&\n'> <'\t\tgit index-pack --stdin --keep=test <../test-3-${packname_3}.pack &&\n'> <'\t\ttest -f $GOP/pack-${packname_3}.pack &&\n'> <'\t\tcmp $GOP/pack-${packname_3}.pack ../test-3-${packname_3}.pack &&\n'> <'\t\ttest -f $GOP/pack-${packname_3}.idx &&\n'> <'\t\tcmp $GOP/pack-${packname_3}.idx ../test-3-${packname_3}.idx &&\n'> <'\t\ttest -f $GOP/pack-${packname_3}.keep\n'> <'\t)\n'> ) } ) (C {(test_expect_success)} {(SQ <'verify pack'>)} { (SQ <'git verify-pack\ttest-1-${packname_1}.idx \\\n'> <'\t\t\ttest-2-${packname_2}.idx \\\n'> <'\t\t\ttest-3-${packname_3}.idx'> ) } ) (C {(test_expect_success)} {(SQ <'verify pack -v'>)} { (SQ <'git verify-pack -v\ttest-1-${packname_1}.idx \\\n'> <'\t\t\ttest-2-${packname_2}.idx \\\n'> <'\t\t\ttest-3-${packname_3}.idx'> ) } ) (C {(test_expect_success)} {(SQ <'verify-pack catches mismatched .idx and .pack files'>)} { (SQ <'cat test-1-${packname_1}.idx >test-3.idx &&\n'> <' cat test-2-${packname_2}.pack >test-3.pack &&\n'> <' if git verify-pack test-3.idx\n'> <' then false\n'> <' else :;\n'> <' fi'> ) } ) (C {(test_expect_success)} {(SQ <'verify-pack catches a corrupted pack signature'>)} { (SQ <'cat test-1-${packname_1}.pack >test-3.pack &&\n'> <' echo | dd of=test-3.pack count=1 bs=1 conv=notrunc seek=2 &&\n'> <' if git verify-pack test-3.idx\n'> <' then false\n'> <' else :;\n'> <' fi'> ) } ) (C {(test_expect_success)} {(SQ <'verify-pack catches a corrupted pack version'>)} { (SQ <'cat test-1-${packname_1}.pack >test-3.pack &&\n'> <' echo | dd of=test-3.pack count=1 bs=1 conv=notrunc seek=7 &&\n'> <' if git verify-pack test-3.idx\n'> <' then false\n'> <' else :;\n'> <' fi'> ) } ) (C {(test_expect_success)} {(SQ <'verify-pack catches a corrupted type/size of the 1st packed object data'>)} { (SQ <'cat test-1-${packname_1}.pack >test-3.pack &&\n'> <' echo | dd of=test-3.pack count=1 bs=1 conv=notrunc seek=12 &&\n'> <' if git verify-pack test-3.idx\n'> <' then false\n'> <' else :;\n'> <' fi'> ) } ) (C {(test_expect_success)} {(SQ <'verify-pack catches a corrupted sum of the index file itself'>)} { (SQ <'l=$(wc -c <test-3.idx) &&\n'> <' l=$(expr $l - 20) &&\n'> <' cat test-1-${packname_1}.pack >test-3.pack &&\n'> <' printf "%20s" "" | dd of=test-3.idx count=20 bs=1 conv=notrunc seek=$l &&\n'> <' if git verify-pack test-3.pack\n'> <' then false\n'> <' else :;\n'> <' fi'> ) } ) (C {(test_expect_success)} {(SQ <'build pack index for an existing pack'>)} { (SQ <'cat test-1-${packname_1}.pack >test-3.pack &&\n'> <' git index-pack -o tmp.idx test-3.pack &&\n'> <' cmp tmp.idx test-1-${packname_1}.idx &&\n'> <'\n'> <' git index-pack test-3.pack &&\n'> <' cmp test-3.idx test-1-${packname_1}.idx &&\n'> <'\n'> <' cat test-2-${packname_2}.pack >test-3.pack &&\n'> <' git index-pack -o tmp.idx test-2-${packname_2}.pack &&\n'> <' cmp tmp.idx test-2-${packname_2}.idx &&\n'> <'\n'> <' git index-pack test-3.pack &&\n'> <' cmp test-3.idx test-2-${packname_2}.idx &&\n'> <'\n'> <' cat test-3-${packname_3}.pack >test-3.pack &&\n'> <' git index-pack -o tmp.idx test-3-${packname_3}.pack &&\n'> <' cmp tmp.idx test-3-${packname_3}.idx &&\n'> <'\n'> <' git index-pack test-3.pack &&\n'> <' cmp test-3.idx test-3-${packname_3}.idx &&\n'> <'\n'> <' cat test-1-${packname_1}.pack >test-4.pack &&\n'> <' rm -f test-4.keep &&\n'> <' git index-pack --keep=why test-4.pack &&\n'> <' cmp test-1-${packname_1}.idx test-4.idx &&\n'> <' test -f test-4.keep &&\n'> <'\n'> <' :'> ) } ) (C {(test_expect_success)} {(SQ <'unpacking with --strict'>)} { (SQ <'\n'> <'\n'> <'\tfor j in a b c d e f g\n'> <'\tdo\n'> <'\t\tfor i in 0 1 2 3 4 5 6 7 8 9\n'> <'\t\tdo\n'> <'\t\t\to=$(echo $j$i | git hash-object -w --stdin) &&\n'> <'\t\t\techo "100644 $o\t0 $j$i"\n'> <'\t\tdone\n'> <'\tdone >LIST &&\n'> <'\trm -f .git/index &&\n'> <'\tgit update-index --index-info <LIST &&\n'> <'\tLIST=$(git write-tree) &&\n'> <'\trm -f .git/index &&\n'> <'\thead -n 10 LIST | git update-index --index-info &&\n'> <'\tLI=$(git write-tree) &&\n'> <'\trm -f .git/index &&\n'> <'\ttail -n 10 LIST | git update-index --index-info &&\n'> <'\tST=$(git write-tree) &&\n'> <'\tPACK5=$( git rev-list --objects "$LIST" "$LI" "$ST" | \\\n'> <'\t\tgit pack-objects test-5 ) &&\n'> <'\tPACK6=$( (\n'> <'\t\t\techo "$LIST"\n'> <'\t\t\techo "$LI"\n'> <'\t\t\techo "$ST"\n'> <'\t\t ) | git pack-objects test-6 ) &&\n'> <'\ttest_create_repo test-5 &&\n'> <'\t(\n'> <'\t\tcd test-5 &&\n'> <'\t\tgit unpack-objects --strict <../test-5-$PACK5.pack &&\n'> <'\t\tgit ls-tree -r $LIST &&\n'> <'\t\tgit ls-tree -r $LI &&\n'> <'\t\tgit ls-tree -r $ST\n'> <'\t) &&\n'> <'\ttest_create_repo test-6 &&\n'> <'\t(\n'> <'\t\t# tree-only into empty repo -- many unreachables\n'> <'\t\tcd test-6 &&\n'> <'\t\ttest_must_fail git unpack-objects --strict <../test-6-$PACK6.pack\n'> <'\t) &&\n'> <'\t(\n'> <'\t\t# already populated -- no unreachables\n'> <'\t\tcd test-5 &&\n'> <'\t\tgit unpack-objects --strict <../test-6-$PACK6.pack\n'> <'\t)\n'> ) } ) (C {(test_expect_success)} {(SQ <'index-pack with --strict'>)} { (SQ <'\n'> <'\n'> <'\tfor j in a b c d e f g\n'> <'\tdo\n'> <'\t\tfor i in 0 1 2 3 4 5 6 7 8 9\n'> <'\t\tdo\n'> <'\t\t\to=$(echo $j$i | git hash-object -w --stdin) &&\n'> <'\t\t\techo "100644 $o\t0 $j$i"\n'> <'\t\tdone\n'> <'\tdone >LIST &&\n'> <'\trm -f .git/index &&\n'> <'\tgit update-index --index-info <LIST &&\n'> <'\tLIST=$(git write-tree) &&\n'> <'\trm -f .git/index &&\n'> <'\thead -n 10 LIST | git update-index --index-info &&\n'> <'\tLI=$(git write-tree) &&\n'> <'\trm -f .git/index &&\n'> <'\ttail -n 10 LIST | git update-index --index-info &&\n'> <'\tST=$(git write-tree) &&\n'> <'\tPACK5=$( git rev-list --objects "$LIST" "$LI" "$ST" | \\\n'> <'\t\tgit pack-objects test-5 ) &&\n'> <'\tPACK6=$( (\n'> <'\t\t\techo "$LIST"\n'> <'\t\t\techo "$LI"\n'> <'\t\t\techo "$ST"\n'> <'\t\t ) | git pack-objects test-6 ) &&\n'> <'\ttest_create_repo test-7 &&\n'> <'\t(\n'> <'\t\tcd test-7 &&\n'> <'\t\tgit index-pack --strict --stdin <../test-5-$PACK5.pack &&\n'> <'\t\tgit ls-tree -r $LIST &&\n'> <'\t\tgit ls-tree -r $LI &&\n'> <'\t\tgit ls-tree -r $ST\n'> <'\t) &&\n'> <'\ttest_create_repo test-8 &&\n'> <'\t(\n'> <'\t\t# tree-only into empty repo -- many unreachables\n'> <'\t\tcd test-8 &&\n'> <'\t\ttest_must_fail git index-pack --strict --stdin <../test-6-$PACK6.pack\n'> <'\t) &&\n'> <'\t(\n'> <'\t\t# already populated -- no unreachables\n'> <'\t\tcd test-7 &&\n'> <'\t\tgit index-pack --strict --stdin <../test-6-$PACK6.pack\n'> <'\t)\n'> ) } ) (C {(test_expect_success)} {(SQ <'honor pack.packSizeLimit'>)} { (SQ <'\n'> <'\tgit config pack.packSizeLimit 3m &&\n'> <'\tpackname_10=$(git pack-objects test-10 <obj-list) &&\n'> <'\ttest 2 = $(ls test-10-*.pack | wc -l)\n'> ) } ) (C {(test_expect_success)} {(SQ <'verify resulting packs'>)} {(SQ <'\n'> <'\tgit verify-pack test-10-*.pack\n'>)} ) (C {(test_expect_success)} {(SQ <'tolerate packsizelimit smaller than biggest object'>)} { (SQ <'\n'> <'\tgit config pack.packSizeLimit 1 &&\n'> <'\tpackname_11=$(git pack-objects test-11 <obj-list) &&\n'> <'\ttest 5 = $(ls test-11-*.pack | wc -l)\n'> ) } ) (C {(test_expect_success)} {(SQ <'verify resulting packs'>)} {(SQ <'\n'> <'\tgit verify-pack test-11-*.pack\n'>)} ) (C {(test_expect_success)} {(SQ <'fake a SHA1 hash collision'>)} { (SQ <'test -f\t.git/objects/c8/2de19312b6c3695c0c18f70709a6c535682a67 &&\n'> <' cp -f\t.git/objects/9d/235ed07cd19811a6ceb342de82f190e49c9f68 \\\n'> <'\t\t.git/objects/c8/2de19312b6c3695c0c18f70709a6c535682a67'> ) } ) (C {(test_expect_success)} {(SQ <'make sure index-pack detects the SHA1 collision'>)} { (SQ <'test_must_fail git index-pack -o bad.idx test-3.pack 2>msg &&\n'> <' test_i18ngrep "SHA1 COLLISION FOUND" msg'> ) } ) (C {(test_expect_success)} {(SQ <'make sure index-pack detects the SHA1 collision (large blobs)'>)} { (SQ < 'test_must_fail git -c core.bigfilethreshold=1 index-pack -o bad.idx test-3.pack 2>msg &&\n' > <' test_i18ngrep "SHA1 COLLISION FOUND" msg'> ) } ) (C {(test_done)}) ] )