(command.CommandList
  children: [
    (command.Assignment
      keyword: Assign_None
      pairs: [
        (assign_pair
          lhs: (lhs_expr.LhsName name:test_description spids:[21])
          op: Equal
          rhs: {(SQ <'git apply boundary tests\n'> <'\n'>)}
          spids: [21]
        )
      ]
      spids: [21]
    )
    (C {(.)} {(./test-lib.sh)})
    (command.Assignment
      keyword: Assign_None
      pairs: [
        (assign_pair
          lhs: (lhs_expr.LhsName name:L spids:[32])
          op: Equal
          rhs: {(DQ ('c d e f g h i j k l m n o p q r s t u v w x'))}
          spids: [32]
        )
      ]
      spids: [32]
    )
    (C {(test_expect_success)} {(setup)} 
      {(SQ <'\n'> <'\tfor i in b '>) (DQ ($ VSub_Name '$L')) 
        (SQ <' y\n'> <'\tdo\n'> <'\t\techo $i\n'> <'\tdone >victim &&\n'> <'\tcat victim >original &&\n'> 
          <'\tgit update-index --add victim &&\n'> <'\n'> <'\t# add to the head\n'> <'\tfor i in a b '>
        ) (DQ ($ VSub_Name '$L')) 
        (SQ <' y\n'> <'\tdo\n'> <'\t\techo $i\n'> <'\tdone >victim &&\n'> 
          <'\tcat victim >add-a-expect &&\n'> <'\tgit diff victim >add-a-patch.with &&\n'> <'\tgit diff --unified=0 >add-a-patch.without &&\n'> 
          <'\n'> <'\t# insert at line two\n'> <'\tfor i in b a '>
        ) (DQ ($ VSub_Name '$L')) 
        (SQ <' y\n'> <'\tdo\n'> <'\t\techo $i\n'> <'\tdone >victim &&\n'> 
          <'\tcat victim >insert-a-expect &&\n'> <'\tgit diff victim >insert-a-patch.with &&\n'> 
          <'\tgit diff --unified=0 >insert-a-patch.without &&\n'> <'\n'> <'\t# modify at the head\n'> <'\tfor i in a '>
        ) (DQ ($ VSub_Name '$L')) 
        (SQ <' y\n'> <'\tdo\n'> <'\t\techo $i\n'> <'\tdone >victim &&\n'> 
          <'\tcat victim >mod-a-expect &&\n'> <'\tgit diff victim >mod-a-patch.with &&\n'> <'\tgit diff --unified=0 >mod-a-patch.without &&\n'> 
          <'\n'> <'\t# remove from the head\n'> <'\tfor i in '>
        ) (DQ ($ VSub_Name '$L')) 
        (SQ <' y\n'> <'\tdo\n'> <'\t\techo $i\n'> <'\tdone >victim &&\n'> 
          <'\tcat victim >del-a-expect &&\n'> <'\tgit diff victim >del-a-patch.with &&\n'> <'\tgit diff --unified=0 >del-a-patch.without &&\n'> 
          <'\n'> <'\t# add to the tail\n'> <'\tfor i in b '>
        ) (DQ ($ VSub_Name '$L')) 
        (SQ <' y z\n'> <'\tdo\n'> <'\t\techo $i\n'> <'\tdone >victim &&\n'> 
          <'\tcat victim >add-z-expect &&\n'> <'\tgit diff victim >add-z-patch.with &&\n'> <'\tgit diff --unified=0 >add-z-patch.without &&\n'> 
          <'\n'> <'\t# modify at the tail\n'> <'\tfor i in b '>
        ) (DQ ($ VSub_Name '$L')) 
        (SQ <' z\n'> <'\tdo\n'> <'\t\techo $i\n'> <'\tdone >victim &&\n'> 
          <'\tcat victim >mod-z-expect &&\n'> <'\tgit diff victim >mod-z-patch.with &&\n'> <'\tgit diff --unified=0 >mod-z-patch.without &&\n'> 
          <'\n'> <'\t# remove from the tail\n'> <'\tfor i in b '>
        ) (DQ ($ VSub_Name '$L')) 
        (SQ <'\n'> <'\tdo\n'> <'\t\techo $i\n'> <'\tdone >victim &&\n'> 
          <'\tcat victim >del-z-expect &&\n'> <'\tgit diff victim >del-z-patch.with &&\n'> <'\tgit diff --unified=0 >del-z-patch.without\n'> <'\n'> 
          <'\t# done\n'>
        )
      }
    )
    (command.ForEach
      iter_name: with
      iter_words: [{(with)} {(without)}]
      do_arg_iter: F
      body: 
        (command.DoGroup
          children: [
            (command.Case
              to_match: {(DQ ($ VSub_Name '$with'))}
              arms: [
                (case_arm
                  pat_list: [{(with)}]
                  action: [
                    (command.Assignment
                      keyword: Assign_None
                      pairs: [
                        (assign_pair
                          lhs: (lhs_expr.LhsName name:u spids:[191])
                          op: Equal
                          rhs: (word.EmptyWord)
                          spids: [191]
                        )
                      ]
                      spids: [191]
                    )
                  ]
                  spids: [188 189 193 16777215]
                )
                (case_arm
                  pat_list: [{(without)}]
                  action: [
                    (command.Assignment
                      keyword: Assign_None
                      pairs: [
                        (assign_pair
                          lhs: (lhs_expr.LhsName name:u spids:[199])
                          op: Equal
                          rhs: {(SQ <'--unidiff-zero '>)}
                          spids: [199]
                        )
                      ]
                      spids: [199]
                    )
                  ]
                  spids: [196 197 204 16777215]
                )
              ]
              spids: [179 185 207]
            )
            (command.ForEach
              iter_name: kind
              iter_words: [{(add-a)} {(add-z)} {(insert-a)} {(mod-a)} {(mod-z)} {(del-a)} {(del-z)}]
              do_arg_iter: F
              body: 
                (command.DoGroup
                  children: [
                    (C {(test_expect_success)} 
                      {
                        (DQ ('apply ') ($ VSub_Name '$kind') ('-patch ') ($ VSub_Name '$with') 
                          (' context')
                        )
                      } 
                      {
                        (SQ <'\n'> <'\t\t\tcat original >victim &&\n'> 
                          <'\t\t\tgit update-index victim &&\n'> <'\t\t\tgit apply --index '>
                        ) (DQ ($ VSub_Name '$u') ($ VSub_Name '$kind') (-patch.) ($ VSub_Name '$with')) 
                        (SQ <' &&\n'> <'\t\t\ttest_cmp '>) (DQ ($ VSub_Name '$kind')) (SQ <'-expect victim\n'> <'\t\t'>)
                      }
                    )
                  ]
                  spids: [231 269]
                )
              spids: [215 16777215]
            )
          ]
          spids: [176 271]
        )
      spids: [171 16777215]
    )
    (command.ForEach
      iter_name: kind
      iter_words: [{(add-a)} {(add-z)} {(insert-a)} {(mod-a)} {(mod-z)} {(del-a)} {(del-z)}]
      do_arg_iter: F
      body: 
        (command.DoGroup
          children: [
            (C {(rm)} {(-f)} {($ VSub_Name '$kind') (-ng.without)})
            (command.SimpleCommand
              words: [{(sed)} {(-e)} {(DQ ('s/^diff --git /diff /'))} {(-e)} {(SQ <'/^index /d'>)}]
              redirects: [
                (redir.Redir
                  op: <Redir_Less '<'>
                  fd: 16777215
                  arg_word: {($ VSub_Name '$kind') (-patch.without)}
                )
                (redir.Redir
                  op: <Redir_Great '>'>
                  fd: 16777215
                  arg_word: {($ VSub_Name '$kind') (-ng.without)}
                )
              ]
            )
            (C {(test_expect_success)} 
              {(DQ ('apply non-git ') ($ VSub_Name '$kind') ('-patch without context'))} 
              {
                (SQ <'\n'> <'\t\tcat original >victim &&\n'> <'\t\tgit update-index victim &&\n'> 
                  <'\t\tgit apply --unidiff-zero --index '>
                ) (DQ ($ VSub_Name '$kind') (-ng.without)) (SQ <' &&\n'> <'\t\ttest_cmp '>) (DQ ($ VSub_Name '$kind')) 
                (SQ <'-expect victim\n'> <'\t'>)
              }
            )
          ]
          spids: [294 362]
        )
      spids: [279 16777215]
    )
    (C {(test_expect_success)} {(SQ <'two lines'>)} 
      {
        (SQ <'\n'> <'\n'> <'\t>file &&\n'> <'\tgit add file &&\n'> <'\techo aaa >file &&\n'> 
          <'\tgit diff >patch &&\n'> <'\tgit add file &&\n'> <'\techo bbb >file &&\n'> <'\tgit add file &&\n'> 
          <'\ttest_must_fail git apply --check patch\n'> <'\n'>
        )
      }
    )
    (C {(test_expect_success)} {(SQ <'apply patch with 3 context lines matching at end'>)} 
      {
        (SQ <'\n'> <'\t{ echo a; echo b; echo c; echo d; } >file &&\n'> <'\tgit add file &&\n'> 
          <'\techo e >>file &&\n'> <'\tgit diff >patch &&\n'> <'\t>file &&\n'> <'\ttest_must_fail git apply patch\n'>
        )
      }
    )
    (C {(test_done)})
  ]
)