]>
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 | ||
8 | test_expect_success setup ' | |
d41489a6 NTND |
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 && | |
568508e7 JH |
12 | echo X | dd of=large1 bs=1k seek=2000 && |
13 | echo X | dd of=large2 bs=1k seek=2000 && | |
14 | echo X | dd of=large3 bs=1k seek=2000 && | |
d41489a6 | 15 | echo Y | dd of=huge bs=1k seek=2500 && |
9927d962 | 16 | GIT_ALLOC_LIMIT=1500k && |
d41489a6 | 17 | export GIT_ALLOC_LIMIT |
4dd1fbc7 JH |
18 | ' |
19 | ||
568508e7 JH |
20 | test_expect_success 'add a large file or two' ' |
21 | git add large1 huge large2 && | |
22 | # make sure we got a single packfile and no loose objects | |
23 | bad= count=0 idx= && | |
24 | for p in .git/objects/pack/pack-*.pack | |
25 | do | |
26 | count=$(( $count + 1 )) | |
27 | if test -f "$p" && idx=${p%.pack}.idx && test -f "$idx" | |
28 | then | |
29 | continue | |
30 | fi | |
31 | bad=t | |
32 | done && | |
33 | test -z "$bad" && | |
34 | test $count = 1 && | |
35 | cnt=$(git show-index <"$idx" | wc -l) && | |
36 | test $cnt = 2 && | |
37 | for l in .git/objects/??/?????????????????????????????????????? | |
38 | do | |
39 | test -f "$l" || continue | |
40 | bad=t | |
41 | done && | |
42 | test -z "$bad" && | |
43 | ||
44 | # attempt to add another copy of the same | |
45 | git add large3 && | |
46 | bad= count=0 && | |
47 | for p in .git/objects/pack/pack-*.pack | |
48 | do | |
49 | count=$(( $count + 1 )) | |
50 | if test -f "$p" && idx=${p%.pack}.idx && test -f "$idx" | |
51 | then | |
52 | continue | |
53 | fi | |
54 | bad=t | |
55 | done && | |
56 | test -z "$bad" && | |
57 | test $count = 1 | |
4dd1fbc7 JH |
58 | ' |
59 | ||
60 | test_expect_success 'checkout a large file' ' | |
568508e7 JH |
61 | large1=$(git rev-parse :large1) && |
62 | git update-index --add --cacheinfo 100644 $large1 another && | |
4dd1fbc7 | 63 | git checkout another && |
568508e7 JH |
64 | cmp large1 another ;# this must not be test_cmp |
65 | ' | |
66 | ||
67 | test_expect_success 'packsize limit' ' | |
68 | test_create_repo mid && | |
69 | ( | |
70 | cd mid && | |
71 | git config core.bigfilethreshold 64k && | |
72 | git config pack.packsizelimit 256k && | |
73 | ||
74 | # mid1 and mid2 will fit within 256k limit but | |
75 | # appending mid3 will bust the limit and will | |
76 | # result in a separate packfile. | |
77 | test-genrandom "a" $(( 66 * 1024 )) >mid1 && | |
78 | test-genrandom "b" $(( 80 * 1024 )) >mid2 && | |
79 | test-genrandom "c" $(( 128 * 1024 )) >mid3 && | |
80 | git add mid1 mid2 mid3 && | |
81 | ||
82 | count=0 | |
83 | for pi in .git/objects/pack/pack-*.idx | |
84 | do | |
85 | test -f "$pi" && count=$(( $count + 1 )) | |
86 | done && | |
87 | test $count = 2 && | |
88 | ||
89 | ( | |
90 | git hash-object --stdin <mid1 | |
91 | git hash-object --stdin <mid2 | |
92 | git hash-object --stdin <mid3 | |
93 | ) | | |
94 | sort >expect && | |
95 | ||
96 | for pi in .git/objects/pack/pack-*.idx | |
97 | do | |
98 | git show-index <"$pi" | |
99 | done | | |
100 | sed -e "s/^[0-9]* \([0-9a-f]*\) .*/\1/" | | |
101 | sort >actual && | |
102 | ||
103 | test_cmp expect actual | |
104 | ) | |
4dd1fbc7 JH |
105 | ' |
106 | ||
d41489a6 NTND |
107 | test_expect_success 'diff --raw' ' |
108 | git commit -q -m initial && | |
109 | echo modified >>large1 && | |
110 | git add large1 && | |
111 | git commit -q -m modified && | |
112 | git diff --raw HEAD^ | |
113 | ' | |
114 | ||
6bf3b813 NTND |
115 | test_expect_success 'diff --stat' ' |
116 | git diff --stat HEAD^ HEAD | |
117 | ' | |
118 | ||
1aaf69e6 NTND |
119 | test_expect_success 'diff' ' |
120 | git diff HEAD^ HEAD >actual && | |
121 | grep "Binary files.*differ" actual | |
122 | ' | |
123 | ||
124 | test_expect_success 'diff --cached' ' | |
125 | git diff --cached HEAD^ >actual && | |
126 | grep "Binary files.*differ" actual | |
127 | ' | |
128 | ||
d41489a6 NTND |
129 | test_expect_success 'hash-object' ' |
130 | git hash-object large1 | |
131 | ' | |
132 | ||
00c8fd49 | 133 | test_expect_success 'cat-file a large file' ' |
d41489a6 NTND |
134 | git cat-file blob :large1 >/dev/null |
135 | ' | |
136 | ||
00c8fd49 | 137 | test_expect_success 'cat-file a large file from a tag' ' |
d41489a6 NTND |
138 | git tag -m largefile largefiletag :large1 && |
139 | git cat-file blob largefiletag >/dev/null | |
140 | ' | |
141 | ||
74775a09 | 142 | test_expect_success 'git-show a large file' ' |
d41489a6 NTND |
143 | git show :large1 >/dev/null |
144 | ||
145 | ' | |
146 | ||
9ec2dde9 | 147 | test_expect_success 'index-pack' ' |
714c71b2 | 148 | git clone file://"$(pwd)"/.git foo && |
9ec2dde9 NTND |
149 | GIT_DIR=non-existent git index-pack --strict --verify foo/.git/objects/pack/*.pack |
150 | ' | |
151 | ||
da591a7f | 152 | test_expect_success 'repack' ' |
d41489a6 NTND |
153 | git repack -ad |
154 | ' | |
155 | ||
cf2ba13a | 156 | test_expect_success 'pack-objects with large loose object' ' |
714c71b2 | 157 | SHA1=$(git hash-object huge) && |
cf2ba13a NTND |
158 | test_create_repo loose && |
159 | echo $SHA1 | git pack-objects --stdout | | |
160 | GIT_ALLOC_LIMIT=0 GIT_DIR=loose/.git git unpack-objects && | |
161 | echo $SHA1 | GIT_DIR=loose/.git git pack-objects pack && | |
162 | test_create_repo packed && | |
163 | mv pack-* packed/.git/objects/pack && | |
164 | GIT_DIR=packed/.git git cat-file blob $SHA1 >actual && | |
165 | cmp huge actual | |
166 | ' | |
167 | ||
5544049d NTND |
168 | test_expect_success 'tar achiving' ' |
169 | git archive --format=tar HEAD >/dev/null | |
170 | ' | |
171 | ||
2158f883 RS |
172 | test_expect_success 'zip achiving, store only' ' |
173 | git archive --format=zip -0 HEAD >/dev/null | |
174 | ' | |
175 | ||
c743c215 RS |
176 | test_expect_success 'zip achiving, deflate' ' |
177 | git archive --format=zip HEAD >/dev/null | |
178 | ' | |
179 | ||
735efde8 NTND |
180 | test_expect_success 'fsck' ' |
181 | test_must_fail git fsck 2>err && | |
182 | n=$(grep "error: attempting to allocate .* over limit" err | wc -l) && | |
183 | test "$n" -gt 1 | |
184 | ' | |
185 | ||
4dd1fbc7 | 186 | test_done |