]>
git.ipfire.org Git - thirdparty/git.git/blob - t/t5317-pack-objects-filter-objects.sh
3 test_description
='git pack-objects using object filtering'
7 # Test blob:none filter.
9 test_expect_success
'setup r1' '
10 echo "{print \$1}" >print_1.awk &&
11 echo "{print \$2}" >print_2.awk &&
16 echo "This is file: $n" > r1/file.$n
18 git -C r1 commit -m "$n"
22 test_expect_success
'verify blob count in normal packfile' '
23 git -C r1 ls-files -s file.1 file.2 file.3 file.4 file.5 |
27 git -C r1 pack-objects --rev --stdout >all.pack <<-EOF &&
30 git -C r1 index-pack ../all.pack &&
32 git -C r1 verify-pack -v ../all.pack |
37 test_cmp expected observed
40 test_expect_success
'verify blob:none packfile has no blobs' '
41 git -C r1 pack-objects --rev --stdout --filter=blob:none >filter.pack <<-EOF &&
44 git -C r1 index-pack ../filter.pack &&
46 git -C r1 verify-pack -v ../filter.pack |
51 nr=$(wc -l <observed) &&
55 test_expect_success
'verify normal and blob:none packfiles have same commits/trees' '
56 git -C r1 verify-pack -v ../all.pack |
57 grep -E "commit|tree" |
61 git -C r1 verify-pack -v ../filter.pack |
62 grep -E "commit|tree" |
66 test_cmp expected observed
69 # Test blob:limit=<n>[kmg] filter.
70 # We boundary test around the size parameter. The filter is strictly less than
71 # the value, so size 500 and 1000 should have the same results, but 1001 should
74 test_expect_success
'setup r2' '
78 printf "%"$n"s" X > r2/large.$n
79 git -C r2 add large.$n
80 git -C r2 commit -m "$n"
84 test_expect_success
'verify blob count in normal packfile' '
85 git -C r2 ls-files -s large.1000 large.10000 |
89 git -C r2 pack-objects --rev --stdout >all.pack <<-EOF &&
92 git -C r2 index-pack ../all.pack &&
94 git -C r2 verify-pack -v ../all.pack |
99 test_cmp expected observed
102 test_expect_success
'verify blob:limit=500 omits all blobs' '
103 git -C r2 pack-objects --rev --stdout --filter=blob:limit=500 >filter.pack <<-EOF &&
106 git -C r2 index-pack ../filter.pack &&
108 git -C r2 verify-pack -v ../filter.pack |
113 nr=$(wc -l <observed) &&
117 test_expect_success
'verify blob:limit=1000' '
118 git -C r2 pack-objects --rev --stdout --filter=blob:limit=1000 >filter.pack <<-EOF &&
121 git -C r2 index-pack ../filter.pack &&
123 git -C r2 verify-pack -v ../filter.pack |
128 nr=$(wc -l <observed) &&
132 test_expect_success
'verify blob:limit=1001' '
133 git -C r2 ls-files -s large.1000 |
137 git -C r2 pack-objects --rev --stdout --filter=blob:limit=1001 >filter.pack <<-EOF &&
140 git -C r2 index-pack ../filter.pack &&
142 git -C r2 verify-pack -v ../filter.pack |
147 test_cmp expected observed
150 test_expect_success
'verify blob:limit=10001' '
151 git -C r2 ls-files -s large.1000 large.10000 |
155 git -C r2 pack-objects --rev --stdout --filter=blob:limit=10001 >filter.pack <<-EOF &&
158 git -C r2 index-pack ../filter.pack &&
160 git -C r2 verify-pack -v ../filter.pack |
165 test_cmp expected observed
168 test_expect_success
'verify blob:limit=1k' '
169 git -C r2 ls-files -s large.1000 |
173 git -C r2 pack-objects --rev --stdout --filter=blob:limit=1k >filter.pack <<-EOF &&
176 git -C r2 index-pack ../filter.pack &&
178 git -C r2 verify-pack -v ../filter.pack |
183 test_cmp expected observed
186 test_expect_success
'verify explicitly specifying oversized blob in input' '
187 git -C r2 ls-files -s large.1000 large.10000 |
191 git -C r2 pack-objects --rev --stdout --filter=blob:limit=1k >filter.pack <<-EOF &&
193 $(git -C r2 rev-parse HEAD:large.10000)
195 git -C r2 index-pack ../filter.pack &&
197 git -C r2 verify-pack -v ../filter.pack |
202 test_cmp expected observed
205 test_expect_success
'verify blob:limit=1m' '
206 git -C r2 ls-files -s large.1000 large.10000 |
210 git -C r2 pack-objects --rev --stdout --filter=blob:limit=1m >filter.pack <<-EOF &&
213 git -C r2 index-pack ../filter.pack &&
215 git -C r2 verify-pack -v ../filter.pack |
220 test_cmp expected observed
223 test_expect_success
'verify normal and blob:limit packfiles have same commits/trees' '
224 git -C r2 verify-pack -v ../all.pack |
225 grep -E "commit|tree" |
229 git -C r2 verify-pack -v ../filter.pack |
230 grep -E "commit|tree" |
234 test_cmp expected observed
237 # Test sparse:path=<path> filter.
238 # Use a local file containing a sparse-checkout specification to filter
239 # out blobs not required for the corresponding sparse-checkout. We do not
240 # require sparse-checkout to actually be enabled.
242 test_expect_success
'setup r3' '
245 for n in sparse1 sparse2
247 echo "This is file: $n" > r3/$n
249 echo "This is file: dir1/$n" > r3/dir1/$n
250 git -C r3 add dir1/$n
252 git -C r3 commit -m "sparse" &&
253 echo dir1/ >pattern1 &&
254 echo sparse1 >pattern2
257 test_expect_success
'verify blob count in normal packfile' '
258 git -C r3 ls-files -s sparse1 sparse2 dir1/sparse1 dir1/sparse2 |
262 git -C r3 pack-objects --rev --stdout >all.pack <<-EOF &&
265 git -C r3 index-pack ../all.pack &&
267 git -C r3 verify-pack -v ../all.pack |
272 test_cmp expected observed
275 test_expect_success
'verify sparse:path=pattern1' '
276 git -C r3 ls-files -s dir1/sparse1 dir1/sparse2 |
280 git -C r3 pack-objects --rev --stdout --filter=sparse:path=../pattern1 >filter.pack <<-EOF &&
283 git -C r3 index-pack ../filter.pack &&
285 git -C r3 verify-pack -v ../filter.pack |
290 test_cmp expected observed
293 test_expect_success
'verify normal and sparse:path=pattern1 packfiles have same commits/trees' '
294 git -C r3 verify-pack -v ../all.pack |
295 grep -E "commit|tree" |
299 git -C r3 verify-pack -v ../filter.pack |
300 grep -E "commit|tree" |
304 test_cmp expected observed
307 test_expect_success
'verify sparse:path=pattern2' '
308 git -C r3 ls-files -s sparse1 dir1/sparse1 |
312 git -C r3 pack-objects --rev --stdout --filter=sparse:path=../pattern2 >filter.pack <<-EOF &&
315 git -C r3 index-pack ../filter.pack &&
317 git -C r3 verify-pack -v ../filter.pack |
322 test_cmp expected observed
325 test_expect_success
'verify normal and sparse:path=pattern2 packfiles have same commits/trees' '
326 git -C r3 verify-pack -v ../all.pack |
327 grep -E "commit|tree" |
331 git -C r3 verify-pack -v ../filter.pack |
332 grep -E "commit|tree" |
336 test_cmp expected observed
339 # Test sparse:oid=<oid-ish> filter.
340 # Like sparse:path, but we get the sparse-checkout specification from
341 # a blob rather than a file on disk.
343 test_expect_success
'setup r4' '
346 for n in sparse1 sparse2
348 echo "This is file: $n" > r4/$n
350 echo "This is file: dir1/$n" > r4/dir1/$n
351 git -C r4 add dir1/$n
353 echo dir1/ >r4/pattern &&
354 git -C r4 add pattern &&
355 git -C r4 commit -m "pattern"
358 test_expect_success
'verify blob count in normal packfile' '
359 git -C r4 ls-files -s pattern sparse1 sparse2 dir1/sparse1 dir1/sparse2 |
363 git -C r4 pack-objects --rev --stdout >all.pack <<-EOF &&
366 git -C r4 index-pack ../all.pack &&
368 git -C r4 verify-pack -v ../all.pack |
373 test_cmp expected observed
376 test_expect_success
'verify sparse:oid=OID' '
377 git -C r4 ls-files -s dir1/sparse1 dir1/sparse2 |
381 oid=$(git -C r4 ls-files -s pattern | awk -f print_2.awk) &&
382 git -C r4 pack-objects --rev --stdout --filter=sparse:oid=$oid >filter.pack <<-EOF &&
385 git -C r4 index-pack ../filter.pack &&
387 git -C r4 verify-pack -v ../filter.pack |
392 test_cmp expected observed
395 test_expect_success
'verify sparse:oid=oid-ish' '
396 git -C r4 ls-files -s dir1/sparse1 dir1/sparse2 |
400 git -C r4 pack-objects --rev --stdout --filter=sparse:oid=master:pattern >filter.pack <<-EOF &&
403 git -C r4 index-pack ../filter.pack &&
405 git -C r4 verify-pack -v ../filter.pack |
410 test_cmp expected observed
413 # Delete some loose objects and use pack-objects, but WITHOUT any filtering.
414 # This models previously omitted objects that we did not receive.
416 test_expect_success
'setup r1 - delete loose blobs' '
417 git -C r1 ls-files -s file.1 file.2 file.3 file.4 file.5 |
421 for id in `cat expected | sed "s|..|&/|"`
423 rm r1/.git/objects/$id
427 test_expect_success
'verify pack-objects fails w/ missing objects' '
428 test_must_fail git -C r1 pack-objects --rev --stdout >miss.pack <<-EOF
433 test_expect_success
'verify pack-objects fails w/ --missing=error' '
434 test_must_fail git -C r1 pack-objects --rev --stdout --missing=error >miss.pack <<-EOF
439 test_expect_success
'verify pack-objects w/ --missing=allow-any' '
440 git -C r1 pack-objects --rev --stdout --missing=allow-any >miss.pack <<-EOF