(command.CommandList
  children: [
    (command.ShAssignment
      pairs: [
        (assign_pair
          lhs: (sh_lhs_expr.Name name:test_description)
          op: assign_op.Equal
          rhs: {(SQ <'apply same filename'>)}
          spids: [4]
        )
      ]
    )
    (C {<.>} {<'./test-lib.sh'>})
    (C {<test_expect_success>} {(SQ <setup>)} 
      {
        (SQ <'\n'> <'\n'> <'\tmkdir -p some/sub/dir &&\n'> <'\techo Hello > some/sub/dir/file &&\n'> 
          <'\tgit add some/sub/dir/file &&\n'> <'\tgit commit -m initial &&\n'> <'\tgit tag initial\n'> <'\n'>
        )
      }
    )
    (command.Simple
      words: [{<cat>}]
      redirects: [
        (redir op:<Id.Redir_Great '>'> loc:(redir_loc.Fd fd:1) arg:{<patch>})
        (redir
          op: <Id.Redir_DLess '<<'>
          loc: (redir_loc.Fd fd:0)
          arg: 
            (redir_param.MultiLine
              here_begin: {<EOF>}
              here_end_span_id: 50
              stdin_parts: [
                <'diff a/bla/blub/dir/file b/bla/blub/dir/file\n'>
                <'--- a/bla/blub/dir/file\n'>
                <'+++ b/bla/blub/dir/file\n'>
                <'@@ -1,1 +1,1 @@\n'>
                <'-Hello\n'>
                <'+Bello\n'>
              ]
            )
        )
      ]
      do_fork: T
    )
    (C {<test_expect_success>} {(SQ <'apply --directory -p (1)'>)} 
      {
        (SQ <'\n'> <'\n'> <'\tgit apply --directory=some/sub -p3 --index patch &&\n'> 
          <'\ttest Bello = $(git show :some/sub/dir/file) &&\n'> <'\ttest Bello = $(cat some/sub/dir/file)\n'> <'\n'>
        )
      }
    )
    (C {<test_expect_success>} {(SQ <'apply --directory -p (2) '>)} 
      {
        (SQ <'\n'> <'\n'> <'\tgit reset --hard initial &&\n'> 
          <'\tgit apply --directory=some/sub/ -p3 --index patch &&\n'> <'\ttest Bello = $(git show :some/sub/dir/file) &&\n'> <'\ttest Bello = $(cat some/sub/dir/file)\n'> 
          <'\n'>
        )
      }
    )
    (command.Simple
      words: [{<cat>}]
      redirects: [
        (redir op:<Id.Redir_Great '>'> loc:(redir_loc.Fd fd:1) arg:{<patch>})
        (redir
          op: <Id.Redir_DLess '<<'>
          loc: (redir_loc.Fd fd:0)
          arg: 
            (redir_param.MultiLine
              here_begin: {<EOF>}
              here_end_span_id: 103
              stdin_parts: [
                <'diff --git a/newfile b/newfile\n'>
                <'new file mode 100644\n'>
                <'index 0000000..d95f3ad\n'>
                <'--- /dev/null\n'>
                <'+++ b/newfile\n'>
                <'@@ -0,0 +1 @@\n'>
                <'+content\n'>
              ]
            )
        )
      ]
      do_fork: T
    )
    (C {<test_expect_success>} {(SQ <'apply --directory (new file)'>)} 
      {
        (SQ <'\n'> <'\tgit reset --hard initial &&\n'> 
          <'\tgit apply --directory=some/sub/dir/ --index patch &&\n'> <'\ttest content = $(git show :some/sub/dir/newfile) &&\n'> 
          <'\ttest content = $(cat some/sub/dir/newfile)\n'>
        )
      }
    )
    (command.Simple
      words: [{<cat>}]
      redirects: [
        (redir op:<Id.Redir_Great '>'> loc:(redir_loc.Fd fd:1) arg:{<patch>})
        (redir
          op: <Id.Redir_DLess '<<'>
          loc: (redir_loc.Fd fd:0)
          arg: 
            (redir_param.MultiLine
              here_begin: {<EOF>}
              here_end_span_id: 138
              stdin_parts: [
                <'diff --git a/c/newfile2 b/c/newfile2\n'>
                <'new file mode 100644\n'>
                <'index 0000000..d95f3ad\n'>
                <'--- /dev/null\n'>
                <'+++ b/c/newfile2\n'>
                <'@@ -0,0 +1 @@\n'>
                <'+content\n'>
              ]
            )
        )
      ]
      do_fork: T
    )
    (C {<test_expect_success>} {(SQ <'apply --directory -p (new file)'>)} 
      {
        (SQ <'\n'> <'\tgit reset --hard initial &&\n'> 
          <'\tgit apply -p2 --directory=some/sub/dir/ --index patch &&\n'> <'\ttest content = $(git show :some/sub/dir/newfile2) &&\n'> 
          <'\ttest content = $(cat some/sub/dir/newfile2)\n'>
        )
      }
    )
    (command.Simple
      words: [{<cat>}]
      redirects: [
        (redir op:<Id.Redir_Great '>'> loc:(redir_loc.Fd fd:1) arg:{<patch>})
        (redir
          op: <Id.Redir_DLess '<<'>
          loc: (redir_loc.Fd fd:0)
          arg: 
            (redir_param.MultiLine
              here_begin: {<EOF>}
              here_end_span_id: 173
              stdin_parts: [
                <'diff --git a/delfile b/delfile\n'>
                <'deleted file mode 100644\n'>
                <'index d95f3ad..0000000\n'>
                <'--- a/delfile\n'>
                <'+++ /dev/null\n'>
                <'@@ -1 +0,0 @@\n'>
                <'-content\n'>
              ]
            )
        )
      ]
      do_fork: T
    )
    (C {<test_expect_success>} {(SQ <'apply --directory (delete file)'>)} 
      {
        (SQ <'\n'> <'\tgit reset --hard initial &&\n'> <'\techo content >some/sub/dir/delfile &&\n'> 
          <'\tgit add some/sub/dir/delfile &&\n'> <'\tgit apply --directory=some/sub/dir/ --index patch &&\n'> <'\t! (git ls-files | grep delfile)\n'>
        )
      }
    )
    (command.Simple
      words: [{<cat>}]
      redirects: [
        (redir op:<Id.Redir_Great '>'> loc:(redir_loc.Fd fd:1) arg:{<patch>})
        (redir
          op: <Id.Redir_DLess '<<'>
          loc: (redir_loc.Fd fd:0)
          arg: 
            (redir_param.MultiLine
              here_begin: {(SQ <EOF>)}
              here_end_span_id: 210
              stdin_parts: [
                <'diff --git "a/qu\\157tefile" "b/qu\\157tefile"\n'>
                <'new file mode 100644\n'>
                <'index 0000000..d95f3ad\n'>
                <'--- /dev/null\n'>
                <'+++ "b/qu\\157tefile"\n'>
                <'@@ -0,0 +1 @@\n'>
                <'+content\n'>
              ]
            )
        )
      ]
      do_fork: T
    )
    (C {<test_expect_success>} {(SQ <'apply --directory (quoted filename)'>)} 
      {
        (SQ <'\n'> <'\tgit reset --hard initial &&\n'> 
          <'\tgit apply --directory=some/sub/dir/ --index patch &&\n'> <'\ttest content = $(git show :some/sub/dir/quotefile) &&\n'> 
          <'\ttest content = $(cat some/sub/dir/quotefile)\n'>
        )
      }
    )
    (C {<test_done>})
  ]
)