]>
Commit | Line | Data |
---|---|---|
4dd1fbc7 JH |
1 | #!/bin/sh |
2 | # Copyright (c) 2011, Google Inc. | |
3 | ||
4 | test_description='adding and checking out large blobs' | |
5 | ||
6 | . ./test-lib.sh | |
7 | ||
8de7eeb5 JH |
8 | # This should be moved to test-lib.sh together with the |
9 | # copy in t0021 after both topics have graduated to 'master'. | |
10 | file_size () { | |
5868bd86 | 11 | test-tool path-utils file-size "$1" |
8de7eeb5 JH |
12 | } |
13 | ||
4dd1fbc7 | 14 | test_expect_success setup ' |
d41489a6 NTND |
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 && | |
d0a042a1 JS |
18 | printf "%2000000s" X >large1 && |
19 | cp large1 large2 && | |
20 | cp large1 large3 && | |
21 | printf "%2500000s" Y >huge && | |
9927d962 | 22 | GIT_ALLOC_LIMIT=1500k && |
d41489a6 | 23 | export GIT_ALLOC_LIMIT |
4dd1fbc7 JH |
24 | ' |
25 | ||
8de7eeb5 JH |
26 | # add a large file with different settings |
27 | while read expect config | |
28 | do | |
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) && | |
33 | case "$expect" in | |
34 | small) test "$sz" -le 100000 ;; | |
35 | large) test "$sz" -ge 100000 ;; | |
36 | esac | |
37 | ' | |
38 | done <<\EOF | |
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 | |
47 | EOF | |
48 | ||
568508e7 JH |
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 | |
52 | bad= count=0 idx= && | |
53 | for p in .git/objects/pack/pack-*.pack | |
54 | do | |
55 | count=$(( $count + 1 )) | |
a51d9e8f RJ |
56 | if test_path_is_file "$p" && |
57 | idx=${p%.pack}.idx && test_path_is_file "$idx" | |
568508e7 JH |
58 | then |
59 | continue | |
60 | fi | |
61 | bad=t | |
62 | done && | |
63 | test -z "$bad" && | |
64 | test $count = 1 && | |
65 | cnt=$(git show-index <"$idx" | wc -l) && | |
66 | test $cnt = 2 && | |
a1142963 | 67 | for l in .git/objects/$OIDPATH_REGEX |
568508e7 | 68 | do |
a51d9e8f | 69 | test_path_is_file "$l" || continue |
568508e7 JH |
70 | bad=t |
71 | done && | |
72 | test -z "$bad" && | |
73 | ||
74 | # attempt to add another copy of the same | |
75 | git add large3 && | |
76 | bad= count=0 && | |
77 | for p in .git/objects/pack/pack-*.pack | |
78 | do | |
79 | count=$(( $count + 1 )) | |
a51d9e8f RJ |
80 | if test_path_is_file "$p" && |
81 | idx=${p%.pack}.idx && test_path_is_file "$idx" | |
568508e7 JH |
82 | then |
83 | continue | |
84 | fi | |
85 | bad=t | |
86 | done && | |
87 | test -z "$bad" && | |
88 | test $count = 1 | |
4dd1fbc7 JH |
89 | ' |
90 | ||
91 | test_expect_success 'checkout a large file' ' | |
568508e7 JH |
92 | large1=$(git rev-parse :large1) && |
93 | git update-index --add --cacheinfo 100644 $large1 another && | |
4dd1fbc7 | 94 | git checkout another && |
d0a042a1 | 95 | test_cmp large1 another |
568508e7 JH |
96 | ' |
97 | ||
98 | test_expect_success 'packsize limit' ' | |
99 | test_create_repo mid && | |
100 | ( | |
101 | cd mid && | |
102 | git config core.bigfilethreshold 64k && | |
103 | git config pack.packsizelimit 256k && | |
104 | ||
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. | |
c680668d NTND |
108 | test-tool genrandom "a" $(( 66 * 1024 )) >mid1 && |
109 | test-tool genrandom "b" $(( 80 * 1024 )) >mid2 && | |
110 | test-tool genrandom "c" $(( 128 * 1024 )) >mid3 && | |
568508e7 JH |
111 | git add mid1 mid2 mid3 && |
112 | ||
f2deabfc | 113 | count=0 && |
568508e7 JH |
114 | for pi in .git/objects/pack/pack-*.idx |
115 | do | |
a51d9e8f | 116 | test_path_is_file "$pi" && count=$(( $count + 1 )) |
568508e7 JH |
117 | done && |
118 | test $count = 2 && | |
119 | ||
120 | ( | |
f2deabfc ES |
121 | git hash-object --stdin <mid1 && |
122 | git hash-object --stdin <mid2 && | |
568508e7 JH |
123 | git hash-object --stdin <mid3 |
124 | ) | | |
125 | sort >expect && | |
126 | ||
127 | for pi in .git/objects/pack/pack-*.idx | |
128 | do | |
129 | git show-index <"$pi" | |
130 | done | | |
131 | sed -e "s/^[0-9]* \([0-9a-f]*\) .*/\1/" | | |
132 | sort >actual && | |
133 | ||
134 | test_cmp expect actual | |
135 | ) | |
4dd1fbc7 JH |
136 | ' |
137 | ||
d41489a6 NTND |
138 | test_expect_success 'diff --raw' ' |
139 | git commit -q -m initial && | |
140 | echo modified >>large1 && | |
141 | git add large1 && | |
142 | git commit -q -m modified && | |
143 | git diff --raw HEAD^ | |
144 | ' | |
145 | ||
6bf3b813 NTND |
146 | test_expect_success 'diff --stat' ' |
147 | git diff --stat HEAD^ HEAD | |
148 | ' | |
149 | ||
1aaf69e6 NTND |
150 | test_expect_success 'diff' ' |
151 | git diff HEAD^ HEAD >actual && | |
152 | grep "Binary files.*differ" actual | |
153 | ' | |
154 | ||
155 | test_expect_success 'diff --cached' ' | |
156 | git diff --cached HEAD^ >actual && | |
157 | grep "Binary files.*differ" actual | |
158 | ' | |
159 | ||
d41489a6 NTND |
160 | test_expect_success 'hash-object' ' |
161 | git hash-object large1 | |
162 | ' | |
163 | ||
00c8fd49 | 164 | test_expect_success 'cat-file a large file' ' |
d41489a6 NTND |
165 | git cat-file blob :large1 >/dev/null |
166 | ' | |
167 | ||
00c8fd49 | 168 | test_expect_success 'cat-file a large file from a tag' ' |
d41489a6 NTND |
169 | git tag -m largefile largefiletag :large1 && |
170 | git cat-file blob largefiletag >/dev/null | |
171 | ' | |
172 | ||
74775a09 | 173 | test_expect_success 'git-show a large file' ' |
d41489a6 NTND |
174 | git show :large1 >/dev/null |
175 | ||
176 | ' | |
177 | ||
9ec2dde9 | 178 | test_expect_success 'index-pack' ' |
714c71b2 | 179 | git clone file://"$(pwd)"/.git foo && |
793731f7 | 180 | GIT_DIR=non-existent git index-pack --object-format=$(test_oid algo) \ |
181 | --strict --verify foo/.git/objects/pack/*.pack | |
9ec2dde9 NTND |
182 | ' |
183 | ||
da591a7f | 184 | test_expect_success 'repack' ' |
d41489a6 NTND |
185 | git repack -ad |
186 | ' | |
187 | ||
cf2ba13a | 188 | test_expect_success 'pack-objects with large loose object' ' |
714c71b2 | 189 | SHA1=$(git hash-object huge) && |
cf2ba13a NTND |
190 | test_create_repo loose && |
191 | echo $SHA1 | git pack-objects --stdout | | |
192 | GIT_ALLOC_LIMIT=0 GIT_DIR=loose/.git git unpack-objects && | |
193 | echo $SHA1 | GIT_DIR=loose/.git git pack-objects pack && | |
194 | test_create_repo packed && | |
195 | mv pack-* packed/.git/objects/pack && | |
196 | GIT_DIR=packed/.git git cat-file blob $SHA1 >actual && | |
d0a042a1 | 197 | test_cmp huge actual |
cf2ba13a NTND |
198 | ' |
199 | ||
4dc8b1c1 | 200 | test_expect_success 'tar archiving' ' |
5544049d NTND |
201 | git archive --format=tar HEAD >/dev/null |
202 | ' | |
203 | ||
4dc8b1c1 | 204 | test_expect_success 'zip archiving, store only' ' |
2158f883 RS |
205 | git archive --format=zip -0 HEAD >/dev/null |
206 | ' | |
207 | ||
4dc8b1c1 | 208 | test_expect_success 'zip archiving, deflate' ' |
c743c215 RS |
209 | git archive --format=zip HEAD >/dev/null |
210 | ' | |
211 | ||
ec9d2249 NTND |
212 | test_expect_success 'fsck large blobs' ' |
213 | git fsck 2>err && | |
214 | test_must_be_empty err | |
735efde8 NTND |
215 | ' |
216 | ||
4dd1fbc7 | 217 | test_done |