t/t3*: avoid redundant uses of cat
[alt-git.git] / t / t5546-receive-limits.sh
blob9fc9ba552f1db320a595dcf7b5b23c31b5c855b1
1 #!/bin/sh
3 test_description='check receive input limits'
5 TEST_PASSES_SANITIZE_LEAK=true
6 . ./test-lib.sh
8 # Let's run tests with different unpack limits: 1 and 10000
9 # When the limit is 1, `git receive-pack` will call `git index-pack`.
10 # When the limit is 10000, `git receive-pack` will call `git unpack-objects`.
12 validate_store_type () {
13 git -C dest count-objects -v >actual &&
14 case "$store_type" in
15 index)
16 grep "^count: 0$" actual ;;
17 unpack)
18 grep "^packs: 0$" actual ;;
19 esac || {
20 echo "store_type is $store_type"
21 cat actual
22 false;
26 test_pack_input_limit () {
27 store_type=$1
29 case "$store_type" in
30 index) unpack_limit=1 other_limit=10000 ;;
31 unpack) unpack_limit=10000 other_limit=1 ;;
32 esac
34 test_expect_success 'prepare destination repository' '
35 rm -fr dest &&
36 git --bare init dest
39 test_expect_success "set unpacklimit to $unpack_limit" '
40 git --git-dir=dest config receive.unpacklimit "$unpack_limit"
43 test_expect_success 'setting receive.maxInputSize to 512 rejects push' '
44 git --git-dir=dest config receive.maxInputSize 512 &&
45 test_must_fail git push dest HEAD
48 test_expect_success 'bumping limit to 4k allows push' '
49 git --git-dir=dest config receive.maxInputSize 4k &&
50 git push dest HEAD
53 test_expect_success 'prepare destination repository (again)' '
54 rm -fr dest &&
55 git --bare init dest
58 test_expect_success 'lifting the limit allows push' '
59 git --git-dir=dest config receive.maxInputSize 0 &&
60 git push dest HEAD
63 test_expect_success 'prepare destination repository (once more)' '
64 rm -fr dest &&
65 git --bare init dest
68 test_expect_success 'receive trumps transfer' '
69 git --git-dir=dest config receive.unpacklimit "$unpack_limit" &&
70 git --git-dir=dest config transfer.unpacklimit "$other_limit" &&
71 git push dest HEAD &&
72 validate_store_type
77 test_expect_success "create known-size (1024 bytes) commit" '
78 test-tool genrandom foo 1024 >one-k &&
79 git add one-k &&
80 test_commit one-k
83 test_pack_input_limit index
84 test_pack_input_limit unpack
86 test_done