#!/bin/sh global test_description := ''check receive input limits'' source ./test-lib.sh # Let's run tests with different unpack limits: 1 and 10000 # When the limit is 1, `git receive-pack` will call `git index-pack`. # When the limit is 10000, `git receive-pack` will call `git unpack-objects`. proc test_pack_input_limit { matchstr $1 { index { global unpack_limit := '1' } unpack { global unpack_limit := '10000' } } test_expect_success 'prepare destination repository' ' rm -fr dest && git --bare init dest ' test_expect_success "set unpacklimit to $unpack_limit" ' git --git-dir=dest config receive.unpacklimit "$unpack_limit" ' test_expect_success 'setting receive.maxInputSize to 512 rejects push' ' git --git-dir=dest config receive.maxInputSize 512 && test_must_fail git push dest HEAD ' test_expect_success 'bumping limit to 4k allows push' ' git --git-dir=dest config receive.maxInputSize 4k && git push dest HEAD ' test_expect_success 'prepare destination repository (again)' ' rm -fr dest && git --bare init dest ' test_expect_success 'lifting the limit allows push' ' git --git-dir=dest config receive.maxInputSize 0 && git push dest HEAD ' } test_expect_success "create known-size (1024 bytes) commit" ' test-genrandom foo 1024 >one-k && git add one-k && test_commit one-k ' test_pack_input_limit index test_pack_input_limit unpack test_done (CommandList children: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:test_description) op: Equal rhs: {(SQ <"check receive input limits">)} spids: [4] ) ] spids: [4] ) (C {(.)} {(./test-lib.sh)}) (FuncDef name: test_pack_input_limit body: (BraceGroup children: [ (Case to_match: {(DQ ($ VSub_Number "$1"))} arms: [ (case_arm pat_list: [{(index)}] action: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:unpack_limit) op: Equal rhs: {(1)} spids: [44] ) ] spids: [44] ) ] spids: [41 42 47 -1] ) (case_arm pat_list: [{(unpack)}] action: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:unpack_limit) op: Equal rhs: {(10000)} spids: [53] ) ] spids: [53] ) ] spids: [50 51 56 -1] ) ] spids: [32 38 59] ) (C {(test_expect_success)} {(SQ <"prepare destination repository">)} {(SQ <"\n"> <"\t\trm -fr dest &&\n"> <"\t\tgit --bare init dest\n"> <"\t">)} ) (C {(test_expect_success)} {(DQ ("set unpacklimit to ") ($ VSub_Name "$unpack_limit"))} { (SQ <"\n"> <"\t\tgit --git-dir=dest config receive.unpacklimit \"$unpack_limit\"\n"> <"\t"> ) } ) (C {(test_expect_success)} {(SQ <"setting receive.maxInputSize to 512 rejects push">)} { (SQ <"\n"> <"\t\tgit --git-dir=dest config receive.maxInputSize 512 &&\n"> <"\t\ttest_must_fail git push dest HEAD\n"> <"\t"> ) } ) (C {(test_expect_success)} {(SQ <"bumping limit to 4k allows push">)} { (SQ <"\n"> <"\t\tgit --git-dir=dest config receive.maxInputSize 4k &&\n"> <"\t\tgit push dest HEAD\n"> <"\t"> ) } ) (C {(test_expect_success)} {(SQ <"prepare destination repository (again)">)} {(SQ <"\n"> <"\t\trm -fr dest &&\n"> <"\t\tgit --bare init dest\n"> <"\t">)} ) (C {(test_expect_success)} {(SQ <"lifting the limit allows push">)} { (SQ <"\n"> <"\t\tgit --git-dir=dest config receive.maxInputSize 0 &&\n"> <"\t\tgit push dest HEAD\n"> <"\t"> ) } ) ] spids: [29] ) spids: [24 28] ) (C {(test_expect_success)} {(DQ ("create known-size (1024 bytes) commit"))} { (SQ <"\n"> <"\ttest-genrandom foo 1024 >one-k &&\n"> <"\tgit add one-k &&\n"> <"\ttest_commit one-k\n"> ) } ) (C {(test_pack_input_limit)} {(index)}) (C {(test_pack_input_limit)} {(unpack)}) (C {(test_done)}) ] )