(command.CommandList
  children: [
    (command.ShAssignment
      pairs: [
        (assign_pair
          lhs: (sh_lhs_expr.Name name:test_description)
          op: assign_op.Equal
          rhs: {(SQ <'add -e basic tests'>)}
          spids: [13]
        )
      ]
    )
    (C {<.>} {<./test-lib.sh>})
    (command.Simple
      words: [{<cat>}]
      redirects: [
        (redir.Redir op:<Id.Redir_Great '>'> fd:-1 arg_word:{<file>})
        (redir.HereDoc
          op: <Id.Redir_DLess '<<'>
          fd: -1
          here_begin: {<EOF>}
          here_end_span_id: 46
          stdin_parts: [
            <'LO, praise of the prowess of people-kings\n'>
            <'of spear-armed Danes, in days long sped,\n'>
            <'we have heard, and what honor the athelings won!\n'>
            <'Oft Scyld the Scefing from squadroned foes,\n'>
            <'from many a tribe, the mead-bench tore,\n'>
            <'awing the earls. Since erst he lay\n'>
            <'friendless, a foundling, fate repaid him:\n'>
            <'for he waxed under welkin, in wealth he throve,\n'>
            <'till before him the folk, both far and near,\n'>
            <'who house by the whale-path, heard his mandate,\n'>
            <'gave him gifts:  a good king he!\n'>
          ]
        )
      ]
    )
    (command.Simple
      words: [{<cat>}]
      redirects: [
        (redir.Redir op:<Id.Redir_Great '>'> fd:-1 arg_word:{<second-part>})
        (redir.HereDoc
          op: <Id.Redir_DLess '<<'>
          fd: -1
          here_begin: {<EOF>}
          here_end_span_id: 65
          stdin_parts: [
            <'To him an heir was afterward born,\n'>
            <'a son in his halls, whom heaven sent\n'>
            <'to favor the folk, feeling their woe\n'>
            <'that erst they had lacked an earl for leader\n'>
            <'so long a while; the Lord endowed him,\n'>
            <"the Wielder of Wonder, with world's renown.\n">
          ]
        )
      ]
    )
    (C {<test_expect_success>} {(SQ <setup>)} 
      {
        (SQ <'\n'> <'\n'> <'\tgit add file &&\n'> <'\ttest_tick &&\n'> <'\tgit commit -m initial file\n'> 
          <'\n'>
        )
      }
    )
    (command.Simple
      words: [{<cat>}]
      redirects: [
        (redir.Redir op:<Id.Redir_Great '>'> fd:-1 arg_word:{<expected-patch>})
        (redir.HereDoc
          op: <Id.Redir_DLess '<<'>
          fd: -1
          here_begin: {<EOF>}
          here_end_span_id: 116
          stdin_parts: [
            <'diff --git a/file b/file\n'>
            <'index b9834b5..9020acb 100644\n'>
            <'--- a/file\n'>
            <'+++ b/file\n'>
            <'@@ -1,11 +1,6 @@\n'>
            <'-LO, praise of the prowess of people-kings\n'>
            <'-of spear-armed Danes, in days long sped,\n'>
            <'-we have heard, and what honor the athelings won!\n'>
            <'-Oft Scyld the Scefing from squadroned foes,\n'>
            <'-from many a tribe, the mead-bench tore,\n'>
            <'-awing the earls. Since erst he lay\n'>
            <'-friendless, a foundling, fate repaid him:\n'>
            <'-for he waxed under welkin, in wealth he throve,\n'>
            <'-till before him the folk, both far and near,\n'>
            <'-who house by the whale-path, heard his mandate,\n'>
            <'-gave him gifts:  a good king he!\n'>
            <'+To him an heir was afterward born,\n'>
            <'+a son in his halls, whom heaven sent\n'>
            <'+to favor the folk, feeling their woe\n'>
            <'+that erst they had lacked an earl for leader\n'>
            <'+so long a while; the Lord endowed him,\n'>
            <"+the Wielder of Wonder, with world's renown.\n">
          ]
        )
      ]
    )
    (command.Simple
      words: [{<cat>}]
      redirects: [
        (redir.Redir op:<Id.Redir_Great '>'> fd:-1 arg_word:{<patch>})
        (redir.HereDoc
          op: <Id.Redir_DLess '<<'>
          fd: -1
          here_begin: {<EOF>}
          here_end_span_id: 141
          stdin_parts: [
            <'diff --git a/file b/file\n'>
            <'index b9834b5..ef6e94c 100644\n'>
            <'--- a/file\n'>
            <'+++ b/file\n'>
            <'@@ -3,1 +3,333 @@ of spear-armed Danes, in days long sped,\n'>
            <' we have heard, and what honor the athelings won!\n'>
            <'+\n'>
            <' Oft Scyld the Scefing from squadroned foes,\n'>
            <'@@ -2,7 +1,5 @@ awing the earls. Since erst he lay\n'>
            <' friendless, a foundling, fate repaid him:\n'>
            <'+\n'>
            <' for he waxed under welkin, in wealth he throve,\n'>
          ]
        )
      ]
    )
    (command.Simple
      words: [{<cat>}]
      redirects: [
        (redir.Redir op:<Id.Redir_Great '>'> fd:-1 arg_word:{<expected>})
        (redir.HereDoc
          op: <Id.Redir_DLess '<<'>
          fd: -1
          here_begin: {<EOF>}
          here_end_span_id: 171
          stdin_parts: [
            <'diff --git a/file b/file\n'>
            <'index b9834b5..ef6e94c 100644\n'>
            <'--- a/file\n'>
            <'+++ b/file\n'>
            <'@@ -1,10 +1,12 @@\n'>
            <' LO, praise of the prowess of people-kings\n'>
            <' of spear-armed Danes, in days long sped,\n'>
            <' we have heard, and what honor the athelings won!\n'>
            <'+\n'>
            <' Oft Scyld the Scefing from squadroned foes,\n'>
            <' from many a tribe, the mead-bench tore,\n'>
            <' awing the earls. Since erst he lay\n'>
            <' friendless, a foundling, fate repaid him:\n'>
            <'+\n'>
            <' for he waxed under welkin, in wealth he throve,\n'>
            <' till before him the folk, both far and near,\n'>
            <' who house by the whale-path, heard his mandate,\n'>
          ]
        )
      ]
    )
    (command.Simple
      words: [{<echo>} {(DQ <'#!'> ($ Id.VSub_DollarName '$SHELL_PATH'))}]
      redirects: [(redir.Redir op:<Id.Redir_Great '>'> fd:-1 arg_word:{<fake-editor.sh>})]
    )
    (command.Simple
      words: [{<cat>}]
      redirects: [
        (redir.Redir op:<Id.Redir_DGreat '>>'> fd:-1 arg_word:{<fake-editor.sh>})
        (redir.HereDoc
          op: <Id.Redir_DLess '<<'>
          fd: -1
          here_begin: {(word_part.EscapedLiteral token:<Id.Lit_EscapedChar '\\E'>) <OF>}
          here_end_span_id: 195
          stdin_parts: [<'mv -f "$1" orig-patch &&\n'> <'mv -f patch "$1"\n'>]
        )
      ]
    )
    (C {<test_set_editor>} 
      {
        (DQ 
          (command_sub
            left_token: <Id.Left_DollarParen '$('>
            command_list: (command.CommandList children:[(C {<pwd>})])
          ) </fake-editor.sh>
        )
      }
    )
    (C {<chmod>} {<a> <Id.Lit_Other '+'> <x>} {<fake-editor.sh>})
    (C {<test_expect_success>} {(SQ <'add -e'>)} 
      {
        (SQ <'\n'> <'\n'> <'\tcp second-part file &&\n'> <'\tgit add -e &&\n'> 
          <'\ttest_cmp second-part file &&\n'> <'\ttest_cmp orig-patch expected-patch &&\n'> <'\tgit diff --cached > out &&\n'> 
          <'\ttest_cmp out expected\n'> <'\n'>
        )
      }
    )
    (C {<test_expect_success>} {(SQ <'add -e notices editor failure'>)} 
      {
        (SQ <'\n'> <'\tgit reset --hard &&\n'> <'\techo change >>file &&\n'> 
          <'\ttest_must_fail env GIT_EDITOR=false git add -e &&\n'> <'\ttest_expect_code 1 git diff --exit-code\n'>
        )
      }
    )
    (C {<test_done>})
  ]
)