(CommandList
  children: [
    (Assignment
      keyword: Assign_None
      pairs: [
        (assign_pair
          lhs: (LhsName name:test_description)
          op: Equal
          rhs: {(SQ <"git apply boundary tests\n"> <"\n">)}
          spids: [13]
        )
      ]
      spids: [13]
    )
    (C {(.)} {(./test-lib.sh)})
    (Assignment
      keyword: Assign_None
      pairs: [
        (assign_pair
          lhs: (LhsName name:L)
          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: [24]
        )
      ]
      spids: [24]
    )
    (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">
        )
      }
    )
    (ForEach
      iter_name: with
      iter_words: [{(with)} {(without)}]
      do_arg_iter: False
      body: 
        (DoGroup
          children: [
            (Case
              to_match: {(DQ ($ VSub_Name "$with"))}
              arms: [
                (case_arm
                  pat_list: [{(with)}]
                  action: [
                    (Assignment
                      keyword: Assign_None
                      pairs: [(assign_pair lhs:(LhsName name:u) op:Equal rhs:{(SQ )} spids:[183])]
                      spids: [183]
                    )
                  ]
                  spids: [180 181 185 -1]
                )
                (case_arm
                  pat_list: [{(without)}]
                  action: [
                    (Assignment
                      keyword: Assign_None
                      pairs: [
                        (assign_pair
                          lhs: (LhsName name:u)
                          op: Equal
                          rhs: {(SQ <"--unidiff-zero ">)}
                          spids: [191]
                        )
                      ]
                      spids: [191]
                    )
                  ]
                  spids: [188 189 196 -1]
                )
              ]
              spids: [171 177 199]
            )
            (ForEach
              iter_name: kind
              iter_words: [{(add-a)} {(add-z)} {(insert-a)} {(mod-a)} {(mod-z)} {(del-a)} {(del-z)}]
              do_arg_iter: False
              body: 
                (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: [223 261]
                )
              spids: [207 -1]
            )
          ]
          spids: [168 263]
        )
      spids: [163 -1]
    )
    (ForEach
      iter_name: kind
      iter_words: [{(add-a)} {(add-z)} {(insert-a)} {(mod-a)} {(mod-z)} {(del-a)} {(del-z)}]
      do_arg_iter: False
      body: 
        (DoGroup
          children: [
            (C {(rm)} {(-f)} {($ VSub_Name "$kind") (-ng.without)})
            (SimpleCommand
              words: [{(sed)} {(-e)} {(DQ ("s/^diff --git /diff /"))} {(-e)} {(SQ <"/^index /d">)}]
              redirects: [
                (Redir
                  op_id: Redir_Less
                  fd: -1
                  arg_word: {($ VSub_Name "$kind") (-patch.without)}
                  spids: [315]
                )
                (Redir
                  op_id: Redir_Great
                  fd: -1
                  arg_word: {($ VSub_Name "$kind") (-ng.without)}
                  spids: [319]
                )
              ]
            )
            (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: [286 354]
        )
      spids: [271 -1]
    )
    (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)})
  ]
)