t / t5546-receive-limits.shon commit Sync with maint (f6727b0)
   1#!/bin/sh
   2
   3test_description='check receive input limits'
   4. ./test-lib.sh
   5
   6# Let's run tests with different unpack limits: 1 and 10000
   7# When the limit is 1, `git receive-pack` will call `git index-pack`.
   8# When the limit is 10000, `git receive-pack` will call `git unpack-objects`.
   9
  10test_pack_input_limit () {
  11        case "$1" in
  12        index) unpack_limit=1 ;;
  13        unpack) unpack_limit=10000 ;;
  14        esac
  15
  16        test_expect_success 'prepare destination repository' '
  17                rm -fr dest &&
  18                git --bare init dest
  19        '
  20
  21        test_expect_success "set unpacklimit to $unpack_limit" '
  22                git --git-dir=dest config receive.unpacklimit "$unpack_limit"
  23        '
  24
  25        test_expect_success 'setting receive.maxInputSize to 512 rejects push' '
  26                git --git-dir=dest config receive.maxInputSize 512 &&
  27                test_must_fail git push dest HEAD
  28        '
  29
  30        test_expect_success 'bumping limit to 4k allows push' '
  31                git --git-dir=dest config receive.maxInputSize 4k &&
  32                git push dest HEAD
  33        '
  34
  35        test_expect_success 'prepare destination repository (again)' '
  36                rm -fr dest &&
  37                git --bare init dest
  38        '
  39
  40        test_expect_success 'lifting the limit allows push' '
  41                git --git-dir=dest config receive.maxInputSize 0 &&
  42                git push dest HEAD
  43        '
  44}
  45
  46test_expect_success "create known-size (1024 bytes) commit" '
  47        test-genrandom foo 1024 >one-k &&
  48        git add one-k &&
  49        test_commit one-k
  50'
  51
  52test_pack_input_limit index
  53test_pack_input_limit unpack
  54
  55test_done