2 # Copyright (c) 2011, Google Inc.
4 test_description
='adding and checking out large blobs'
8 test_expect_success setup
'
9 # clone does not allow us to pass core.bigfilethreshold to
10 # new repos, so set core.bigfilethreshold globally
11 git config --global core.bigfilethreshold 200k &&
12 perl -e "print \"\\0\" x 2048000; print \"X\\n\";" > large1 &&
13 perl -e "print \"\\0\" x 2048000; print \"X\\n\";" > large2 &&
14 perl -e "print \"\\0\" x 2048000; print \"X\\n\";" > large3 &&
15 perl -e "print \"\\0\" x 2560000; print \"Y\\n\";" > huge &&
16 GIT_ALLOC_LIMIT=1500 &&
17 export GIT_ALLOC_LIMIT
20 test_expect_success
'add a large file or two' '
21 git add large1 huge large2 &&
22 # make sure we got a single packfile and no loose objects
24 for p in .git/objects/pack/pack-*.pack
26 count=$(( $count + 1 ))
27 if test -f "$p" && idx=${p%.pack}.idx && test -f "$idx"
35 cnt=$(git show-index <"$idx" | wc -l) &&
37 for l in .git/objects/??/??????????????????????????????????????
39 test -f "$l" || continue
44 # attempt to add another copy of the same
47 for p in .git/objects/pack/pack-*.pack
49 count=$(( $count + 1 ))
50 if test -f "$p" && idx=${p%.pack}.idx && test -f "$idx"
60 test_expect_success
'checkout a large file' '
61 large1=$(git rev-parse :large1) &&
62 git update-index --add --cacheinfo 100644 $large1 another &&
63 git checkout another &&
64 cmp large1 another ;# this must not be test_cmp
67 test_expect_success
'packsize limit' '
68 test_create_repo mid &&
71 git config core.bigfilethreshold 64k &&
72 git config pack.packsizelimit 256k &&
74 # mid1 and mid2 will fit within 256k limit but
75 # appending mid3 will bust the limit and will
76 # result in a separate packfile.
77 test-genrandom "a" $(( 66 * 1024 )) >mid1 &&
78 test-genrandom "b" $(( 80 * 1024 )) >mid2 &&
79 test-genrandom "c" $(( 128 * 1024 )) >mid3 &&
80 git add mid1 mid2 mid3 &&
83 for pi in .git/objects/pack/pack-*.idx
85 test -f "$pi" && count=$(( $count + 1 ))
90 git hash-object --stdin <mid1
91 git hash-object --stdin <mid2
92 git hash-object --stdin <mid3
96 for pi in .git/objects/pack/pack-*.idx
100 sed -e "s/^[0-9]* \([0-9a-f]*\) .*/\1/" |
103 test_cmp expect actual
107 test_expect_success
'diff --raw' '
108 git commit -q -m initial &&
109 echo modified >>large1 &&
111 git commit -q -m modified &&
115 test_expect_success
'hash-object' '
116 git hash-object large1
119 test_expect_success
'cat-file a large file' '
120 git cat-file blob :large1 >/dev/null
123 test_expect_success
'cat-file a large file from a tag' '
124 git tag -m largefile largefiletag :large1 &&
125 git cat-file blob largefiletag >/dev/null
128 test_expect_success
'git-show a large file' '
129 git show :large1 >/dev/null
133 test_expect_success
'index-pack' '
134 git clone file://"$(pwd)"/.git foo &&
135 GIT_DIR=non-existent git index-pack --strict --verify foo/.git/objects/pack/*.pack
138 test_expect_success
'repack' '
142 test_expect_success
'pack-objects with large loose object' '
143 SHA1=$(git hash-object huge) &&
144 test_create_repo loose &&
145 echo $SHA1 | git pack-objects --stdout |
146 GIT_ALLOC_LIMIT=0 GIT_DIR=loose/.git git unpack-objects &&
147 echo $SHA1 | GIT_DIR=loose/.git git pack-objects pack &&
148 test_create_repo packed &&
149 mv pack-* packed/.git/objects/pack &&
150 GIT_DIR=packed/.git git cat-file blob $SHA1 >actual &&
154 test_expect_success
'tar achiving' '
155 git archive --format=tar HEAD >/dev/null
158 test_expect_success
'zip achiving, store only' '
159 git archive --format=zip -0 HEAD >/dev/null
162 test_expect_success
'zip achiving, deflate' '
163 git archive --format=zip HEAD >/dev/null