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 printf "%2000000s" X >large1 &&
15 printf "%2500000s" Y >huge &&
16 GIT_ALLOC_LIMIT=1500k &&
17 export GIT_ALLOC_LIMIT
20 test_expect_success
'enter "large" codepath, with small core.bigFileThreshold' '
21 test_when_finished "rm -rf repo" &&
23 git init --bare repo &&
24 echo large | git -C repo hash-object -w --stdin &&
25 git -C repo -c core.bigfilethreshold=4 fsck
28 # add a large file with different settings
29 while read expect config
31 test_expect_success
"add with $config" '
32 test_when_finished "rm -f .git/objects/pack/pack-*.* .git/index" &&
33 git $config add large1 &&
34 sz=$(test_file_size .git/objects/pack/pack-*.pack) &&
36 small) test "$sz" -le 100000 ;;
37 large) test "$sz" -ge 100000 ;;
41 large
-c core.compression
=0
42 small
-c core.compression
=9
43 large
-c core.compression
=0 -c pack.compression
=0
44 large
-c core.compression
=9 -c pack.compression
=0
45 small
-c core.compression
=0 -c pack.compression
=9
46 small
-c core.compression
=9 -c pack.compression
=9
47 large
-c pack.compression
=0
48 small
-c pack.compression
=9
51 test_expect_success
'add a large file or two' '
52 git add large1 huge large2 &&
53 # make sure we got a single packfile and no loose objects
55 for p in .git/objects/pack/pack-*.pack
57 count=$(( $count + 1 ))
58 if test_path_is_file "$p" &&
59 idx=${p%.pack}.idx && test_path_is_file "$idx"
67 cnt=$(git show-index <"$idx" | wc -l) &&
69 for l in .git/objects/$OIDPATH_REGEX
71 test_path_is_file "$l" || continue
76 # attempt to add another copy of the same
79 for p in .git/objects/pack/pack-*.pack
81 count=$(( $count + 1 ))
82 if test_path_is_file "$p" &&
83 idx=${p%.pack}.idx && test_path_is_file "$idx"
93 test_expect_success
'checkout a large file' '
94 large1=$(git rev-parse :large1) &&
95 git update-index --add --cacheinfo 100644 $large1 another &&
96 git checkout another &&
97 test_cmp large1 another
100 test_expect_success
'packsize limit' '
101 test_create_repo mid &&
104 git config core.bigfilethreshold 64k &&
105 git config pack.packsizelimit 256k &&
107 # mid1 and mid2 will fit within 256k limit but
108 # appending mid3 will bust the limit and will
109 # result in a separate packfile.
110 test-tool genrandom "a" $(( 66 * 1024 )) >mid1 &&
111 test-tool genrandom "b" $(( 80 * 1024 )) >mid2 &&
112 test-tool genrandom "c" $(( 128 * 1024 )) >mid3 &&
113 git add mid1 mid2 mid3 &&
116 for pi in .git/objects/pack/pack-*.idx
118 test_path_is_file "$pi" && count=$(( $count + 1 ))
123 git hash-object --stdin <mid1 &&
124 git hash-object --stdin <mid2 &&
125 git hash-object --stdin <mid3
129 for pi in .git/objects/pack/pack-*.idx
131 git show-index <"$pi"
133 sed -e "s/^[0-9]* \([0-9a-f]*\) .*/\1/" |
136 test_cmp expect actual
140 test_expect_success
'diff --raw' '
141 git commit -q -m initial &&
142 echo modified >>large1 &&
144 git commit -q -m modified &&
148 test_expect_success
'diff --stat' '
149 git diff --stat HEAD^ HEAD
152 test_expect_success
'diff' '
153 git diff HEAD^ HEAD >actual &&
154 grep "Binary files.*differ" actual
157 test_expect_success
'diff --cached' '
158 git diff --cached HEAD^ >actual &&
159 grep "Binary files.*differ" actual
162 test_expect_success
'hash-object' '
163 git hash-object large1
166 test_expect_success
'cat-file a large file' '
167 git cat-file blob :large1 >/dev/null
170 test_expect_success
'cat-file a large file from a tag' '
171 git tag -m largefile largefiletag :large1 &&
172 git cat-file blob largefiletag >/dev/null
175 test_expect_success
'git-show a large file' '
176 git show :large1 >/dev/null
180 test_expect_success
'index-pack' '
181 git clone file://"$(pwd)"/.git foo &&
182 GIT_DIR=non-existent git index-pack --object-format=$(test_oid algo) \
183 --strict --verify foo/.git/objects/pack/*.pack
186 test_expect_success
'repack' '
190 test_expect_success
'pack-objects with large loose object' '
191 SHA1=$(git hash-object huge) &&
192 test_create_repo loose &&
193 echo $SHA1 | git pack-objects --stdout |
194 GIT_ALLOC_LIMIT=0 GIT_DIR=loose/.git git unpack-objects &&
195 echo $SHA1 | GIT_DIR=loose/.git git pack-objects pack &&
196 test_create_repo packed &&
197 mv pack-* packed/.git/objects/pack &&
198 GIT_DIR=packed/.git git cat-file blob $SHA1 >actual &&
202 test_expect_success
'tar archiving' '
203 git archive --format=tar HEAD >/dev/null
206 test_expect_success
'zip archiving, store only' '
207 git archive --format=zip -0 HEAD >/dev/null
210 test_expect_success
'zip archiving, deflate' '
211 git archive --format=zip HEAD >/dev/null
214 test_expect_success
'fsck large blobs' '
216 test_must_be_empty err