]>
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 | ||
84356ff7 PW |
8 | test_expect_success 'core.bigFileThreshold must be non-negative' ' |
9 | test_must_fail git -c core.bigFileThreshold=-1 rev-parse >out 2>err && | |
10 | grep "bad numeric config value" err && | |
11 | test_must_be_empty out | |
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 | ||
168a937b ÆAB |
26 | test_expect_success 'enter "large" codepath, with small core.bigFileThreshold' ' |
27 | test_when_finished "rm -rf repo" && | |
28 | ||
29 | git init --bare repo && | |
30 | echo large | git -C repo hash-object -w --stdin && | |
31 | git -C repo -c core.bigfilethreshold=4 fsck | |
32 | ' | |
33 | ||
8de7eeb5 JH |
34 | # add a large file with different settings |
35 | while read expect config | |
36 | do | |
37 | test_expect_success "add with $config" ' | |
38 | test_when_finished "rm -f .git/objects/pack/pack-*.* .git/index" && | |
39 | git $config add large1 && | |
53b67a80 | 40 | sz=$(test_file_size .git/objects/pack/pack-*.pack) && |
8de7eeb5 JH |
41 | case "$expect" in |
42 | small) test "$sz" -le 100000 ;; | |
43 | large) test "$sz" -ge 100000 ;; | |
44 | esac | |
45 | ' | |
46 | done <<\EOF | |
47 | large -c core.compression=0 | |
48 | small -c core.compression=9 | |
49 | large -c core.compression=0 -c pack.compression=0 | |
50 | large -c core.compression=9 -c pack.compression=0 | |
51 | small -c core.compression=0 -c pack.compression=9 | |
52 | small -c core.compression=9 -c pack.compression=9 | |
53 | large -c pack.compression=0 | |
54 | small -c pack.compression=9 | |
55 | EOF | |
56 | ||
568508e7 JH |
57 | test_expect_success 'add a large file or two' ' |
58 | git add large1 huge large2 && | |
59 | # make sure we got a single packfile and no loose objects | |
03949e33 | 60 | count=0 idx= && |
568508e7 JH |
61 | for p in .git/objects/pack/pack-*.pack |
62 | do | |
74d2f569 | 63 | count=$(( $count + 1 )) && |
03949e33 ES |
64 | test_path_is_file "$p" && |
65 | idx=${p%.pack}.idx && | |
66 | test_path_is_file "$idx" || return 1 | |
568508e7 | 67 | done && |
568508e7 JH |
68 | test $count = 1 && |
69 | cnt=$(git show-index <"$idx" | wc -l) && | |
70 | test $cnt = 2 && | |
a1142963 | 71 | for l in .git/objects/$OIDPATH_REGEX |
568508e7 | 72 | do |
03949e33 | 73 | test_path_is_missing "$l" || return 1 |
568508e7 | 74 | done && |
568508e7 JH |
75 | |
76 | # attempt to add another copy of the same | |
77 | git add large3 && | |
78 | bad= count=0 && | |
79 | for p in .git/objects/pack/pack-*.pack | |
80 | do | |
74d2f569 | 81 | count=$(( $count + 1 )) && |
03949e33 ES |
82 | test_path_is_file "$p" && |
83 | idx=${p%.pack}.idx && | |
84 | test_path_is_file "$idx" || return 1 | |
568508e7 | 85 | done && |
568508e7 | 86 | test $count = 1 |
4dd1fbc7 JH |
87 | ' |
88 | ||
89 | test_expect_success 'checkout a large file' ' | |
568508e7 JH |
90 | large1=$(git rev-parse :large1) && |
91 | git update-index --add --cacheinfo 100644 $large1 another && | |
4dd1fbc7 | 92 | git checkout another && |
d0a042a1 | 93 | test_cmp large1 another |
568508e7 JH |
94 | ' |
95 | ||
96 | test_expect_success 'packsize limit' ' | |
97 | test_create_repo mid && | |
98 | ( | |
99 | cd mid && | |
100 | git config core.bigfilethreshold 64k && | |
101 | git config pack.packsizelimit 256k && | |
102 | ||
103 | # mid1 and mid2 will fit within 256k limit but | |
104 | # appending mid3 will bust the limit and will | |
105 | # result in a separate packfile. | |
c680668d NTND |
106 | test-tool genrandom "a" $(( 66 * 1024 )) >mid1 && |
107 | test-tool genrandom "b" $(( 80 * 1024 )) >mid2 && | |
108 | test-tool genrandom "c" $(( 128 * 1024 )) >mid3 && | |
568508e7 JH |
109 | git add mid1 mid2 mid3 && |
110 | ||
f2deabfc | 111 | count=0 && |
568508e7 JH |
112 | for pi in .git/objects/pack/pack-*.idx |
113 | do | |
db5875aa | 114 | test_path_is_file "$pi" && count=$(( $count + 1 )) || return 1 |
568508e7 JH |
115 | done && |
116 | test $count = 2 && | |
117 | ||
118 | ( | |
f2deabfc ES |
119 | git hash-object --stdin <mid1 && |
120 | git hash-object --stdin <mid2 && | |
568508e7 JH |
121 | git hash-object --stdin <mid3 |
122 | ) | | |
123 | sort >expect && | |
124 | ||
125 | for pi in .git/objects/pack/pack-*.idx | |
126 | do | |
db5875aa | 127 | git show-index <"$pi" || return 1 |
568508e7 JH |
128 | done | |
129 | sed -e "s/^[0-9]* \([0-9a-f]*\) .*/\1/" | | |
130 | sort >actual && | |
131 | ||
132 | test_cmp expect actual | |
133 | ) | |
4dd1fbc7 JH |
134 | ' |
135 | ||
d41489a6 NTND |
136 | test_expect_success 'diff --raw' ' |
137 | git commit -q -m initial && | |
138 | echo modified >>large1 && | |
139 | git add large1 && | |
140 | git commit -q -m modified && | |
141 | git diff --raw HEAD^ | |
142 | ' | |
143 | ||
6bf3b813 NTND |
144 | test_expect_success 'diff --stat' ' |
145 | git diff --stat HEAD^ HEAD | |
146 | ' | |
147 | ||
1aaf69e6 NTND |
148 | test_expect_success 'diff' ' |
149 | git diff HEAD^ HEAD >actual && | |
150 | grep "Binary files.*differ" actual | |
151 | ' | |
152 | ||
153 | test_expect_success 'diff --cached' ' | |
154 | git diff --cached HEAD^ >actual && | |
155 | grep "Binary files.*differ" actual | |
156 | ' | |
157 | ||
d41489a6 NTND |
158 | test_expect_success 'hash-object' ' |
159 | git hash-object large1 | |
160 | ' | |
161 | ||
00c8fd49 | 162 | test_expect_success 'cat-file a large file' ' |
d41489a6 NTND |
163 | git cat-file blob :large1 >/dev/null |
164 | ' | |
165 | ||
00c8fd49 | 166 | test_expect_success 'cat-file a large file from a tag' ' |
d41489a6 NTND |
167 | git tag -m largefile largefiletag :large1 && |
168 | git cat-file blob largefiletag >/dev/null | |
169 | ' | |
170 | ||
74775a09 | 171 | test_expect_success 'git-show a large file' ' |
d41489a6 NTND |
172 | git show :large1 >/dev/null |
173 | ||
174 | ' | |
175 | ||
9ec2dde9 | 176 | test_expect_success 'index-pack' ' |
714c71b2 | 177 | git clone file://"$(pwd)"/.git foo && |
793731f7 | 178 | GIT_DIR=non-existent git index-pack --object-format=$(test_oid algo) \ |
179 | --strict --verify foo/.git/objects/pack/*.pack | |
9ec2dde9 NTND |
180 | ' |
181 | ||
da591a7f | 182 | test_expect_success 'repack' ' |
d41489a6 NTND |
183 | git repack -ad |
184 | ' | |
185 | ||
cf2ba13a | 186 | test_expect_success 'pack-objects with large loose object' ' |
714c71b2 | 187 | SHA1=$(git hash-object huge) && |
cf2ba13a NTND |
188 | test_create_repo loose && |
189 | echo $SHA1 | git pack-objects --stdout | | |
190 | GIT_ALLOC_LIMIT=0 GIT_DIR=loose/.git git unpack-objects && | |
191 | echo $SHA1 | GIT_DIR=loose/.git git pack-objects pack && | |
192 | test_create_repo packed && | |
193 | mv pack-* packed/.git/objects/pack && | |
194 | GIT_DIR=packed/.git git cat-file blob $SHA1 >actual && | |
d0a042a1 | 195 | test_cmp huge actual |
cf2ba13a NTND |
196 | ' |
197 | ||
4dc8b1c1 | 198 | test_expect_success 'tar archiving' ' |
5544049d NTND |
199 | git archive --format=tar HEAD >/dev/null |
200 | ' | |
201 | ||
4dc8b1c1 | 202 | test_expect_success 'zip archiving, store only' ' |
2158f883 RS |
203 | git archive --format=zip -0 HEAD >/dev/null |
204 | ' | |
205 | ||
4dc8b1c1 | 206 | test_expect_success 'zip archiving, deflate' ' |
c743c215 RS |
207 | git archive --format=zip HEAD >/dev/null |
208 | ' | |
209 | ||
ec9d2249 NTND |
210 | test_expect_success 'fsck large blobs' ' |
211 | git fsck 2>err && | |
212 | test_must_be_empty err | |
735efde8 NTND |
213 | ' |
214 | ||
4dd1fbc7 | 215 | test_done |