]> git.ipfire.org Git - thirdparty/git.git/blame - t/t5546-receive-limits.sh
The third batch
[thirdparty/git.git] / t / t5546-receive-limits.sh
CommitLineData
c08db5a2
JK
1#!/bin/sh
2
3test_description='check receive input limits'
c65d18cb
ÆAB
4
5TEST_PASSES_SANITIZE_LEAK=true
c08db5a2
JK
6. ./test-lib.sh
7
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`.
11
f3d33f8c
JH
12validate_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;
23 }
24}
25
c08db5a2 26test_pack_input_limit () {
f3d33f8c
JH
27 store_type=$1
28
29 case "$store_type" in
30 index) unpack_limit=1 other_limit=10000 ;;
31 unpack) unpack_limit=10000 other_limit=1 ;;
c08db5a2
JK
32 esac
33
34 test_expect_success 'prepare destination repository' '
35 rm -fr dest &&
36 git --bare init dest
37 '
38
39 test_expect_success "set unpacklimit to $unpack_limit" '
40 git --git-dir=dest config receive.unpacklimit "$unpack_limit"
41 '
42
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
46 '
47
48 test_expect_success 'bumping limit to 4k allows push' '
49 git --git-dir=dest config receive.maxInputSize 4k &&
50 git push dest HEAD
51 '
52
53 test_expect_success 'prepare destination repository (again)' '
54 rm -fr dest &&
55 git --bare init dest
56 '
57
58 test_expect_success 'lifting the limit allows push' '
59 git --git-dir=dest config receive.maxInputSize 0 &&
60 git push dest HEAD
61 '
f3d33f8c
JH
62
63 test_expect_success 'prepare destination repository (once more)' '
64 rm -fr dest &&
65 git --bare init dest
66 '
67
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
73 '
74
c08db5a2
JK
75}
76
77test_expect_success "create known-size (1024 bytes) commit" '
c680668d 78 test-tool genrandom foo 1024 >one-k &&
c08db5a2
JK
79 git add one-k &&
80 test_commit one-k
81'
82
83test_pack_input_limit index
84test_pack_input_limit unpack
85
86test_done