(command.CommandList
  children: [
    (command.ShAssignment
      pairs: [
        (assign_pair
          lhs: (sh_lhs_expr.Name name:test_description)
          op: assign_op.Equal
          rhs: {(SQ <'check receive input limits'>)}
          spids: [4]
        )
      ]
    )
    (C {<.>} {<'./test-lib.sh'>})
    (command.ShFunction
      name: test_pack_input_limit
      body: 
        (BraceGroup
          children: [
            (command.Case
              to_match: {(DQ ($ Id.VSub_Number '$1'))}
              arms: [
                (case_arm
                  pat_list: [{<index>}]
                  action: [
                    (command.ShAssignment
                      pairs: [
                        (assign_pair
                          lhs: (sh_lhs_expr.Name name:unpack_limit)
                          op: assign_op.Equal
                          rhs: {<1>}
                          spids: [44]
                        )
                      ]
                    )
                  ]
                  spids: [41 42 47 -1]
                )
                (case_arm
                  pat_list: [{<unpack>}]
                  action: [
                    (command.ShAssignment
                      pairs: [
                        (assign_pair
                          lhs: (sh_lhs_expr.Name name:unpack_limit)
                          op: assign_op.Equal
                          rhs: {<10000>}
                          spids: [53]
                        )
                      ]
                    )
                  ]
                  spids: [50 51 56 -1]
                )
              ]
            )
            (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 '> ($ Id.VSub_DollarName '$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'>
                )
              }
            )
          ]
        )
    )
    (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>})
  ]
)