(CommandList
  children: [
    (Assignment
      keyword: Assign_None
      pairs: [
        (assign_pair
          lhs: (LhsName name:test_description)
          op: Equal
          rhs: {(SQ <"apply same filename">)}
          spids: [4]
        )
      ]
      spids: [4]
    )
    (C {(.)} {(./test-lib.sh)})
    (FuncDef
      name: modify
      body: 
        (BraceGroup
          children: [
            (AndOr
              children: [
                (SimpleCommand
                  words: [{(sed)} {(-e)} {(DQ ($ VSub_Number "$1"))}]
                  redirects: [
                    (Redir
                      op_id: Redir_Less
                      fd: -1
                      arg_word: {(DQ ($ VSub_Number "$2"))}
                      spids: [31]
                    )
                    (Redir
                      op_id: Redir_Great
                      fd: -1
                      arg_word: {(DQ ($ VSub_Number "$2")) (.x)}
                      spids: [37]
                    )
                  ]
                )
                (C {(mv)} {(DQ ($ VSub_Number "$2")) (.x)} {(DQ ($ VSub_Number "$2"))})
              ]
              op_id: Op_DAmp
            )
          ]
          spids: [20]
        )
      spids: [15 19]
    )
    (C {(test_expect_success)} {(setup)} 
      {
        (SQ <"\n"> <"\tfor i in a b c d e f g h i j k l m\n"> <"\tdo\n"> <"\t\techo $i\n"> 
          <"\tdone >same_fn &&\n"> <"\tcp same_fn other_fn &&\n"> <"\tgit add same_fn other_fn &&\n"> <"\tgit commit -m initial\n">
        )
      }
    )
    (C {(test_expect_success)} {(SQ <"apply same filename with independent changes">)} 
      {
        (SQ <"\n"> <"\tmodify \"s/^d/z/\" same_fn &&\n"> <"\tgit diff > patch0 &&\n"> 
          <"\tgit add same_fn &&\n"> <"\tmodify \"s/^i/y/\" same_fn &&\n"> <"\tgit diff >> patch0 &&\n"> <"\tcp same_fn same_fn2 &&\n"> 
          <"\tgit reset --hard &&\n"> <"\tgit apply patch0 &&\n"> <"\ttest_cmp same_fn same_fn2\n">
        )
      }
    )
    (C {(test_expect_success)} {(SQ <"apply same filename with overlapping changes">)} 
      {
        (SQ <"\n"> <"\tgit reset --hard &&\n"> <"\tmodify \"s/^d/z/\" same_fn &&\n"> 
          <"\tgit diff > patch0 &&\n"> <"\tgit add same_fn &&\n"> <"\tmodify \"s/^e/y/\" same_fn &&\n"> <"\tgit diff >> patch0 &&\n"> 
          <"\tcp same_fn same_fn2 &&\n"> <"\tgit reset --hard &&\n"> <"\tgit apply patch0 &&\n"> <"\ttest_cmp same_fn same_fn2\n">
        )
      }
    )
    (C {(test_expect_success)} {(SQ <"apply same new filename after rename">)} 
      {
        (SQ <"\n"> <"\tgit reset --hard &&\n"> <"\tgit mv same_fn new_fn &&\n"> 
          <"\tmodify \"s/^d/z/\" new_fn &&\n"> <"\tgit add new_fn &&\n"> <"\tgit diff -M --cached > patch1 &&\n"> <"\tmodify \"s/^e/y/\" new_fn &&\n"> 
          <"\tgit diff >> patch1 &&\n"> <"\tcp new_fn new_fn2 &&\n"> <"\tgit reset --hard &&\n"> <"\tgit apply --index patch1 &&\n"> 
          <"\ttest_cmp new_fn new_fn2\n">
        )
      }
    )
    (C {(test_expect_success)} {(SQ <"apply same old filename after rename -- should fail.">)} 
      {
        (SQ <"\n"> <"\tgit reset --hard &&\n"> <"\tgit mv same_fn new_fn &&\n"> 
          <"\tmodify \"s/^d/z/\" new_fn &&\n"> <"\tgit add new_fn &&\n"> <"\tgit diff -M --cached > patch1 &&\n"> <"\tgit mv new_fn same_fn &&\n"> 
          <"\tmodify \"s/^e/y/\" same_fn &&\n"> <"\tgit diff >> patch1 &&\n"> <"\tgit reset --hard &&\n"> <"\ttest_must_fail git apply patch1\n">
        )
      }
    )
    (C {(test_expect_success)} {(SQ <"apply A->B (rename), C->A (rename), A->A -- should pass.">)} 
      {
        (SQ <"\n"> <"\tgit reset --hard &&\n"> <"\tgit mv same_fn new_fn &&\n"> 
          <"\tmodify \"s/^d/z/\" new_fn &&\n"> <"\tgit add new_fn &&\n"> <"\tgit diff -M --cached > patch1 &&\n"> 
          <"\tgit commit -m \"a rename\" &&\n"> <"\tgit mv other_fn same_fn &&\n"> <"\tmodify \"s/^e/y/\" same_fn &&\n"> <"\tgit add same_fn &&\n"> 
          <"\tgit diff -M --cached >> patch1 &&\n"> <"\tmodify \"s/^g/x/\" same_fn &&\n"> <"\tgit diff >> patch1 &&\n"> <"\tgit reset --hard HEAD^ &&\n"> 
          <"\tgit apply patch1\n">
        )
      }
    )
    (C {(test_done)})
  ]
)