2 # Copyright (c) 2011, Google Inc.
4 test_description='adding and checking out large blobs'
8 # This should be moved to test-lib.sh together with the
9 # copy in t0021 after both topics have graduated to 'master'.
11 test-tool path-utils file-size "$1"
14 test_expect_success setup '
16 # clone does not allow us to pass core.bigfilethreshold to
17 # new repos, so set core.bigfilethreshold globally
18 git config --global core.bigfilethreshold 200k &&
19 printf "%2000000s" X >large1 &&
22 printf "%2500000s" Y >huge &&
23 GIT_ALLOC_LIMIT=1500k &&
24 export GIT_ALLOC_LIMIT
27 # add a large file with different settings
28 while read expect config
30 test_expect_success "add with $config" '
31 test_when_finished "rm -f .git/objects/pack/pack-*.* .git/index" &&
32 git $config add large1 &&
33 sz=$(file_size .git/objects/pack/pack-*.pack) &&
35 small) test "$sz" -le 100000 ;;
36 large) test "$sz" -ge 100000 ;;
40 large -c core.compression=0
41 small -c core.compression=9
42 large -c core.compression=0 -c pack.compression=0
43 large -c core.compression=9 -c pack.compression=0
44 small -c core.compression=0 -c pack.compression=9
45 small -c core.compression=9 -c pack.compression=9
46 large -c pack.compression=0
47 small -c pack.compression=9
50 test_expect_success 'add a large file or two' '
51 git add large1 huge large2 &&
52 # make sure we got a single packfile and no loose objects
54 for p in .git/objects/pack/pack-*.pack
56 count=$(( $count + 1 ))
57 if test_path_is_file "$p" &&
58 idx=${p%.pack}.idx && test_path_is_file "$idx"
66 cnt=$(git show-index <"$idx" | wc -l) &&
68 for l in .git/objects/$OIDPATH_REGEX
70 test_path_is_file "$l" || continue
75 # attempt to add another copy of the same
78 for p in .git/objects/pack/pack-*.pack
80 count=$(( $count + 1 ))
81 if test_path_is_file "$p" &&
82 idx=${p%.pack}.idx && test_path_is_file "$idx"
92 test_expect_success 'checkout a large file' '
93 large1=$(git rev-parse :large1) &&
94 git update-index --add --cacheinfo 100644 $large1 another &&
95 git checkout another &&
96 test_cmp large1 another
99 test_expect_success 'packsize limit' '
100 test_create_repo mid &&
103 git config core.bigfilethreshold 64k &&
104 git config pack.packsizelimit 256k &&
106 # mid1 and mid2 will fit within 256k limit but
107 # appending mid3 will bust the limit and will
108 # result in a separate packfile.
109 test-tool genrandom "a" $(( 66 * 1024 )) >mid1 &&
110 test-tool genrandom "b" $(( 80 * 1024 )) >mid2 &&
111 test-tool genrandom "c" $(( 128 * 1024 )) >mid3 &&
112 git add mid1 mid2 mid3 &&
115 for pi in .git/objects/pack/pack-*.idx
117 test_path_is_file "$pi" && count=$(( $count + 1 ))
122 git hash-object --stdin <mid1 &&
123 git hash-object --stdin <mid2 &&
124 git hash-object --stdin <mid3
128 for pi in .git/objects/pack/pack-*.idx
130 git show-index <"$pi"
132 sed -e "s/^[0-9]* \([0-9a-f]*\) .*/\1/" |
135 test_cmp expect actual
139 test_expect_success 'diff --raw' '
140 git commit -q -m initial &&
141 echo modified >>large1 &&
143 git commit -q -m modified &&
147 test_expect_success 'diff --stat' '
148 git diff --stat HEAD^ HEAD
151 test_expect_success 'diff' '
152 git diff HEAD^ HEAD >actual &&
153 grep "Binary files.*differ" actual
156 test_expect_success 'diff --cached' '
157 git diff --cached HEAD^ >actual &&
158 grep "Binary files.*differ" actual
161 test_expect_success 'hash-object' '
162 git hash-object large1
165 test_expect_success 'cat-file a large file' '
166 git cat-file blob :large1 >/dev/null
169 test_expect_success 'cat-file a large file from a tag' '
170 git tag -m largefile largefiletag :large1 &&
171 git cat-file blob largefiletag >/dev/null
174 test_expect_success 'git-show a large file' '
175 git show :large1 >/dev/null
179 test_expect_success 'index-pack' '
180 git clone file://"$(pwd)"/.git foo &&
181 GIT_DIR=non-existent git index-pack --object-format=$(test_oid algo) \
182 --strict --verify foo/.git/objects/pack/*.pack
185 test_expect_success 'repack' '
189 test_expect_success 'pack-objects with large loose object' '
190 SHA1=$(git hash-object huge) &&
191 test_create_repo loose &&
192 echo $SHA1 | git pack-objects --stdout |
193 GIT_ALLOC_LIMIT=0 GIT_DIR=loose/.git git unpack-objects &&
194 echo $SHA1 | GIT_DIR=loose/.git git pack-objects pack &&
195 test_create_repo packed &&
196 mv pack-* packed/.git/objects/pack &&
197 GIT_DIR=packed/.git git cat-file blob $SHA1 >actual &&
201 test_expect_success 'tar archiving' '
202 git archive --format=tar HEAD >/dev/null
205 test_expect_success 'zip archiving, store only' '
206 git archive --format=zip -0 HEAD >/dev/null
209 test_expect_success 'zip archiving, deflate' '
210 git archive --format=zip HEAD >/dev/null
213 test_expect_success 'fsck large blobs' '
215 test_must_be_empty err