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 '
15 # clone does not allow us to pass core.bigfilethreshold to
16 # new repos, so set core.bigfilethreshold globally
17 git config --global core.bigfilethreshold 200k &&
18 printf "%2000000s" X >large1 &&
21 printf "%2500000s" Y >huge &&
22 GIT_ALLOC_LIMIT=1500k &&
23 export GIT_ALLOC_LIMIT
26 # add a large file with different settings
27 while read expect config
29 test_expect_success "add with $config" '
30 test_when_finished "rm -f .git/objects/pack/pack-*.* .git/index" &&
31 git $config add large1 &&
32 sz=$(file_size .git/objects/pack/pack-*.pack) &&
34 small) test "$sz" -le 100000 ;;
35 large) test "$sz" -ge 100000 ;;
39 large -c core.compression=0
40 small -c core.compression=9
41 large -c core.compression=0 -c pack.compression=0
42 large -c core.compression=9 -c pack.compression=0
43 small -c core.compression=0 -c pack.compression=9
44 small -c core.compression=9 -c pack.compression=9
45 large -c pack.compression=0
46 small -c pack.compression=9
49 test_expect_success 'add a large file or two' '
50 git add large1 huge large2 &&
51 # make sure we got a single packfile and no loose objects
53 for p in .git/objects/pack/pack-*.pack
55 count=$(( $count + 1 ))
56 if test_path_is_file "$p" &&
57 idx=${p%.pack}.idx && test_path_is_file "$idx"
65 cnt=$(git show-index <"$idx" | wc -l) &&
67 for l in .git/objects/??/??????????????????????????????????????
69 test_path_is_file "$l" || continue
74 # attempt to add another copy of the same
77 for p in .git/objects/pack/pack-*.pack
79 count=$(( $count + 1 ))
80 if test_path_is_file "$p" &&
81 idx=${p%.pack}.idx && test_path_is_file "$idx"
91 test_expect_success 'checkout a large file' '
92 large1=$(git rev-parse :large1) &&
93 git update-index --add --cacheinfo 100644 $large1 another &&
94 git checkout another &&
95 test_cmp large1 another
98 test_expect_success 'packsize limit' '
99 test_create_repo mid &&
102 git config core.bigfilethreshold 64k &&
103 git config pack.packsizelimit 256k &&
105 # mid1 and mid2 will fit within 256k limit but
106 # appending mid3 will bust the limit and will
107 # result in a separate packfile.
108 test-tool genrandom "a" $(( 66 * 1024 )) >mid1 &&
109 test-tool genrandom "b" $(( 80 * 1024 )) >mid2 &&
110 test-tool genrandom "c" $(( 128 * 1024 )) >mid3 &&
111 git add mid1 mid2 mid3 &&
114 for pi in .git/objects/pack/pack-*.idx
116 test_path_is_file "$pi" && count=$(( $count + 1 ))
121 git hash-object --stdin <mid1 &&
122 git hash-object --stdin <mid2 &&
123 git hash-object --stdin <mid3
127 for pi in .git/objects/pack/pack-*.idx
129 git show-index <"$pi"
131 sed -e "s/^[0-9]* \([0-9a-f]*\) .*/\1/" |
134 test_cmp expect actual
138 test_expect_success 'diff --raw' '
139 git commit -q -m initial &&
140 echo modified >>large1 &&
142 git commit -q -m modified &&
146 test_expect_success 'diff --stat' '
147 git diff --stat HEAD^ HEAD
150 test_expect_success 'diff' '
151 git diff HEAD^ HEAD >actual &&
152 grep "Binary files.*differ" actual
155 test_expect_success 'diff --cached' '
156 git diff --cached HEAD^ >actual &&
157 grep "Binary files.*differ" actual
160 test_expect_success 'hash-object' '
161 git hash-object large1
164 test_expect_success 'cat-file a large file' '
165 git cat-file blob :large1 >/dev/null
168 test_expect_success 'cat-file a large file from a tag' '
169 git tag -m largefile largefiletag :large1 &&
170 git cat-file blob largefiletag >/dev/null
173 test_expect_success 'git-show a large file' '
174 git show :large1 >/dev/null
178 test_expect_success 'index-pack' '
179 git clone file://"$(pwd)"/.git foo &&
180 GIT_DIR=non-existent git index-pack --strict --verify foo/.git/objects/pack/*.pack
183 test_expect_success 'repack' '
187 test_expect_success 'pack-objects with large loose object' '
188 SHA1=$(git hash-object huge) &&
189 test_create_repo loose &&
190 echo $SHA1 | git pack-objects --stdout |
191 GIT_ALLOC_LIMIT=0 GIT_DIR=loose/.git git unpack-objects &&
192 echo $SHA1 | GIT_DIR=loose/.git git pack-objects pack &&
193 test_create_repo packed &&
194 mv pack-* packed/.git/objects/pack &&
195 GIT_DIR=packed/.git git cat-file blob $SHA1 >actual &&
199 test_expect_success 'tar archiving' '
200 git archive --format=tar HEAD >/dev/null
203 test_expect_success 'zip archiving, store only' '
204 git archive --format=zip -0 HEAD >/dev/null
207 test_expect_success 'zip archiving, deflate' '
208 git archive --format=zip HEAD >/dev/null
211 test_expect_success 'fsck large blobs' '
213 test_must_be_empty err