]> git.ipfire.org Git - thirdparty/git.git/blob - t/t5546-receive-limits.sh
Merge branch 'jk/bundle-use-dash-for-stdfiles'
[thirdparty/git.git] / t / t5546-receive-limits.sh
1 #!/bin/sh
2
3 test_description='check receive input limits'
4
5 TEST_PASSES_SANITIZE_LEAK=true
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
12 test_pack_input_limit () {
13 case "$1" in
14 index) unpack_limit=1 ;;
15 unpack) unpack_limit=10000 ;;
16 esac
17
18 test_expect_success 'prepare destination repository' '
19 rm -fr dest &&
20 git --bare init dest
21 '
22
23 test_expect_success "set unpacklimit to $unpack_limit" '
24 git --git-dir=dest config receive.unpacklimit "$unpack_limit"
25 '
26
27 test_expect_success 'setting receive.maxInputSize to 512 rejects push' '
28 git --git-dir=dest config receive.maxInputSize 512 &&
29 test_must_fail git push dest HEAD
30 '
31
32 test_expect_success 'bumping limit to 4k allows push' '
33 git --git-dir=dest config receive.maxInputSize 4k &&
34 git push dest HEAD
35 '
36
37 test_expect_success 'prepare destination repository (again)' '
38 rm -fr dest &&
39 git --bare init dest
40 '
41
42 test_expect_success 'lifting the limit allows push' '
43 git --git-dir=dest config receive.maxInputSize 0 &&
44 git push dest HEAD
45 '
46 }
47
48 test_expect_success "create known-size (1024 bytes) commit" '
49 test-tool genrandom foo 1024 >one-k &&
50 git add one-k &&
51 test_commit one-k
52 '
53
54 test_pack_input_limit index
55 test_pack_input_limit unpack
56
57 test_done