(command.CommandList
  children: [
    (command.ShAssignment
      pairs: [
        (assign_pair
          lhs: (sh_lhs_expr.Name name:test_description)
          op: assign_op.Equal
          rhs: {(SQ <'various format-patch tests'>)}
          spids: [13]
        )
      ]
    )
    (C {<.>} {<'./test-lib.sh'>})
    (C {<.>} {(DQ ($ Id.VSub_DollarName '$TEST_DIRECTORY')) <'/lib-terminal.sh'>})
    (C {<test_expect_success>} {<setup>} 
      {
        (SQ <'\n'> <'\n'> <'\tfor i in 1 2 3 4 5 6 7 8 9 10; do echo "$i"; done >file &&\n'> 
          <'\tcat file >elif &&\n'> <'\tgit add file elif &&\n'> <'\ttest_tick &&\n'> <'\tgit commit -m Initial &&\n'> 
          <'\tgit checkout -b side &&\n'> <'\n'> <'\tfor i in 1 2 5 6 A B C 7 8 9 10; do echo "$i"; done >file &&\n'> 
          <'\ttest_chmod +x elif &&\n'> <'\ttest_tick &&\n'> <'\tgit commit -m "Side changes #1" &&\n'> <'\n'> 
          <'\tfor i in D E F; do echo "$i"; done >>file &&\n'> <'\tgit update-index file &&\n'> <'\ttest_tick &&\n'> <'\tgit commit -m "Side changes #2" &&\n'> 
          <'\tgit tag C2 &&\n'> <'\n'> <'\tfor i in 5 6 1 2 3 A 4 B C 7 8 9 10 D E F; do echo "$i"; done >file &&\n'> 
          <'\tgit update-index file &&\n'> <'\ttest_tick &&\n'> <'\tgit commit -m "Side changes #3 with \\\\n backslash-n in it." &&\n'> <'\n'> 
          <'\tgit checkout master &&\n'> <'\tgit diff-tree -p C2 | git apply --index &&\n'> <'\ttest_tick &&\n'> 
          <'\tgit commit -m "Master accepts moral equivalent of #2"\n'> <'\n'>
        )
      }
    )
    (C {<test_expect_success>} {(DQ <'format-patch --ignore-if-in-upstream'>)} 
      {
        (SQ <'\n'> <'\n'> <'\tgit format-patch --stdout master..side >patch0 &&\n'> 
          <'\tcnt=$(grep "^From " patch0 | wc -l) &&\n'> <'\ttest $cnt = 3\n'> <'\n'>
        )
      }
    )
    (C {<test_expect_success>} {(DQ <'format-patch --ignore-if-in-upstream'>)} 
      {
        (SQ <'\n'> <'\n'> <'\tgit format-patch --stdout \\\n'> 
          <'\t\t--ignore-if-in-upstream master..side >patch1 &&\n'> <'\tcnt=$(grep "^From " patch1 | wc -l) &&\n'> <'\ttest $cnt = 2\n'> <'\n'>
        )
      }
    )
    (C {<test_expect_success>} {(DQ <'format-patch --ignore-if-in-upstream handles tags'>)} 
      {
        (SQ <'\n'> <'\tgit tag -a v1 -m tag side &&\n'> <'\tgit tag -a v2 -m tag master &&\n'> 
          <'\tgit format-patch --stdout --ignore-if-in-upstream v2..v1 >patch1 &&\n'> <'\tcnt=$(grep "^From " patch1 | wc -l) &&\n'> <'\ttest $cnt = 2\n'>
        )
      }
    )
    (C {<test_expect_success>} {(DQ <'format-patch doesn\'t consider merge commits'>)} 
      {
        (SQ <'\n'> <'\n'> <'\tgit checkout -b slave master &&\n'> <'\techo "Another line" >>file &&\n'> 
          <'\ttest_tick &&\n'> <'\tgit commit -am "Slave change #1" &&\n'> <'\techo "Yet another line" >>file &&\n'> 
          <'\ttest_tick &&\n'> <'\tgit commit -am "Slave change #2" &&\n'> <'\tgit checkout -b merger master &&\n'> 
          <'\ttest_tick &&\n'> <'\tgit merge --no-ff slave &&\n'> 
          <'\tcnt=$(git format-patch -3 --stdout | grep "^From " | wc -l) &&\n'> <'\ttest $cnt = 3\n'>
        )
      }
    )
    (C {<test_expect_success>} {(DQ <'format-patch result applies'>)} 
      {
        (SQ <'\n'> <'\n'> <'\tgit checkout -b rebuild-0 master &&\n'> <'\tgit am -3 patch0 &&\n'> 
          <'\tcnt=$(git rev-list master.. | wc -l) &&\n'> <'\ttest $cnt = 2\n'>
        )
      }
    )
    (C {<test_expect_success>} {(DQ <'format-patch --ignore-if-in-upstream result applies'>)} 
      {
        (SQ <'\n'> <'\n'> <'\tgit checkout -b rebuild-1 master &&\n'> <'\tgit am -3 patch1 &&\n'> 
          <'\tcnt=$(git rev-list master.. | wc -l) &&\n'> <'\ttest $cnt = 2\n'>
        )
      }
    )
    (C {<test_expect_success>} {(SQ <'commit did not screw up the log message'>)} 
      {
        (SQ <'\n'> <'\n'> <'\tgit cat-file commit side | grep "^Side .* with .* backslash-n"\n'> <'\n'>)
      }
    )
    (C {<test_expect_success>} {(SQ <'format-patch did not screw up the log message'>)} 
      {
        (SQ <'\n'> <'\n'> <'\tgrep "^Subject: .*Side changes #3 with .* backslash-n" patch0 &&\n'> 
          <'\tgrep "^Subject: .*Side changes #3 with .* backslash-n" patch1\n'> <'\n'>
        )
      }
    )
    (C {<test_expect_success>} {(SQ <'replay did not screw up the log message'>)} 
      {
        (SQ <'\n'> <'\n'> <'\tgit cat-file commit rebuild-1 | grep "^Side .* with .* backslash-n"\n'> 
          <'\n'>
        )
      }
    )
    (C {<test_expect_success>} {(SQ <'extra headers'>)} 
      {
        (SQ <'\n'> <'\n'> <'\tgit config format.headers "To: R E Cipient <rcipient@example.com>\n'> 
          <'" &&\n'> <'\tgit config --add format.headers "Cc: S E Cipient <scipient@example.com>\n'> <'" &&\n'> 
          <'\tgit format-patch --stdout master..side > patch2 &&\n'> <'\tsed -e "/^\\$/q" patch2 > hdrs2 &&\n'> 
          <'\tgrep "^To: R E Cipient <rcipient@example.com>\\$" hdrs2 &&\n'> <'\tgrep "^Cc: S E Cipient <scipient@example.com>\\$" hdrs2\n'> <'\n'>
        )
      }
    )
    (C {<test_expect_success>} {(SQ <'extra headers without newlines'>)} 
      {
        (SQ <'\n'> <'\n'> 
          <
'\tgit config --replace-all format.headers "To: R E Cipient <rcipient@example.com>" &&\n'
          > <'\tgit config --add format.headers "Cc: S E Cipient <scipient@example.com>" &&\n'> 
          <'\tgit format-patch --stdout master..side >patch3 &&\n'> <'\tsed -e "/^\\$/q" patch3 > hdrs3 &&\n'> 
          <'\tgrep "^To: R E Cipient <rcipient@example.com>\\$" hdrs3 &&\n'> <'\tgrep "^Cc: S E Cipient <scipient@example.com>\\$" hdrs3\n'> <'\n'>
        )
      }
    )
    (C {<test_expect_success>} {(SQ <'extra headers with multiple To:s'>)} 
      {
        (SQ <'\n'> <'\n'> 
          <
'\tgit config --replace-all format.headers "To: R E Cipient <rcipient@example.com>" &&\n'
          > <'\tgit config --add format.headers "To: S E Cipient <scipient@example.com>" &&\n'> 
          <'\tgit format-patch --stdout master..side > patch4 &&\n'> <'\tsed -e "/^\\$/q" patch4 > hdrs4 &&\n'> 
          <'\tgrep "^To: R E Cipient <rcipient@example.com>,\\$" hdrs4 &&\n'> <'\tgrep "^ *S E Cipient <scipient@example.com>\\$" hdrs4\n'>
        )
      }
    )
    (C {<test_expect_success>} {(SQ <'additional command line cc (ascii)'>)} 
      {
        (SQ <'\n'> <'\n'> 
          <
'\tgit config --replace-all format.headers "Cc: R E Cipient <rcipient@example.com>" &&\n'
          > 
          <
'\tgit format-patch --cc="S E Cipient <scipient@example.com>" --stdout master..side | sed -e "/^\\$/q" >patch5 &&\n'
          > <'\tgrep "^Cc: R E Cipient <rcipient@example.com>,\\$" patch5 &&\n'> 
          <'\tgrep "^ *S E Cipient <scipient@example.com>\\$" patch5\n'>
        )
      }
    )
    (C {<test_expect_failure>} {(SQ <'additional command line cc (rfc822)'>)} 
      {
        (SQ <'\n'> <'\n'> 
          <
'\tgit config --replace-all format.headers "Cc: R E Cipient <rcipient@example.com>" &&\n'
          > 
          <
'\tgit format-patch --cc="S. E. Cipient <scipient@example.com>" --stdout master..side | sed -e "/^\\$/q" >patch5 &&\n'
          > <'\tgrep "^Cc: R E Cipient <rcipient@example.com>,\\$" patch5 &&\n'> 
          <'\tgrep "^ *\\"S. E. Cipient\\" <scipient@example.com>\\$" patch5\n'>
        )
      }
    )
    (C {<test_expect_success>} {(SQ <'command line headers'>)} 
      {
        (SQ <'\n'> <'\n'> <'\tgit config --unset-all format.headers &&\n'> 
          <
'\tgit format-patch --add-header="Cc: R E Cipient <rcipient@example.com>" --stdout master..side | sed -e "/^\\$/q" >patch6 &&\n'
          > <'\tgrep "^Cc: R E Cipient <rcipient@example.com>\\$" patch6\n'>
        )
      }
    )
    (C {<test_expect_success>} {(SQ <'configuration headers and command line headers'>)} 
      {
        (SQ <'\n'> <'\n'> 
          <
'\tgit config --replace-all format.headers "Cc: R E Cipient <rcipient@example.com>" &&\n'
          > 
          <
'\tgit format-patch --add-header="Cc: S E Cipient <scipient@example.com>" --stdout master..side | sed -e "/^\\$/q" >patch7 &&\n'
          > <'\tgrep "^Cc: R E Cipient <rcipient@example.com>,\\$" patch7 &&\n'> 
          <'\tgrep "^ *S E Cipient <scipient@example.com>\\$" patch7\n'>
        )
      }
    )
    (C {<test_expect_success>} {(SQ <'command line To: header (ascii)'>)} 
      {
        (SQ <'\n'> <'\n'> <'\tgit config --unset-all format.headers &&\n'> 
          <
'\tgit format-patch --to="R E Cipient <rcipient@example.com>" --stdout master..side | sed -e "/^\\$/q" >patch8 &&\n'
          > <'\tgrep "^To: R E Cipient <rcipient@example.com>\\$" patch8\n'>
        )
      }
    )
    (C {<test_expect_failure>} {(SQ <'command line To: header (rfc822)'>)} 
      {
        (SQ <'\n'> <'\n'> 
          <
'\tgit format-patch --to="R. E. Cipient <rcipient@example.com>" --stdout master..side | sed -e "/^\\$/q" >patch8 &&\n'
          > <'\tgrep "^To: \\"R. E. Cipient\\" <rcipient@example.com>\\$" patch8\n'>
        )
      }
    )
    (C {<test_expect_failure>} {(SQ <'command line To: header (rfc2047)'>)} 
      {
        (SQ <'\n'> <'\n'> 
          <
'\tgit format-patch --to="R Ä Cipient <rcipient@example.com>" --stdout master..side | sed -e "/^\\$/q" >patch8 &&\n'
          > <'\tgrep "^To: =?UTF-8?q?R=20=C3=84=20Cipient?= <rcipient@example.com>\\$" patch8\n'>
        )
      }
    )
    (C {<test_expect_success>} {(SQ <'configuration To: header (ascii)'>)} 
      {
        (SQ <'\n'> <'\n'> <'\tgit config format.to "R E Cipient <rcipient@example.com>" &&\n'> 
          <'\tgit format-patch --stdout master..side | sed -e "/^\\$/q" >patch9 &&\n'> <'\tgrep "^To: R E Cipient <rcipient@example.com>\\$" patch9\n'>
        )
      }
    )
    (C {<test_expect_failure>} {(SQ <'configuration To: header (rfc822)'>)} 
      {
        (SQ <'\n'> <'\n'> <'\tgit config format.to "R. E. Cipient <rcipient@example.com>" &&\n'> 
          <'\tgit format-patch --stdout master..side | sed -e "/^\\$/q" >patch9 &&\n'> <'\tgrep "^To: \\"R. E. Cipient\\" <rcipient@example.com>\\$" patch9\n'>
        )
      }
    )
    (C {<test_expect_failure>} {(SQ <'configuration To: header (rfc2047)'>)} 
      {
        (SQ <'\n'> <'\n'> <'\tgit config format.to "R Ä Cipient <rcipient@example.com>" &&\n'> 
          <'\tgit format-patch --stdout master..side | sed -e "/^\\$/q" >patch9 &&\n'> <'\tgrep "^To: =?UTF-8?q?R=20=C3=84=20Cipient?= <rcipient@example.com>\\$" patch9\n'>
        )
      }
    )
    (command.ShFunction
      name: check_patch
      body: 
        (BraceGroup
          children: [
            (command.AndOr
              ops: [Id.Op_DAmp Id.Op_DAmp]
              children: [
                (C {<grep>} {<-e>} {(DQ <'^From:'>)} {(DQ ($ Id.VSub_Number '$1'))})
                (C {<grep>} {<-e>} {(DQ <'^Date:'>)} {(DQ ($ Id.VSub_Number '$1'))})
                (C {<grep>} {<-e>} {(DQ <'^Subject:'>)} {(DQ ($ Id.VSub_Number '$1'))})
              ]
            )
          ]
        )
    )
    (C {<test_expect_success>} {(SQ <'format.from=false'>)} 
      {
        (SQ <'\n'> <'\n'> <'\tgit -c format.from=false format-patch --stdout master..side |\n'> 
          <'\tsed -e "/^\\$/q" >patch &&\n'> <'\tcheck_patch patch &&\n'> <'\t! grep "^From: C O Mitter <committer@example.com>\\$" patch\n'>
        )
      }
    )
    (C {<test_expect_success>} {(SQ <'format.from=true'>)} 
      {
        (SQ <'\n'> <'\n'> <'\tgit -c format.from=true format-patch --stdout master..side |\n'> 
          <'\tsed -e "/^\\$/q" >patch &&\n'> <'\tcheck_patch patch &&\n'> <'\tgrep "^From: C O Mitter <committer@example.com>\\$" patch\n'>
        )
      }
    )
    (C {<test_expect_success>} {(SQ <'format.from with address'>)} 
      {
        (SQ <'\n'> <'\n'> 
          <
'\tgit -c format.from="F R Om <from@example.com>" format-patch --stdout master..side |\n'
          > <'\tsed -e "/^\\$/q" >patch &&\n'> <'\tcheck_patch patch &&\n'> 
          <'\tgrep "^From: F R Om <from@example.com>\\$" patch\n'>
        )
      }
    )
    (C {<test_expect_success>} {(SQ <'--no-from overrides format.from'>)} 
      {
        (SQ <'\n'> <'\n'> 
          <
'\tgit -c format.from="F R Om <from@example.com>" format-patch --no-from --stdout master..side |\n'
          > <'\tsed -e "/^\\$/q" >patch &&\n'> <'\tcheck_patch patch &&\n'> 
          <'\t! grep "^From: F R Om <from@example.com>\\$" patch\n'>
        )
      }
    )
    (C {<test_expect_success>} {(SQ <'--from overrides format.from'>)} 
      {
        (SQ <'\n'> <'\n'> 
          <
'\tgit -c format.from="F R Om <from@example.com>" format-patch --from --stdout master..side |\n'
          > <'\tsed -e "/^\\$/q" >patch &&\n'> <'\tcheck_patch patch &&\n'> 
          <'\t! grep "^From: F R Om <from@example.com>\\$" patch\n'>
        )
      }
    )
    (C {<test_expect_success>} {(SQ <'--no-to overrides config.to'>)} 
      {
        (SQ <'\n'> <'\n'> <'\tgit config --replace-all format.to \\\n'> 
          <'\t\t"R E Cipient <rcipient@example.com>" &&\n'> <'\tgit format-patch --no-to --stdout master..side |\n'> <'\tsed -e "/^\\$/q" >patch10 &&\n'> 
          <'\tcheck_patch patch10 &&\n'> <'\t! grep "^To: R E Cipient <rcipient@example.com>\\$" patch10\n'>
        )
      }
    )
    (C {<test_expect_success>} {(SQ <'--no-to and --to replaces config.to'>)} 
      {
        (SQ <'\n'> <'\n'> <'\tgit config --replace-all format.to \\\n'> 
          <'\t\t"Someone <someone@out.there>" &&\n'> <'\tgit format-patch --no-to --to="Someone Else <else@out.there>" \\\n'> 
          <'\t\t--stdout master..side |\n'> <'\tsed -e "/^\\$/q" >patch11 &&\n'> <'\tcheck_patch patch11 &&\n'> 
          <'\t! grep "^To: Someone <someone@out.there>\\$" patch11 &&\n'> <'\tgrep "^To: Someone Else <else@out.there>\\$" patch11\n'>
        )
      }
    )
    (C {<test_expect_success>} {(SQ <'--no-cc overrides config.cc'>)} 
      {
        (SQ <'\n'> <'\n'> <'\tgit config --replace-all format.cc \\\n'> 
          <'\t\t"C E Cipient <rcipient@example.com>" &&\n'> <'\tgit format-patch --no-cc --stdout master..side |\n'> <'\tsed -e "/^\\$/q" >patch12 &&\n'> 
          <'\tcheck_patch patch12 &&\n'> <'\t! grep "^Cc: C E Cipient <rcipient@example.com>\\$" patch12\n'>
        )
      }
    )
    (C {<test_expect_success>} {(SQ <'--no-add-header overrides config.headers'>)} 
      {
        (SQ <'\n'> <'\n'> <'\tgit config --replace-all format.headers \\\n'> 
          <'\t\t"Header1: B E Cipient <rcipient@example.com>" &&\n'> <'\tgit format-patch --no-add-header --stdout master..side |\n'> <'\tsed -e "/^\\$/q" >patch13 &&\n'> 
          <'\tcheck_patch patch13 &&\n'> <'\t! grep "^Header1: B E Cipient <rcipient@example.com>\\$" patch13\n'>
        )
      }
    )
    (C {<test_expect_success>} {(SQ <'multiple files'>)} 
      {
        (SQ <'\n'> <'\n'> <'\trm -rf patches/ &&\n'> <'\tgit checkout side &&\n'> 
          <'\tgit format-patch -o patches/ master &&\n'> 
          <
'\tls patches/0001-Side-changes-1.patch patches/0002-Side-changes-2.patch patches/0003-Side-changes-3-with-n-backslash-n-in-it.patch\n'
          >
        )
      }
    )
    (C {<test_expect_success>} {(SQ <'reroll count'>)} 
      {
        (SQ <'\n'> <'\trm -fr patches &&\n'> 
          <'\tgit format-patch -o patches --cover-letter --reroll-count 4 master..side >list &&\n'> <'\t! grep -v "^patches/v4-000[0-3]-" list &&\n'> 
          <'\tsed -n -e "/^Subject: /p" $(cat list) >subjects &&\n'> <'\t! grep -v "^Subject: \\[PATCH v4 [0-3]/3\\] " subjects\n'>
        )
      }
    )
    (C {<test_expect_success>} {(SQ <'reroll count (-v)'>)} 
      {
        (SQ <'\n'> <'\trm -fr patches &&\n'> 
          <'\tgit format-patch -o patches --cover-letter -v4 master..side >list &&\n'> <'\t! grep -v "^patches/v4-000[0-3]-" list &&\n'> 
          <'\tsed -n -e "/^Subject: /p" $(cat list) >subjects &&\n'> <'\t! grep -v "^Subject: \\[PATCH v4 [0-3]/3\\] " subjects\n'>
        )
      }
    )
    (command.ShFunction
      name: check_threading
      body: 
        (BraceGroup
          children: [
            (command.AndOr
              ops: [Id.Op_DAmp Id.Op_DAmp Id.Op_DAmp Id.Op_DAmp]
              children: [
                (command.ShAssignment
                  pairs: [
                    (assign_pair
                      lhs: (sh_lhs_expr.Name name:expect)
                      op: assign_op.Equal
                      rhs: {(DQ ($ Id.VSub_Number '$1'))}
                      spids: [695]
                    )
                  ]
                )
                (C {<shift>})
                (command.Pipeline
                  children: [
                    (command.Subshell
                      child: 
                        (command.CommandList
                          children: [
                            (command.Sentence
                              child: 
                                (C {<git>} {<format-patch>} {<--stdout>} {(DQ ($ Id.VSub_At '$@'))})
                              terminator: <Id.Op_Semi _>
                            )
                            (command.Simple
                              words: [{<echo>} {($ Id.VSub_QMark '$?')}]
                              redirects: [
                                (redir
                                  op: <Id.Redir_Great '>'>
                                  loc: (redir_loc.Fd fd:1)
                                  arg: {<status.out>}
                                )
                              ]
                              do_fork: T
                            )
                          ]
                        )
                    )
                    (command.Simple
                      words: [
                        {<perl>}
                        {<-ne>}
                        {
                          (SQ <'\n'> <'\t\tif (/^(message-id|references|in-reply-to)/i) {\n'> 
                            <'\t\t\t$printing = 1;\n'> <'\t\t} elsif (/^\\S/) {\n'> <'\t\t\t$printing = 0;\n'> <'\t\t}\n'> <'\t\tif ($printing) {\n'> 
                            <'\t\t\t$h{$1}=$i++ if (/<([^>]+)>/ and !exists $h{$1});\n'> <'\t\t\tfor $k (keys %h) {s/$k/$h{$k}/};\n'> <'\t\t\tprint;\n'> <'\t\t}\n'> 
                            <'\t\tprint "---\\n" if /^From /i;\n'> <'\t'>
                          )
                        }
                      ]
                      redirects: [
                        (redir
                          op: <Id.Redir_Great '>'>
                          loc: (redir_loc.Fd fd:1)
                          arg: {<actual>}
                        )
                      ]
                      do_fork: T
                    )
                  ]
                  negated: F
                )
                (C {<test>} {<0>} {<Id.Lit_Equals '='>} 
                  {
                    (DQ 
                      (command_sub
                        left_token: <Id.Left_DollarParen '$('>
                        child: (C {<cat>} {<status.out>})
                      )
                    )
                  }
                )
                (C {<test_cmp>} {(DQ ($ Id.VSub_DollarName '$expect'))} {<actual>})
              ]
            )
          ]
        )
    )
    (command.Simple
      words: [{<cat>}]
      redirects: [
        (redir op:<Id.Redir_DGreat '>>'> loc:(redir_loc.Fd fd:1) arg:{<expect.no-threading>})
        (redir
          op: <Id.Redir_DLess '<<'>
          loc: (redir_loc.Fd fd:0)
          arg: 
            (redir_param.MultiLine
              here_begin: {<EOF>}
              here_end_span_id: 808
              stdin_parts: [<'---\n'> <'---\n'> <'---\n'>]
            )
        )
      ]
      do_fork: T
    )
    (C {<test_expect_success>} {(SQ <'no threading'>)} 
      {(SQ <'\n'> <'\tgit checkout side &&\n'> <'\tcheck_threading expect.no-threading master\n'>)}
    )
    (command.Simple
      words: [{<cat>}]
      redirects: [
        (redir op:<Id.Redir_Great '>'> loc:(redir_loc.Fd fd:1) arg:{<expect.thread>})
        (redir
          op: <Id.Redir_DLess '<<'>
          loc: (redir_loc.Fd fd:0)
          arg: 
            (redir_param.MultiLine
              here_begin: {<EOF>}
              here_end_span_id: 843
              stdin_parts: [
                <'---\n'>
                <'Message-Id: <0>\n'>
                <'---\n'>
                <'Message-Id: <1>\n'>
                <'In-Reply-To: <0>\n'>
                <'References: <0>\n'>
                <'---\n'>
                <'Message-Id: <2>\n'>
                <'In-Reply-To: <0>\n'>
                <'References: <0>\n'>
              ]
            )
        )
      ]
      do_fork: T
    )
    (C {<test_expect_success>} {(SQ <thread>)} 
      {(SQ <'\n'> <'\tcheck_threading expect.thread --thread master\n'>)}
    )
    (command.Simple
      words: [{<cat>}]
      redirects: [
        (redir op:<Id.Redir_Great '>'> loc:(redir_loc.Fd fd:1) arg:{<expect.in-reply-to>})
        (redir
          op: <Id.Redir_DLess '<<'>
          loc: (redir_loc.Fd fd:0)
          arg: 
            (redir_param.MultiLine
              here_begin: {<EOF>}
              here_end_span_id: 879
              stdin_parts: [
                <'---\n'>
                <'Message-Id: <0>\n'>
                <'In-Reply-To: <1>\n'>
                <'References: <1>\n'>
                <'---\n'>
                <'Message-Id: <2>\n'>
                <'In-Reply-To: <1>\n'>
                <'References: <1>\n'>
                <'---\n'>
                <'Message-Id: <3>\n'>
                <'In-Reply-To: <1>\n'>
                <'References: <1>\n'>
              ]
            )
        )
      ]
      do_fork: T
    )
    (C {<test_expect_success>} {(SQ <'thread in-reply-to'>)} 
      {
        (SQ <'\n'> <'\tcheck_threading expect.in-reply-to --in-reply-to="<test.message>" \\\n'> 
          <'\t\t--thread master\n'>
        )
      }
    )
    (command.Simple
      words: [{<cat>}]
      redirects: [
        (redir op:<Id.Redir_Great '>'> loc:(redir_loc.Fd fd:1) arg:{<expect.cover-letter>})
        (redir
          op: <Id.Redir_DLess '<<'>
          loc: (redir_loc.Fd fd:0)
          arg: 
            (redir_param.MultiLine
              here_begin: {<EOF>}
              here_end_span_id: 918
              stdin_parts: [
                <'---\n'>
                <'Message-Id: <0>\n'>
                <'---\n'>
                <'Message-Id: <1>\n'>
                <'In-Reply-To: <0>\n'>
                <'References: <0>\n'>
                <'---\n'>
                <'Message-Id: <2>\n'>
                <'In-Reply-To: <0>\n'>
                <'References: <0>\n'>
                <'---\n'>
                <'Message-Id: <3>\n'>
                <'In-Reply-To: <0>\n'>
                <'References: <0>\n'>
              ]
            )
        )
      ]
      do_fork: T
    )
    (C {<test_expect_success>} {(SQ <'thread cover-letter'>)} 
      {(SQ <'\n'> <'\tcheck_threading expect.cover-letter --cover-letter --thread master\n'>)}
    )
    (command.Simple
      words: [{<cat>}]
      redirects: [
        (redir op:<Id.Redir_Great '>'> loc:(redir_loc.Fd fd:1) arg:{<expect.cl-irt>})
        (redir
          op: <Id.Redir_DLess '<<'>
          loc: (redir_loc.Fd fd:0)
          arg: 
            (redir_param.MultiLine
              here_begin: {<EOF>}
              here_end_span_id: 961
              stdin_parts: [
                <'---\n'>
                <'Message-Id: <0>\n'>
                <'In-Reply-To: <1>\n'>
                <'References: <1>\n'>
                <'---\n'>
                <'Message-Id: <2>\n'>
                <'In-Reply-To: <0>\n'>
                <'References: <1>\n'>
                <'\t<0>\n'>
                <'---\n'>
                <'Message-Id: <3>\n'>
                <'In-Reply-To: <0>\n'>
                <'References: <1>\n'>
                <'\t<0>\n'>
                <'---\n'>
                <'Message-Id: <4>\n'>
                <'In-Reply-To: <0>\n'>
                <'References: <1>\n'>
                <'\t<0>\n'>
              ]
            )
        )
      ]
      do_fork: T
    )
    (C {<test_expect_success>} {(SQ <'thread cover-letter in-reply-to'>)} 
      {
        (SQ <'\n'> <'\tcheck_threading expect.cl-irt --cover-letter \\\n'> 
          <'\t\t--in-reply-to="<test.message>" --thread master\n'>
        )
      }
    )
    (C {<test_expect_success>} {(SQ <'thread explicit shallow'>)} 
      {
        (SQ <'\n'> <'\tcheck_threading expect.cl-irt --cover-letter \\\n'> 
          <'\t\t--in-reply-to="<test.message>" --thread=shallow master\n'>
        )
      }
    )
    (command.Simple
      words: [{<cat>}]
      redirects: [
        (redir op:<Id.Redir_Great '>'> loc:(redir_loc.Fd fd:1) arg:{<expect.deep>})
        (redir
          op: <Id.Redir_DLess '<<'>
          loc: (redir_loc.Fd fd:0)
          arg: 
            (redir_param.MultiLine
              here_begin: {<EOF>}
              here_end_span_id: 1010
              stdin_parts: [
                <'---\n'>
                <'Message-Id: <0>\n'>
                <'---\n'>
                <'Message-Id: <1>\n'>
                <'In-Reply-To: <0>\n'>
                <'References: <0>\n'>
                <'---\n'>
                <'Message-Id: <2>\n'>
                <'In-Reply-To: <1>\n'>
                <'References: <0>\n'>
                <'\t<1>\n'>
              ]
            )
        )
      ]
      do_fork: T
    )
    (C {<test_expect_success>} {(SQ <'thread deep'>)} 
      {(SQ <'\n'> <'\tcheck_threading expect.deep --thread=deep master\n'>)}
    )
    (command.Simple
      words: [{<cat>}]
      redirects: [
        (redir op:<Id.Redir_Great '>'> loc:(redir_loc.Fd fd:1) arg:{<expect.deep-irt>})
        (redir
          op: <Id.Redir_DLess '<<'>
          loc: (redir_loc.Fd fd:0)
          arg: 
            (redir_param.MultiLine
              here_begin: {<EOF>}
              here_end_span_id: 1049
              stdin_parts: [
                <'---\n'>
                <'Message-Id: <0>\n'>
                <'In-Reply-To: <1>\n'>
                <'References: <1>\n'>
                <'---\n'>
                <'Message-Id: <2>\n'>
                <'In-Reply-To: <0>\n'>
                <'References: <1>\n'>
                <'\t<0>\n'>
                <'---\n'>
                <'Message-Id: <3>\n'>
                <'In-Reply-To: <2>\n'>
                <'References: <1>\n'>
                <'\t<0>\n'>
                <'\t<2>\n'>
              ]
            )
        )
      ]
      do_fork: T
    )
    (C {<test_expect_success>} {(SQ <'thread deep in-reply-to'>)} 
      {
        (SQ <'\n'> <'\tcheck_threading expect.deep-irt  --thread=deep \\\n'> 
          <'\t\t--in-reply-to="<test.message>" master\n'>
        )
      }
    )
    (command.Simple
      words: [{<cat>}]
      redirects: [
        (redir op:<Id.Redir_Great '>'> loc:(redir_loc.Fd fd:1) arg:{<expect.deep-cl>})
        (redir
          op: <Id.Redir_DLess '<<'>
          loc: (redir_loc.Fd fd:0)
          arg: 
            (redir_param.MultiLine
              here_begin: {<EOF>}
              here_end_span_id: 1091
              stdin_parts: [
                <'---\n'>
                <'Message-Id: <0>\n'>
                <'---\n'>
                <'Message-Id: <1>\n'>
                <'In-Reply-To: <0>\n'>
                <'References: <0>\n'>
                <'---\n'>
                <'Message-Id: <2>\n'>
                <'In-Reply-To: <1>\n'>
                <'References: <0>\n'>
                <'\t<1>\n'>
                <'---\n'>
                <'Message-Id: <3>\n'>
                <'In-Reply-To: <2>\n'>
                <'References: <0>\n'>
                <'\t<1>\n'>
                <'\t<2>\n'>
              ]
            )
        )
      ]
      do_fork: T
    )
    (C {<test_expect_success>} {(SQ <'thread deep cover-letter'>)} 
      {(SQ <'\n'> <'\tcheck_threading expect.deep-cl --cover-letter --thread=deep master\n'>)}
    )
    (command.Simple
      words: [{<cat>}]
      redirects: [
        (redir op:<Id.Redir_Great '>'> loc:(redir_loc.Fd fd:1) arg:{<expect.deep-cl-irt>})
        (redir
          op: <Id.Redir_DLess '<<'>
          loc: (redir_loc.Fd fd:0)
          arg: 
            (redir_param.MultiLine
              here_begin: {<EOF>}
              here_end_span_id: 1137
              stdin_parts: [
                <'---\n'>
                <'Message-Id: <0>\n'>
                <'In-Reply-To: <1>\n'>
                <'References: <1>\n'>
                <'---\n'>
                <'Message-Id: <2>\n'>
                <'In-Reply-To: <0>\n'>
                <'References: <1>\n'>
                <'\t<0>\n'>
                <'---\n'>
                <'Message-Id: <3>\n'>
                <'In-Reply-To: <2>\n'>
                <'References: <1>\n'>
                <'\t<0>\n'>
                <'\t<2>\n'>
                <'---\n'>
                <'Message-Id: <4>\n'>
                <'In-Reply-To: <3>\n'>
                <'References: <1>\n'>
                <'\t<0>\n'>
                <'\t<2>\n'>
                <'\t<3>\n'>
              ]
            )
        )
      ]
      do_fork: T
    )
    (C {<test_expect_success>} {(SQ <'thread deep cover-letter in-reply-to'>)} 
      {
        (SQ <'\n'> <'\tcheck_threading expect.deep-cl-irt --cover-letter \\\n'> 
          <'\t\t--in-reply-to="<test.message>" --thread=deep master\n'>
        )
      }
    )
    (C {<test_expect_success>} {(SQ <'thread via config'>)} 
      {
        (SQ <'\n'> <'\ttest_config format.thread true &&\n'> 
          <'\tcheck_threading expect.thread master\n'>
        )
      }
    )
    (C {<test_expect_success>} {(SQ <'thread deep via config'>)} 
      {
        (SQ <'\n'> <'\ttest_config format.thread deep &&\n'> <'\tcheck_threading expect.deep master\n'>)
      }
    )
    (C {<test_expect_success>} {(SQ <'thread config + override'>)} 
      {
        (SQ <'\n'> <'\ttest_config format.thread deep &&\n'> 
          <'\tcheck_threading expect.thread --thread master\n'>
        )
      }
    )
    (C {<test_expect_success>} {(SQ <'thread config + --no-thread'>)} 
      {
        (SQ <'\n'> <'\ttest_config format.thread deep &&\n'> 
          <'\tcheck_threading expect.no-threading --no-thread master\n'>
        )
      }
    )
    (C {<test_expect_success>} {(SQ <'excessive subject'>)} 
      {
        (SQ <'\n'> <'\n'> <'\trm -rf patches/ &&\n'> <'\tgit checkout side &&\n'> 
          <'\tfor i in 5 6 1 2 3 A 4 B C 7 8 9 10 D E F; do echo "$i"; done >>file &&\n'> <'\tgit update-index file &&\n'> 
          <
'\tgit commit -m "This is an excessively long subject line for a message due to the habit some projects have of not having a short, one-line subject at the start of the commit message, but rather sticking a whole paragraph right at the start as the only thing in the commit message. It had better not become the filename for the patch." &&\n'
          > <'\tgit format-patch -o patches/ master..side &&\n'> 
          <'\tls patches/0004-This-is-an-excessively-long-subject-line-for-a-messa.patch\n'>
        )
      }
    )
    (C {<test_expect_success>} {(SQ <'cover-letter inherits diff options'>)} 
      {
        (SQ <'\n'> <'\n'> <'\tgit mv file foo &&\n'> <'\tgit commit -m foo &&\n'> 
          <'\tgit format-patch --no-renames --cover-letter -1 &&\n'> <'\tcheck_patch 0000-cover-letter.patch &&\n'> 
          <'\t! grep "file => foo .* 0 *\\$" 0000-cover-letter.patch &&\n'> <'\tgit format-patch --cover-letter -1 -M &&\n'> 
          <'\tgrep "file => foo .* 0 *\\$" 0000-cover-letter.patch\n'> <'\n'>
        )
      }
    )
    (command.Simple
      words: [{<cat>}]
      redirects: [
        (redir op:<Id.Redir_Great '>'> loc:(redir_loc.Fd fd:1) arg:{<expect>})
        (redir
          op: <Id.Redir_DLess '<<'>
          loc: (redir_loc.Fd fd:0)
          arg: 
            (redir_param.MultiLine
              here_begin: {<EOF>}
              here_end_span_id: 1261
              stdin_parts: [
                <'  This is an excessively long subject line for a message due to the\n'>
                <'    habit some projects have of not having a short, one-line subject at\n'>
                <'    the start of the commit message, but rather sticking a whole\n'>
                <'    paragraph right at the start as the only thing in the commit\n'>
                <'    message. It had better not become the filename for the patch.\n'>
                <'  foo\n'>
                <'\n'>
              ]
            )
        )
      ]
      do_fork: T
    )
    (C {<test_expect_success>} {(SQ <'shortlog of cover-letter wraps overly-long onelines'>)} 
      {
        (SQ <'\n'> <'\n'> <'\tgit format-patch --cover-letter -2 &&\n'> 
          <'\tsed -e "1,/A U Thor/d" -e "/^\\$/q" < 0000-cover-letter.patch > output &&\n'> <'\ttest_cmp expect output\n'> <'\n'>
        )
      }
    )
    (command.Simple
      words: [{<cat>}]
      redirects: [
        (redir op:<Id.Redir_Great '>'> loc:(redir_loc.Fd fd:1) arg:{<expect>})
        (redir
          op: <Id.Redir_DLess '<<'>
          loc: (redir_loc.Fd fd:0)
          arg: 
            (redir_param.MultiLine
              here_begin: {<EOF>}
              here_end_span_id: 1299
              stdin_parts: [
                <'index 40f36c6..2dc5c23 100644\n'>
                <'--- a/file\n'>
                <'+++ b/file\n'>
                <'@@ -13,4 +13,20 @@ C\n'>
                <' 10\n'>
                <' D\n'>
                <' E\n'>
                <' F\n'>
                <'+5\n'>
              ]
            )
        )
      ]
      do_fork: T
    )
    (C {<test_expect_success>} {(SQ <'format-patch respects -U'>)} 
      {
        (SQ <'\n'> <'\n'> <'\tgit format-patch -U4 -2 &&\n'> <'\tsed -e "1,/^diff/d" -e "/^+5/q" \\\n'> 
          <'\t\t<0001-This-is-an-excessively-long-subject-line-for-a-messa.patch \\\n'> <'\t\t>output &&\n'> <'\ttest_cmp expect output\n'> <'\n'>
        )
      }
    )
    (command.Simple
      words: [{<cat>}]
      redirects: [
        (redir op:<Id.Redir_Great '>'> loc:(redir_loc.Fd fd:1) arg:{<expect>})
        (redir
          op: <Id.Redir_DLess '<<'>
          loc: (redir_loc.Fd fd:0)
          arg: 
            (redir_param.MultiLine
              here_begin: {<EOF>}
              here_end_span_id: 1340
              stdin_parts: [
                <'\n'>
                <'diff --git a/file b/file\n'>
                <'index 40f36c6..2dc5c23 100644\n'>
                <'--- a/file\n'>
                <'+++ b/file\n'>
                <'@@ -14,3 +14,19 @@ C\n'>
                <' D\n'>
                <' E\n'>
                <' F\n'>
                <'+5\n'>
              ]
            )
        )
      ]
      do_fork: T
    )
    (C {<test_expect_success>} {(SQ <'format-patch -p suppresses stat'>)} 
      {
        (SQ <'\n'> <'\n'> <'\tgit format-patch -p -2 &&\n'> 
          <
'\tsed -e "1,/^\\$/d" -e "/^+5/q" < 0001-This-is-an-excessively-long-subject-line-for-a-messa.patch > output &&\n'
          > <'\ttest_cmp expect output\n'> <'\n'>
        )
      }
    )
    (C {<test_expect_success>} {(SQ <'format-patch from a subdirectory (1)'>)} 
      {
        (SQ <'\n'> <'\tfilename=$(\n'> <'\t\trm -rf sub &&\n'> <'\t\tmkdir -p sub/dir &&\n'> 
          <'\t\tcd sub/dir &&\n'> <'\t\tgit format-patch -1\n'> <'\t) &&\n'> <'\tcase "$filename" in\n'> <'\t0*)\n'> <'\t\t;; # ok\n'> 
          <'\t*)\n'> <'\t\techo "Oops? $filename"\n'> <'\t\tfalse\n'> <'\t\t;;\n'> <'\tesac &&\n'> <'\ttest -f "$filename"\n'>
        )
      }
    )
    (C {<test_expect_success>} {(SQ <'format-patch from a subdirectory (2)'>)} 
      {
        (SQ <'\n'> <'\tfilename=$(\n'> <'\t\trm -rf sub &&\n'> <'\t\tmkdir -p sub/dir &&\n'> 
          <'\t\tcd sub/dir &&\n'> <'\t\tgit format-patch -1 -o ..\n'> <'\t) &&\n'> <'\tcase "$filename" in\n'> <'\t../0*)\n'> 
          <'\t\t;; # ok\n'> <'\t*)\n'> <'\t\techo "Oops? $filename"\n'> <'\t\tfalse\n'> <'\t\t;;\n'> <'\tesac &&\n'> 
          <'\tbasename=$(expr "$filename" : ".*/\\(.*\\)") &&\n'> <'\ttest -f "sub/$basename"\n'>
        )
      }
    )
    (C {<test_expect_success>} {(SQ <'format-patch from a subdirectory (3)'>)} 
      {
        (SQ <'\n'> <'\trm -f 0* &&\n'> <'\tfilename=$(\n'> <'\t\trm -rf sub &&\n'> 
          <'\t\tmkdir -p sub/dir &&\n'> <'\t\tcd sub/dir &&\n'> <'\t\tgit format-patch -1 -o "$TRASH_DIRECTORY"\n'> <'\t) &&\n'> 
          <'\tbasename=$(expr "$filename" : ".*/\\(.*\\)") &&\n'> <'\ttest -f "$basename"\n'>
        )
      }
    )
    (C {<test_expect_success>} {(SQ <'format-patch --in-reply-to'>)} 
      {
        (SQ <'\n'> <'\tgit format-patch -1 --stdout --in-reply-to "baz@foo.bar" > patch8 &&\n'> 
          <'\tgrep "^In-Reply-To: <baz@foo.bar>" patch8 &&\n'> <'\tgrep "^References: <baz@foo.bar>" patch8\n'>
        )
      }
    )
    (C {<test_expect_success>} {(SQ <'format-patch --signoff'>)} 
      {
        (SQ <'\n'> <'\tgit format-patch -1 --signoff --stdout >out &&\n'> 
          <'\tgrep "^Signed-off-by: $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL>" out\n'>
        )
      }
    )
    (C {<test_expect_success>} {(SQ <'format-patch --notes --signoff'>)} 
      {
        (SQ <'\n'> <'\tgit notes --ref test add -m "test message" HEAD &&\n'> 
          <'\tgit format-patch -1 --signoff --stdout --notes=test >out &&\n'> <'\t# Three dashes must come after S-o-b\n'> 
          <'\t! sed "/^Signed-off-by: /q" out | grep "test message" &&\n'> <'\tsed "1,/^Signed-off-by: /d" out | grep "test message" &&\n'> 
          <'\t# Notes message must come after three dashes\n'> <'\t! sed "/^---$/q" out | grep "test message" &&\n'> 
          <'\tsed "1,/^---$/d" out | grep "test message"\n'>
        )
      }
    )
    (command.Simple
      words: [{<echo>} {(DQ <'fatal: --name-only does not make sense'>)}]
      redirects: [(redir op:<Id.Redir_Great '>'> loc:(redir_loc.Fd fd:1) arg:{<expect.name-only>})]
      do_fork: T
    )
    (command.Simple
      words: [{<echo>} {(DQ <'fatal: --name-status does not make sense'>)}]
      redirects: [(redir op:<Id.Redir_Great '>'> loc:(redir_loc.Fd fd:1) arg:{<expect.name-status>})]
      do_fork: T
    )
    (command.Simple
      words: [{<echo>} {(DQ <'fatal: --check does not make sense'>)}]
      redirects: [(redir op:<Id.Redir_Great '>'> loc:(redir_loc.Fd fd:1) arg:{<expect.check>})]
      do_fork: T
    )
    (C {<test_expect_success>} {(SQ <'options no longer allowed for format-patch'>)} 
      {
        (SQ <'\n'> <'\ttest_must_fail git format-patch --name-only 2> output &&\n'> 
          <'\ttest_i18ncmp expect.name-only output &&\n'> <'\ttest_must_fail git format-patch --name-status 2> output &&\n'> 
          <'\ttest_i18ncmp expect.name-status output &&\n'> <'\ttest_must_fail git format-patch --check 2> output &&\n'> <'\ttest_i18ncmp expect.check output'>
        )
      }
    )
    (C {<test_expect_success>} {(SQ <'format-patch --numstat should produce a patch'>)} 
      {
        (SQ <'\n'> <'\tgit format-patch --numstat --stdout master..side > output &&\n'> 
          <'\ttest 5 = $(grep "^diff --git a/" output | wc -l)'>
        )
      }
    )
    (C {<test_expect_success>} {(SQ <'format-patch -- <path>'>)} 
      {
        (SQ <'\n'> <'\tgit format-patch master..side -- file 2>error &&\n'> 
          <'\t! grep "Use .--" error\n'>
        )
      }
    )
    (C {<test_expect_success>} {(SQ <'format-patch --ignore-if-in-upstream HEAD'>)} 
      {(SQ <'\n'> <'\tgit format-patch --ignore-if-in-upstream HEAD\n'>)}
    )
    (command.ShAssignment
      pairs: [
        (assign_pair
          lhs: (sh_lhs_expr.Name name:git_version)
          op: assign_op.Equal
          rhs: 
            {
              (DQ 
                (command_sub
                  left_token: <Id.Left_DollarParen '$('>
                  child: 
                    (command.Pipeline
                      children: [(C {<git>} {<--version>}) (C {<sed>} {(DQ <'s/.* //'>)})]
                      negated: F
                    )
                )
              )
            }
          spids: [1563]
        )
      ]
    )
    (command.ShFunction
      name: signature
      body: 
        (BraceGroup
          children: [
            (C {<printf>} 
              {
                (DQ <'%s'> <Id.Lit_Other '\\'> <'n%s'> <Id.Lit_Other '\\'> <n> <Id.Lit_Other '\\'> <n>)
              } {(DQ <'-- '>)} 
              {
                (DQ 
                  (braced_var_sub
                    token: <Id.VSub_Number 1>
                    suffix_op: 
                      (suffix_op.Unary
                        op_id: Id.VTest_ColonHyphen
                        arg_word: {($ Id.VSub_DollarName '$git_version')}
                      )
                  )
                )
              }
            )
          ]
        )
    )
    (C {<test_expect_success>} {(SQ <'format-patch default signature'>)} 
      {
        (SQ <'\n'> <'\tgit format-patch --stdout -1 | tail -n 3 >output &&\n'> 
          <'\tsignature >expect &&\n'> <'\ttest_cmp expect output\n'>
        )
      }
    )
    (C {<test_expect_success>} {(SQ <'format-patch --signature'>)} 
      {
        (SQ <'\n'> <'\tgit format-patch --stdout --signature="my sig" -1 | tail -n 3 >output &&\n'> 
          <'\tsignature "my sig" >expect &&\n'> <'\ttest_cmp expect output\n'>
        )
      }
    )
    (C {<test_expect_success>} {(SQ <'format-patch with format.signature config'>)} 
      {
        (SQ <'\n'> <'\tgit config format.signature "config sig" &&\n'> 
          <'\tgit format-patch --stdout -1 >output &&\n'> <'\tgrep "config sig" output\n'>
        )
      }
    )
    (C {<test_expect_success>} {(SQ <'format-patch --signature overrides format.signature'>)} 
      {
        (SQ <'\n'> <'\tgit config format.signature "config sig" &&\n'> 
          <'\tgit format-patch --stdout --signature="overrides" -1 >output &&\n'> <'\t! grep "config sig" output &&\n'> <'\tgrep "overrides" output\n'>
        )
      }
    )
    (C {<test_expect_success>} {(SQ <'format-patch --no-signature ignores format.signature'>)} 
      {
        (SQ <'\n'> <'\tgit config format.signature "config sig" &&\n'> 
          <'\tgit format-patch --stdout --signature="my sig" --no-signature \\\n'> <'\t\t-1 >output &&\n'> <'\tcheck_patch output &&\n'> <'\t! grep "config sig" output &&\n'> 
          <'\t! grep "my sig" output &&\n'> <'\t! grep "^-- \\$" output\n'>
        )
      }
    )
    (C {<test_expect_success>} {(SQ <'format-patch --signature --cover-letter'>)} 
      {
        (SQ <'\n'> <'\tgit config --unset-all format.signature &&\n'> 
          <'\tgit format-patch --stdout --signature="my sig" --cover-letter \\\n'> <'\t\t-1 >output &&\n'> <'\tgrep "my sig" output &&\n'> 
          <'\ttest 2 = $(grep "my sig" output | wc -l)\n'>
        )
      }
    )
    (C {<test_expect_success>} {(SQ <'format.signature="" suppresses signatures'>)} 
      {
        (SQ <'\n'> <'\tgit config format.signature "" &&\n'> 
          <'\tgit format-patch --stdout -1 >output &&\n'> <'\tcheck_patch output &&\n'> <'\t! grep "^-- \\$" output\n'>
        )
      }
    )
    (C {<test_expect_success>} {(SQ <'format-patch --no-signature suppresses signatures'>)} 
      {
        (SQ <'\n'> <'\tgit config --unset-all format.signature &&\n'> 
          <'\tgit format-patch --stdout --no-signature -1 >output &&\n'> <'\tcheck_patch output &&\n'> <'\t! grep "^-- \\$" output\n'>
        )
      }
    )
    (C {<test_expect_success>} {(SQ <'format-patch --signature="" suppresses signatures'>)} 
      {
        (SQ <'\n'> <'\tgit format-patch --stdout --signature="" -1 >output &&\n'> 
          <'\tcheck_patch output &&\n'> <'\t! grep "^-- \\$" output\n'>
        )
      }
    )
    (C {<test_expect_success>} {(SQ <'prepare mail-signature input'>)} 
      {
        (SQ <'\n'> <'\tcat >mail-signature <<-\\EOF\n'> <'\n'> <'\tTest User <test.email@kernel.org>\n'> 
          <'\thttp://git.kernel.org/cgit/git/git.git\n'> <'\n'> <'\tgit.kernel.org/?p=git/git.git;a=summary\n'> <'\n'> <'\tEOF\n'>
        )
      }
    )
    (C {<test_expect_success>} {(SQ <'--signature-file=file works'>)} 
      {
        (SQ <'\n'> <'\tgit format-patch --stdout --signature-file=mail-signature -1 >output &&\n'> 
          <'\tcheck_patch output &&\n'> <'\tsed -e "1,/^-- \\$/d" <output >actual &&\n'> <'\t{\n'> <'\t\tcat mail-signature && echo\n'> 
          <'\t} >expect &&\n'> <'\ttest_cmp expect actual\n'>
        )
      }
    )
    (C {<test_expect_success>} {(SQ <'format.signaturefile works'>)} 
      {
        (SQ <'\n'> <'\ttest_config format.signaturefile mail-signature &&\n'> 
          <'\tgit format-patch --stdout -1 >output &&\n'> <'\tcheck_patch output &&\n'> <'\tsed -e "1,/^-- \\$/d" <output >actual &&\n'> <'\t{\n'> 
          <'\t\tcat mail-signature && echo\n'> <'\t} >expect &&\n'> <'\ttest_cmp expect actual\n'>
        )
      }
    )
    (C {<test_expect_success>} {(SQ <'--no-signature suppresses format.signaturefile '>)} 
      {
        (SQ <'\n'> <'\ttest_config format.signaturefile mail-signature &&\n'> 
          <'\tgit format-patch --stdout --no-signature -1 >output &&\n'> <'\tcheck_patch output &&\n'> <'\t! grep "^-- \\$" output\n'>
        )
      }
    )
    (C {<test_expect_success>} {(SQ <'--signature-file overrides format.signaturefile'>)} 
      {
        (SQ <'\n'> <'\tcat >other-mail-signature <<-\\EOF &&\n'> 
          <'\tUse this other signature instead of mail-signature.\n'> <'\tEOF\n'> <'\ttest_config format.signaturefile mail-signature &&\n'> 
          <'\tgit format-patch --stdout \\\n'> <'\t\t\t--signature-file=other-mail-signature -1 >output &&\n'> <'\tcheck_patch output &&\n'> 
          <'\tsed -e "1,/^-- \\$/d" <output >actual &&\n'> <'\t{\n'> <'\t\tcat other-mail-signature && echo\n'> <'\t} >expect &&\n'> <'\ttest_cmp expect actual\n'>
        )
      }
    )
    (C {<test_expect_success>} {(SQ <'--signature overrides format.signaturefile'>)} 
      {
        (SQ <'\n'> <'\ttest_config format.signaturefile mail-signature &&\n'> 
          <'\tgit format-patch --stdout --signature="my sig" -1 >output &&\n'> <'\tcheck_patch output &&\n'> <'\tgrep "my sig" output\n'>
        )
      }
    )
    (C {<test_expect_success>} {<TTY>} {(SQ <'format-patch --stdout paginates'>)} 
      {
        (SQ <'\n'> <'\trm -f pager_used &&\n'> 
          <'\ttest_terminal env GIT_PAGER="wc >pager_used" git format-patch --stdout --all &&\n'> <'\ttest_path_is_file pager_used\n'>
        )
      }
    )
    (C {<test_expect_success>} {<TTY>} {(SQ <'format-patch --stdout pagination can be disabled'>)} 
      {
        (SQ <'\n'> <'\trm -f pager_used &&\n'> 
          <
'\ttest_terminal env GIT_PAGER="wc >pager_used" git --no-pager format-patch --stdout --all &&\n'
          > 
          <
'\ttest_terminal env GIT_PAGER="wc >pager_used" git -c "pager.format-patch=false" format-patch --stdout --all &&\n'
          > <'\ttest_path_is_missing pager_used &&\n'> <'\ttest_path_is_missing .git/pager_used\n'>
        )
      }
    )
    (C {<test_expect_success>} {(SQ <'format-patch handles multi-line subjects'>)} 
      {
        (SQ <'\n'> <'\trm -rf patches/ &&\n'> <'\techo content >>file &&\n'> 
          <'\tfor i in one two three; do echo $i; done >msg &&\n'> <'\tgit add file &&\n'> <'\tgit commit -F msg &&\n'> <'\tgit format-patch -o patches -1 &&\n'> 
          <'\tgrep ^Subject: patches/0001-one.patch >actual &&\n'> <'\techo "Subject: [PATCH] one two three" >expect &&\n'> <'\ttest_cmp expect actual\n'>
        )
      }
    )
    (C {<test_expect_success>} {(SQ <'format-patch handles multi-line encoded subjects'>)} 
      {
        (SQ <'\n'> <'\trm -rf patches/ &&\n'> <'\techo content >>file &&\n'> 
          <'\tfor i in en två tre; do echo $i; done >msg &&\n'> <'\tgit add file &&\n'> <'\tgit commit -F msg &&\n'> <'\tgit format-patch -o patches -1 &&\n'> 
          <'\tgrep ^Subject: patches/0001-en.patch >actual &&\n'> <'\techo "Subject: [PATCH] =?UTF-8?q?en=20tv=C3=A5=20tre?=" >expect &&\n'> 
          <'\ttest_cmp expect actual\n'>
        )
      }
    )
    (command.ShAssignment
      pairs: [
        (assign_pair
          lhs: (sh_lhs_expr.Name name:M8)
          op: assign_op.Equal
          rhs: {(DQ <'foo bar '>)}
          spids: [1934]
        )
      ]
    )
    (command.ShAssignment
      pairs: [
        (assign_pair
          lhs: (sh_lhs_expr.Name name:M64)
          op: assign_op.Equal
          rhs: 
            {($ Id.VSub_DollarName '$M8') ($ Id.VSub_DollarName '$M8') ($ Id.VSub_DollarName '$M8') 
              ($ Id.VSub_DollarName '$M8') ($ Id.VSub_DollarName '$M8') ($ Id.VSub_DollarName '$M8') ($ Id.VSub_DollarName '$M8') 
              ($ Id.VSub_DollarName '$M8')
            }
          spids: [1939]
        )
      ]
    )
    (command.ShAssignment
      pairs: [
        (assign_pair
          lhs: (sh_lhs_expr.Name name:M512)
          op: assign_op.Equal
          rhs: 
            {($ Id.VSub_DollarName '$M64') ($ Id.VSub_DollarName '$M64') ($ Id.VSub_DollarName '$M64') 
              ($ Id.VSub_DollarName '$M64') ($ Id.VSub_DollarName '$M64') ($ Id.VSub_DollarName '$M64') ($ Id.VSub_DollarName '$M64') 
              ($ Id.VSub_DollarName '$M64')
            }
          spids: [1949]
        )
      ]
    )
    (command.Simple
      words: [{<cat>}]
      redirects: [
        (redir op:<Id.Redir_Great '>'> loc:(redir_loc.Fd fd:1) arg:{<expect>})
        (redir
          op: <Id.Redir_DLess '<<'>
          loc: (redir_loc.Fd fd:0)
          arg: 
            (redir_param.MultiLine
              here_begin: {(SQ <EOF>)}
              here_end_span_id: 1976
              stdin_parts: [
                <'Subject: [PATCH] foo bar foo bar foo bar foo bar foo bar foo bar foo bar foo\n'>
                <' bar foo bar foo bar foo bar foo bar foo bar foo bar foo bar foo bar foo bar\n'>
                <' foo bar foo bar foo bar foo bar foo bar foo bar foo bar foo bar foo bar foo\n'>
                <' bar foo bar foo bar foo bar foo bar foo bar foo bar foo bar foo bar foo bar\n'>
                <' foo bar foo bar foo bar foo bar foo bar foo bar foo bar foo bar foo bar foo\n'>
                <' bar foo bar foo bar foo bar foo bar foo bar foo bar foo bar foo bar foo bar\n'>
                <' foo bar foo bar foo bar foo bar foo bar foo bar foo bar foo bar foo bar\n'>
              ]
            )
        )
      ]
      do_fork: T
    )
    (C {<test_expect_success>} {(SQ <'format-patch wraps extremely long subject (ascii)'>)} 
      {
        (SQ <'\n'> <'\techo content >>file &&\n'> <'\tgit add file &&\n'> 
          <'\tgit commit -m "$M512" &&\n'> <'\tgit format-patch --stdout -1 >patch &&\n'> 
          <'\tsed -n "/^Subject/p; /^ /p; /^$/q" <patch >subject &&\n'> <'\ttest_cmp expect subject\n'>
        )
      }
    )
    (command.ShAssignment
      pairs: [
        (assign_pair
          lhs: (sh_lhs_expr.Name name:M8)
          op: assign_op.Equal
          rhs: {(DQ <'föö bar '>)}
          spids: [1994]
        )
      ]
    )
    (command.ShAssignment
      pairs: [
        (assign_pair
          lhs: (sh_lhs_expr.Name name:M64)
          op: assign_op.Equal
          rhs: 
            {($ Id.VSub_DollarName '$M8') ($ Id.VSub_DollarName '$M8') ($ Id.VSub_DollarName '$M8') 
              ($ Id.VSub_DollarName '$M8') ($ Id.VSub_DollarName '$M8') ($ Id.VSub_DollarName '$M8') ($ Id.VSub_DollarName '$M8') 
              ($ Id.VSub_DollarName '$M8')
            }
          spids: [1999]
        )
      ]
    )
    (command.ShAssignment
      pairs: [
        (assign_pair
          lhs: (sh_lhs_expr.Name name:M512)
          op: assign_op.Equal
          rhs: 
            {($ Id.VSub_DollarName '$M64') ($ Id.VSub_DollarName '$M64') ($ Id.VSub_DollarName '$M64') 
              ($ Id.VSub_DollarName '$M64') ($ Id.VSub_DollarName '$M64') ($ Id.VSub_DollarName '$M64') ($ Id.VSub_DollarName '$M64') 
              ($ Id.VSub_DollarName '$M64')
            }
          spids: [2009]
        )
      ]
    )
    (command.Simple
      words: [{<cat>}]
      redirects: [
        (redir op:<Id.Redir_Great '>'> loc:(redir_loc.Fd fd:1) arg:{<expect>})
        (redir
          op: <Id.Redir_DLess '<<'>
          loc: (redir_loc.Fd fd:0)
          arg: 
            (redir_param.MultiLine
              here_begin: {(SQ <EOF>)}
              here_end_span_id: 2053
              stdin_parts: [
                <'Subject: [PATCH] =?UTF-8?q?f=C3=B6=C3=B6=20bar=20f=C3=B6=C3=B6=20bar=20f?=\n'>
                <' =?UTF-8?q?=C3=B6=C3=B6=20bar=20f=C3=B6=C3=B6=20bar=20f=C3=B6=C3=B6=20bar?=\n'>
                <' =?UTF-8?q?=20f=C3=B6=C3=B6=20bar=20f=C3=B6=C3=B6=20bar=20f=C3=B6=C3=B6=20?=\n'>
                <' =?UTF-8?q?bar=20f=C3=B6=C3=B6=20bar=20f=C3=B6=C3=B6=20bar=20f=C3=B6=C3=B6?=\n'>
                <' =?UTF-8?q?=20bar=20f=C3=B6=C3=B6=20bar=20f=C3=B6=C3=B6=20bar=20f=C3=B6?=\n'>
                <' =?UTF-8?q?=C3=B6=20bar=20f=C3=B6=C3=B6=20bar=20f=C3=B6=C3=B6=20bar=20f?=\n'>
                <' =?UTF-8?q?=C3=B6=C3=B6=20bar=20f=C3=B6=C3=B6=20bar=20f=C3=B6=C3=B6=20bar?=\n'>
                <' =?UTF-8?q?=20f=C3=B6=C3=B6=20bar=20f=C3=B6=C3=B6=20bar=20f=C3=B6=C3=B6=20?=\n'>
                <' =?UTF-8?q?bar=20f=C3=B6=C3=B6=20bar=20f=C3=B6=C3=B6=20bar=20f=C3=B6=C3=B6?=\n'>
                <' =?UTF-8?q?=20bar=20f=C3=B6=C3=B6=20bar=20f=C3=B6=C3=B6=20bar=20f=C3=B6?=\n'>
                <' =?UTF-8?q?=C3=B6=20bar=20f=C3=B6=C3=B6=20bar=20f=C3=B6=C3=B6=20bar=20f?=\n'>
                <' =?UTF-8?q?=C3=B6=C3=B6=20bar=20f=C3=B6=C3=B6=20bar=20f=C3=B6=C3=B6=20bar?=\n'>
                <' =?UTF-8?q?=20f=C3=B6=C3=B6=20bar=20f=C3=B6=C3=B6=20bar=20f=C3=B6=C3=B6=20?=\n'>
                <' =?UTF-8?q?bar=20f=C3=B6=C3=B6=20bar=20f=C3=B6=C3=B6=20bar=20f=C3=B6=C3=B6?=\n'>
                <' =?UTF-8?q?=20bar=20f=C3=B6=C3=B6=20bar=20f=C3=B6=C3=B6=20bar=20f=C3=B6?=\n'>
                <' =?UTF-8?q?=C3=B6=20bar=20f=C3=B6=C3=B6=20bar=20f=C3=B6=C3=B6=20bar=20f?=\n'>
                <' =?UTF-8?q?=C3=B6=C3=B6=20bar=20f=C3=B6=C3=B6=20bar=20f=C3=B6=C3=B6=20bar?=\n'>
                <' =?UTF-8?q?=20f=C3=B6=C3=B6=20bar=20f=C3=B6=C3=B6=20bar=20f=C3=B6=C3=B6=20?=\n'>
                <' =?UTF-8?q?bar=20f=C3=B6=C3=B6=20bar=20f=C3=B6=C3=B6=20bar=20f=C3=B6=C3=B6?=\n'>
                <' =?UTF-8?q?=20bar=20f=C3=B6=C3=B6=20bar=20f=C3=B6=C3=B6=20bar=20f=C3=B6?=\n'>
                <' =?UTF-8?q?=C3=B6=20bar=20f=C3=B6=C3=B6=20bar=20f=C3=B6=C3=B6=20bar=20f?=\n'>
                <' =?UTF-8?q?=C3=B6=C3=B6=20bar=20f=C3=B6=C3=B6=20bar=20f=C3=B6=C3=B6=20bar?=\n'>
                <' =?UTF-8?q?=20f=C3=B6=C3=B6=20bar=20f=C3=B6=C3=B6=20bar=20f=C3=B6=C3=B6=20?=\n'>
                <' =?UTF-8?q?bar?=\n'>
              ]
            )
        )
      ]
      do_fork: T
    )
    (C {<test_expect_success>} {(SQ <'format-patch wraps extremely long subject (rfc2047)'>)} 
      {
        (SQ <'\n'> <'\trm -rf patches/ &&\n'> <'\techo content >>file &&\n'> <'\tgit add file &&\n'> 
          <'\tgit commit -m "$M512" &&\n'> <'\tgit format-patch --stdout -1 >patch &&\n'> 
          <'\tsed -n "/^Subject/p; /^ /p; /^$/q" <patch >subject &&\n'> <'\ttest_cmp expect subject\n'>
        )
      }
    )
    (command.ShFunction
      name: check_author
      body: 
        (BraceGroup
          children: [
            (command.AndOr
              ops: [Id.Op_DAmp Id.Op_DAmp Id.Op_DAmp Id.Op_DAmp Id.Op_DAmp]
              children: [
                (command.Simple
                  words: [{<echo>} {<content>}]
                  redirects: [(redir op:<Id.Redir_DGreat '>>'> loc:(redir_loc.Fd fd:1) arg:{<file>})]
                  do_fork: T
                )
                (C {<git>} {<add>} {<file>})
                (command.Simple
                  words: [{<git>} {<commit>} {<-m>} {<author-check>}]
                  more_env: [
                    (env_pair
                      name: GIT_AUTHOR_NAME
                      val: {($ Id.VSub_Number '$1')}
                      spids: [2098]
                    )
                  ]
                  do_fork: T
                )
                (command.Simple
                  words: [{<git>} {<format-patch>} {<--stdout>} {<-1>}]
                  redirects: [(redir op:<Id.Redir_Great '>'> loc:(redir_loc.Fd fd:1) arg:{<patch>})]
                  do_fork: T
                )
                (command.Simple
                  words: [{<sed>} {<-n>} {(DQ <'/^From: /p; /^ /p; /^'> <Id.Lit_Other '$'> <'/q'>)}]
                  redirects: [
                    (redir
                      op: <Id.Redir_Less '<'>
                      loc: (redir_loc.Fd fd:0)
                      arg: {<patch>}
                    )
                    (redir
                      op: <Id.Redir_Great '>'>
                      loc: (redir_loc.Fd fd:1)
                      arg: {<actual>}
                    )
                  ]
                  do_fork: T
                )
                (C {<test_cmp>} {<expect>} {<actual>})
              ]
            )
          ]
        )
    )
    (command.Simple
      words: [{<cat>}]
      redirects: [
        (redir op:<Id.Redir_Great '>'> loc:(redir_loc.Fd fd:1) arg:{<expect>})
        (redir
          op: <Id.Redir_DLess '<<'>
          loc: (redir_loc.Fd fd:0)
          arg: 
            (redir_param.MultiLine
              here_begin: {(SQ <EOF>)}
              here_end_span_id: 2165
              stdin_parts: [<'From: "Foo B. Bar" <author@example.com>\n'>]
            )
        )
      ]
      do_fork: T
    )
    (C {<test_expect_success>} {(SQ <'format-patch quotes dot in from-headers'>)} 
      {(SQ <'\n'> <'\tcheck_author "Foo B. Bar"\n'>)}
    )
    (command.Simple
      words: [{<cat>}]
      redirects: [
        (redir op:<Id.Redir_Great '>'> loc:(redir_loc.Fd fd:1) arg:{<expect>})
        (redir
          op: <Id.Redir_DLess '<<'>
          loc: (redir_loc.Fd fd:0)
          arg: 
            (redir_param.MultiLine
              here_begin: {(SQ <EOF>)}
              here_end_span_id: 2189
              stdin_parts: [<'From: "Foo \\"The Baz\\" Bar" <author@example.com>\n'>]
            )
        )
      ]
      do_fork: T
    )
    (C {<test_expect_success>} {(SQ <'format-patch quotes double-quote in from-headers'>)} 
      {(SQ <'\n'> <'\tcheck_author "Foo \\"The Baz\\" Bar"\n'>)}
    )
    (command.Simple
      words: [{<cat>}]
      redirects: [
        (redir op:<Id.Redir_Great '>'> loc:(redir_loc.Fd fd:1) arg:{<expect>})
        (redir
          op: <Id.Redir_DLess '<<'>
          loc: (redir_loc.Fd fd:0)
          arg: 
            (redir_param.MultiLine
              here_begin: {(SQ <EOF>)}
              here_end_span_id: 2213
              stdin_parts: [<'From: =?UTF-8?q?F=C3=B6o=20Bar?= <author@example.com>\n'>]
            )
        )
      ]
      do_fork: T
    )
    (C {<test_expect_success>} {(SQ <'format-patch uses rfc2047-encoded from-headers when necessary'>)} 
      {(SQ <'\n'> <'\tcheck_author "Föo Bar"\n'>)}
    )
    (command.Simple
      words: [{<cat>}]
      redirects: [
        (redir op:<Id.Redir_Great '>'> loc:(redir_loc.Fd fd:1) arg:{<expect>})
        (redir
          op: <Id.Redir_DLess '<<'>
          loc: (redir_loc.Fd fd:0)
          arg: 
            (redir_param.MultiLine
              here_begin: {(SQ <EOF>)}
              here_end_span_id: 2237
              stdin_parts: [<'From: =?UTF-8?q?F=C3=B6o=20B=2E=20Bar?= <author@example.com>\n'>]
            )
        )
      ]
      do_fork: T
    )
    (C {<test_expect_success>} {(SQ <'rfc2047-encoded from-headers leave no rfc822 specials'>)} 
      {(SQ <'\n'> <'\tcheck_author "Föo B. Bar"\n'>)}
    )
    (command.Simple
      words: [{<cat>}]
      redirects: [
        (redir op:<Id.Redir_Great '>'> loc:(redir_loc.Fd fd:1) arg:{<expect>})
        (redir
          op: <Id.Redir_DLess '<<'>
          loc: (redir_loc.Fd fd:0)
          arg: 
            (redir_param.MultiLine
              here_begin: {<EOF>}
              here_end_span_id: 2261
              stdin_parts: [
                <'From: foo_bar_foo_bar_foo_bar_foo_bar_foo_bar_foo_bar_foo_bar_foo_bar_\n'>
                <' <author@example.com>\n'>
              ]
            )
        )
      ]
      do_fork: T
    )
    (C {<test_expect_success>} {(SQ <'format-patch wraps moderately long from-header (ascii)'>)} 
      {
        (SQ <'\n'> 
          <'\tcheck_author "foo_bar_foo_bar_foo_bar_foo_bar_foo_bar_foo_bar_foo_bar_foo_bar_"\n'>
        )
      }
    )
    (command.Simple
      words: [{<cat>}]
      redirects: [
        (redir op:<Id.Redir_Great '>'> loc:(redir_loc.Fd fd:1) arg:{<expect>})
        (redir
          op: <Id.Redir_DLess '<<'>
          loc: (redir_loc.Fd fd:0)
          arg: 
            (redir_param.MultiLine
              here_begin: {(SQ <EOF>)}
              here_end_span_id: 2287
              stdin_parts: [
                <'From: Foo Bar Foo Bar Foo Bar Foo Bar Foo Bar Foo Bar Foo Bar Foo Bar Foo Bar\n'>
                <' Foo Bar Foo Bar Foo Bar Foo Bar Foo Bar Foo Bar Foo Bar Foo Bar Foo Bar Foo\n'>
                <' Bar Foo Bar Foo Bar Foo Bar <author@example.com>\n'>
              ]
            )
        )
      ]
      do_fork: T
    )
    (C {<test_expect_success>} {(SQ <'format-patch wraps extremely long from-header (ascii)'>)} 
      {
        (SQ <'\n'> 
          <
'\tcheck_author "Foo Bar Foo Bar Foo Bar Foo Bar Foo Bar Foo Bar Foo Bar Foo Bar Foo Bar Foo Bar Foo Bar Foo Bar Foo Bar Foo Bar Foo Bar Foo Bar Foo Bar Foo Bar Foo Bar Foo Bar Foo Bar Foo Bar"\n'
          >
        )
      }
    )
    (command.Simple
      words: [{<cat>}]
      redirects: [
        (redir op:<Id.Redir_Great '>'> loc:(redir_loc.Fd fd:1) arg:{<expect>})
        (redir
          op: <Id.Redir_DLess '<<'>
          loc: (redir_loc.Fd fd:0)
          arg: 
            (redir_param.MultiLine
              here_begin: {(SQ <EOF>)}
              here_end_span_id: 2313
              stdin_parts: [
                <'From: "Foo.Bar Foo Bar Foo Bar Foo Bar Foo Bar Foo Bar Foo Bar Foo Bar Foo Bar\n'>
                <' Foo Bar Foo Bar Foo Bar Foo Bar Foo Bar Foo Bar Foo Bar Foo Bar Foo Bar Foo\n'>
                <' Bar Foo Bar Foo Bar Foo Bar" <author@example.com>\n'>
              ]
            )
        )
      ]
      do_fork: T
    )
    (C {<test_expect_success>} {(SQ <'format-patch wraps extremely long from-header (rfc822)'>)} 
      {
        (SQ <'\n'> 
          <
'\tcheck_author "Foo.Bar Foo Bar Foo Bar Foo Bar Foo Bar Foo Bar Foo Bar Foo Bar Foo Bar Foo Bar Foo Bar Foo Bar Foo Bar Foo Bar Foo Bar Foo Bar Foo Bar Foo Bar Foo Bar Foo Bar Foo Bar Foo Bar"\n'
          >
        )
      }
    )
    (command.Simple
      words: [{<cat>}]
      redirects: [
        (redir op:<Id.Redir_Great '>'> loc:(redir_loc.Fd fd:1) arg:{<expect>})
        (redir
          op: <Id.Redir_DLess '<<'>
          loc: (redir_loc.Fd fd:0)
          arg: 
            (redir_param.MultiLine
              here_begin: {(SQ <EOF>)}
              here_end_span_id: 2341
              stdin_parts: [
                <'From: =?UTF-8?q?Fo=C3=B6=20Bar=20Foo=20Bar=20Foo=20Bar=20Foo=20Bar=20Foo?=\n'>
                <' =?UTF-8?q?=20Bar=20Foo=20Bar=20Foo=20Bar=20Foo=20Bar=20Foo=20Bar=20Foo=20?=\n'>
                <' =?UTF-8?q?Bar=20Foo=20Bar=20Foo=20Bar=20Foo=20Bar=20Foo=20Bar=20Foo=20Bar?=\n'>
                <' =?UTF-8?q?=20Foo=20Bar=20Foo=20Bar=20Foo=20Bar=20Foo=20Bar=20Foo=20Bar=20?=\n'>
                <' =?UTF-8?q?Foo=20Bar=20Foo=20Bar?= <author@example.com>\n'>
              ]
            )
        )
      ]
      do_fork: T
    )
    (C {<test_expect_success>} {(SQ <'format-patch wraps extremely long from-header (rfc2047)'>)} 
      {
        (SQ <'\n'> 
          <
'\tcheck_author "Foö Bar Foo Bar Foo Bar Foo Bar Foo Bar Foo Bar Foo Bar Foo Bar Foo Bar Foo Bar Foo Bar Foo Bar Foo Bar Foo Bar Foo Bar Foo Bar Foo Bar Foo Bar Foo Bar Foo Bar Foo Bar Foo Bar"\n'
          >
        )
      }
    )
    (command.Simple
      words: [{<cat>}]
      redirects: [
        (redir op:<Id.Redir_Great '>'> loc:(redir_loc.Fd fd:1) arg:{<expect>})
        (redir
          op: <Id.Redir_DLess '<<'>
          loc: (redir_loc.Fd fd:0)
          arg: 
            (redir_param.MultiLine
              here_begin: {(SQ <EOF>)}
              here_end_span_id: 2365
              stdin_parts: [<'Subject: header with . in it\n'>]
            )
        )
      ]
      do_fork: T
    )
    (C {<test_expect_success>} {(SQ <'subject lines do not have 822 atom-quoting'>)} 
      {
        (SQ <'\n'> <'\techo content >>file &&\n'> <'\tgit add file &&\n'> 
          <'\tgit commit -m "header with . in it" &&\n'> <'\tgit format-patch -k -1 --stdout >patch &&\n'> <'\tgrep ^Subject: patch >actual &&\n'> 
          <'\ttest_cmp expect actual\n'>
        )
      }
    )
    (command.Simple
      words: [{<cat>}]
      redirects: [
        (redir op:<Id.Redir_Great '>'> loc:(redir_loc.Fd fd:1) arg:{<expect>})
        (redir
          op: <Id.Redir_DLess '<<'>
          loc: (redir_loc.Fd fd:0)
          arg: 
            (redir_param.MultiLine
              here_begin: {(SQ <EOF>)}
              here_end_span_id: 2394
              stdin_parts: [<'Subject: [PREFIX 1/1] header with . in it\n'>]
            )
        )
      ]
      do_fork: T
    )
    (C {<test_expect_success>} {(SQ <'subject prefixes have space prepended'>)} 
      {
        (SQ <'\n'> <'\tgit format-patch -n -1 --stdout --subject-prefix=PREFIX >patch &&\n'> 
          <'\tgrep ^Subject: patch >actual &&\n'> <'\ttest_cmp expect actual\n'>
        )
      }
    )
    (command.Simple
      words: [{<cat>}]
      redirects: [
        (redir op:<Id.Redir_Great '>'> loc:(redir_loc.Fd fd:1) arg:{<expect>})
        (redir
          op: <Id.Redir_DLess '<<'>
          loc: (redir_loc.Fd fd:0)
          arg: 
            (redir_param.MultiLine
              here_begin: {(SQ <EOF>)}
              here_end_span_id: 2420
              stdin_parts: [<'Subject: [1/1] header with . in it\n'>]
            )
        )
      ]
      do_fork: T
    )
    (C {<test_expect_success>} {(SQ <'empty subject prefix does not have extra space'>)} 
      {
        (SQ <'\n'> <'\tgit format-patch -n -1 --stdout --subject-prefix= >patch &&\n'> 
          <'\tgrep ^Subject: patch >actual &&\n'> <'\ttest_cmp expect actual\n'>
        )
      }
    )
    (C {<test_expect_success>} {(SQ <--rfc>)} 
      {
        (SQ <'\n'> <'\tcat >expect <<-\\EOF &&\n'> <'\tSubject: [RFC PATCH 1/1] header with . in it\n'> 
          <'\tEOF\n'> <'\tgit format-patch -n -1 --stdout --rfc >patch &&\n'> <'\tgrep ^Subject: patch >actual &&\n'> 
          <'\ttest_cmp expect actual\n'>
        )
      }
    )
    (C {<test_expect_success>} {(SQ <'--from=ident notices bogus ident'>)} 
      {(SQ <'\n'> <'\ttest_must_fail git format-patch -1 --stdout --from=foo >patch\n'>)}
    )
    (C {<test_expect_success>} {(SQ <'--from=ident replaces author'>)} 
      {
        (SQ <'\n'> <'\tgit format-patch -1 --stdout --from="Me <me@example.com>" >patch &&\n'> 
          <'\tcat >expect <<-\\EOF &&\n'> <'\tFrom: Me <me@example.com>\n'> <'\n'> <'\tFrom: A U Thor <author@example.com>\n'> <'\n'> <'\tEOF\n'> 
          <'\tsed -ne "/^From:/p; /^$/p; /^---$/q" <patch >patch.head &&\n'> <'\ttest_cmp expect patch.head\n'>
        )
      }
    )
    (C {<test_expect_success>} {(SQ <'--from uses committer ident'>)} 
      {
        (SQ <'\n'> <'\tgit format-patch -1 --stdout --from >patch &&\n'> 
          <'\tcat >expect <<-\\EOF &&\n'> <'\tFrom: C O Mitter <committer@example.com>\n'> <'\n'> <'\tFrom: A U Thor <author@example.com>\n'> 
          <'\n'> <'\tEOF\n'> <'\tsed -ne "/^From:/p; /^$/p; /^---$/q" <patch >patch.head &&\n'> 
          <'\ttest_cmp expect patch.head\n'>
        )
      }
    )
    (C {<test_expect_success>} {(SQ <'--from omits redundant in-body header'>)} 
      {
        (SQ <'\n'> 
          <'\tgit format-patch -1 --stdout --from="A U Thor <author@example.com>" >patch &&\n'> <'\tcat >expect <<-\\EOF &&\n'> <'\tFrom: A U Thor <author@example.com>\n'> <'\n'> <'\tEOF\n'> 
          <'\tsed -ne "/^From:/p; /^$/p; /^---$/q" <patch >patch.head &&\n'> <'\ttest_cmp expect patch.head\n'>
        )
      }
    )
    (C {<test_expect_success>} {(SQ <'in-body headers trigger content encoding'>)} 
      {
        (SQ <'\n'> <'\ttest_env GIT_AUTHOR_NAME="éxötìc" test_commit exotic &&\n'> 
          <'\ttest_when_finished "git reset --hard HEAD^" &&\n'> <'\tgit format-patch -1 --stdout --from >patch &&\n'> <'\tcat >expect <<-\\EOF &&\n'> 
          <'\tFrom: C O Mitter <committer@example.com>\n'> <'\tContent-Type: text/plain; charset=UTF-8\n'> <'\n'> <'\tFrom: éxötìc <author@example.com>\n'> 
          <'\n'> <'\tEOF\n'> <'\tsed -ne "/^From:/p; /^$/p; /^Content-Type/p; /^---$/q" <patch >patch.head &&\n'> 
          <'\ttest_cmp expect patch.head\n'>
        )
      }
    )
    (command.ShFunction
      name: append_signoff
      body: 
        (BraceGroup
          children: [
            (command.AndOr
              ops: [Id.Op_DAmp Id.Op_DAmp]
              children: [
                (command.ShAssignment
                  pairs: [
                    (assign_pair
                      lhs: (sh_lhs_expr.Name name:C)
                      op: assign_op.Equal
                      rhs: 
                        {
                          (command_sub
                            left_token: <Id.Left_DollarParen '$('>
                            child: 
                              (C {<git>} {<commit-tree>} 
                                {<HEAD> <Id.Lit_Other '^'> <Id.Lit_Other '^'> <Id.Lit_LBrace '{'> <tree> 
                                  <Id.Lit_RBrace '}'>
                                } {<-p>} {<HEAD>}
                              )
                          )
                        }
                      spids: [2552]
                    )
                  ]
                )
                (command.Simple
                  words: [
                    {<git>}
                    {<format-patch>}
                    {<--stdout>}
                    {<--signoff>}
                    {($ Id.VSub_DollarName '$C') <Id.Lit_Other '^'> <..> ($ Id.VSub_DollarName '$C')}
                  ]
                  redirects: [
                    (redir
                      op: <Id.Redir_Great '>'>
                      loc: (redir_loc.Fd fd:1)
                      arg: {<append_signoff.patch>}
                    )
                  ]
                  do_fork: T
                )
                (command.Pipeline
                  children: [
                    (C {<sed>} {<-n>} {<-e>} {(DQ <'1,/^---'> <Id.Lit_Other '$'> <'/p'>)} 
                      {<append_signoff.patch>}
                    )
                    (C {<egrep>} {<-n>} {(DQ <'^Subject|Sign|^'> <Id.Lit_Other '$'>)})
                  ]
                  negated: F
                )
              ]
            )
          ]
        )
    )
    (C {<test_expect_success>} {(SQ <'signoff: commit with no body'>)} 
      {
        (SQ <'\n'> <'\tappend_signoff </dev/null >actual &&\n'> 
          <'\tcat <<\\EOF | sed "s/EOL$//" >expected &&\n'> <'4:Subject: [PATCH] EOL\n'> <'8:\n'> <'9:Signed-off-by: C O Mitter <committer@example.com>\n'> 
          <'EOF\n'> <'\ttest_cmp expected actual\n'>
        )
      }
    )
    (C {<test_expect_success>} {(SQ <'signoff: commit with only subject'>)} 
      {
        (SQ <'\n'> <'\techo subject | append_signoff >actual &&\n'> <'\tcat >expected <<\\EOF &&\n'> 
          <'4:Subject: [PATCH] subject\n'> <'8:\n'> <'9:Signed-off-by: C O Mitter <committer@example.com>\n'> <'EOF\n'> 
          <'\ttest_cmp expected actual\n'>
        )
      }
    )
    (C {<test_expect_success>} {(SQ <'signoff: commit with only subject that does not end with NL'>)} 
      {
        (SQ <'\n'> <'\tprintf subject | append_signoff >actual &&\n'> <'\tcat >expected <<\\EOF &&\n'> 
          <'4:Subject: [PATCH] subject\n'> <'8:\n'> <'9:Signed-off-by: C O Mitter <committer@example.com>\n'> <'EOF\n'> 
          <'\ttest_cmp expected actual\n'>
        )
      }
    )
    (C {<test_expect_success>} {(SQ <'signoff: no existing signoffs'>)} 
      {
        (SQ <'\n'> <'\tappend_signoff <<\\EOF >actual &&\n'> <'subject\n'> <'\n'> <'body\n'> <'EOF\n'> 
          <'\tcat >expected <<\\EOF &&\n'> <'4:Subject: [PATCH] subject\n'> <'8:\n'> <'10:\n'> 
          <'11:Signed-off-by: C O Mitter <committer@example.com>\n'> <'EOF\n'> <'\ttest_cmp expected actual\n'>
        )
      }
    )
    (C {<test_expect_success>} {(SQ <'signoff: no existing signoffs and no trailing NL'>)} 
      {
        (SQ <'\n'> <'\tprintf "subject\\n\\nbody" | append_signoff >actual &&\n'> 
          <'\tcat >expected <<\\EOF &&\n'> <'4:Subject: [PATCH] subject\n'> <'8:\n'> <'10:\n'> 
          <'11:Signed-off-by: C O Mitter <committer@example.com>\n'> <'EOF\n'> <'\ttest_cmp expected actual\n'>
        )
      }
    )
    (C {<test_expect_success>} {(SQ <'signoff: some random signoff'>)} 
      {
        (SQ <'\n'> <'\tappend_signoff <<\\EOF >actual &&\n'> <'subject\n'> <'\n'> <'body\n'> <'\n'> 
          <'Signed-off-by: my@house\n'> <'EOF\n'> <'\tcat >expected <<\\EOF &&\n'> <'4:Subject: [PATCH] subject\n'> <'8:\n'> <'10:\n'> 
          <'11:Signed-off-by: my@house\n'> <'12:Signed-off-by: C O Mitter <committer@example.com>\n'> <'EOF\n'> <'\ttest_cmp expected actual\n'>
        )
      }
    )
    (C {<test_expect_success>} {(SQ <'signoff: misc conforming footer elements'>)} 
      {
        (SQ <'\n'> <'\tappend_signoff <<\\EOF >actual &&\n'> <'subject\n'> <'\n'> <'body\n'> <'\n'> 
          <'Signed-off-by: my@house\n'> <'(cherry picked from commit da39a3ee5e6b4b0d3255bfef95601890afd80709)\n'> 
          <'Tested-by: Some One <someone@example.com>\n'> <'Bug: 1234\n'> <'EOF\n'> <'\tcat >expected <<\\EOF &&\n'> <'4:Subject: [PATCH] subject\n'> <'8:\n'> 
          <'10:\n'> <'11:Signed-off-by: my@house\n'> <'15:Signed-off-by: C O Mitter <committer@example.com>\n'> <'EOF\n'> 
          <'\ttest_cmp expected actual\n'>
        )
      }
    )
    (C {<test_expect_success>} {(SQ <'signoff: some random signoff-alike'>)} 
      {
        (SQ <'\n'> <'\tappend_signoff <<\\EOF >actual &&\n'> <'subject\n'> <'\n'> <'body\n'> 
          <'Fooled-by-me: my@house\n'> <'EOF\n'> <'\tcat >expected <<\\EOF &&\n'> <'4:Subject: [PATCH] subject\n'> <'8:\n'> <'11:\n'> 
          <'12:Signed-off-by: C O Mitter <committer@example.com>\n'> <'EOF\n'> <'\ttest_cmp expected actual\n'>
        )
      }
    )
    (C {<test_expect_success>} {(SQ <'signoff: not really a signoff'>)} 
      {
        (SQ <'\n'> <'\tappend_signoff <<\\EOF >actual &&\n'> <'subject\n'> <'\n'> 
          <'I want to mention about Signed-off-by: here.\n'> <'EOF\n'> <'\tcat >expected <<\\EOF &&\n'> <'4:Subject: [PATCH] subject\n'> <'8:\n'> 
          <'9:I want to mention about Signed-off-by: here.\n'> <'10:\n'> <'11:Signed-off-by: C O Mitter <committer@example.com>\n'> <'EOF\n'> 
          <'\ttest_cmp expected actual\n'>
        )
      }
    )
    (C {<test_expect_success>} {(SQ <'signoff: not really a signoff (2)'>)} 
      {
        (SQ <'\n'> <'\tappend_signoff <<\\EOF >actual &&\n'> <'subject\n'> <'\n'> <'My unfortunate\n'> 
          <'Signed-off-by: example happens to be wrapped here.\n'> <'EOF\n'> <'\tcat >expected <<\\EOF &&\n'> <'4:Subject: [PATCH] subject\n'> <'8:\n'> 
          <'10:Signed-off-by: example happens to be wrapped here.\n'> <'11:\n'> <'12:Signed-off-by: C O Mitter <committer@example.com>\n'> <'EOF\n'> 
          <'\ttest_cmp expected actual\n'>
        )
      }
    )
    (C {<test_expect_success>} {(SQ <'signoff: valid S-o-b paragraph in the middle'>)} 
      {
        (SQ <'\n'> <'\tappend_signoff <<\\EOF >actual &&\n'> <'subject\n'> <'\n'> 
          <'Signed-off-by: my@house\n'> <'Signed-off-by: your@house\n'> <'\n'> <'A lot of houses.\n'> <'EOF\n'> <'\tcat >expected <<\\EOF &&\n'> 
          <'4:Subject: [PATCH] subject\n'> <'8:\n'> <'9:Signed-off-by: my@house\n'> <'10:Signed-off-by: your@house\n'> <'11:\n'> <'13:\n'> 
          <'14:Signed-off-by: C O Mitter <committer@example.com>\n'> <'EOF\n'> <'\ttest_cmp expected actual\n'>
        )
      }
    )
    (C {<test_expect_success>} {(SQ <'signoff: the same signoff at the end'>)} 
      {
        (SQ <'\n'> <'\tappend_signoff <<\\EOF >actual &&\n'> <'subject\n'> <'\n'> <'body\n'> <'\n'> 
          <'Signed-off-by: C O Mitter <committer@example.com>\n'> <'EOF\n'> <'\tcat >expected <<\\EOF &&\n'> <'4:Subject: [PATCH] subject\n'> <'8:\n'> <'10:\n'> 
          <'11:Signed-off-by: C O Mitter <committer@example.com>\n'> <'EOF\n'> <'\ttest_cmp expected actual\n'>
        )
      }
    )
    (C {<test_expect_success>} {(SQ <'signoff: the same signoff at the end, no trailing NL'>)} 
      {
        (SQ <'\n'> <'\tprintf "subject\\n\\nSigned-off-by: C O Mitter <committer@example.com>" |\n'> 
          <'\t\tappend_signoff >actual &&\n'> <'\tcat >expected <<\\EOF &&\n'> <'4:Subject: [PATCH] subject\n'> <'8:\n'> 
          <'9:Signed-off-by: C O Mitter <committer@example.com>\n'> <'EOF\n'> <'\ttest_cmp expected actual\n'>
        )
      }
    )
    (C {<test_expect_success>} {(SQ <'signoff: the same signoff NOT at the end'>)} 
      {
        (SQ <'\n'> <'\tappend_signoff <<\\EOF >actual &&\n'> <'subject\n'> <'\n'> <'body\n'> <'\n'> 
          <'Signed-off-by: C O Mitter <committer@example.com>\n'> <'Signed-off-by: my@house\n'> <'EOF\n'> <'\tcat >expected <<\\EOF &&\n'> 
          <'4:Subject: [PATCH] subject\n'> <'8:\n'> <'10:\n'> <'11:Signed-off-by: C O Mitter <committer@example.com>\n'> 
          <'12:Signed-off-by: my@house\n'> <'EOF\n'> <'\ttest_cmp expected actual\n'>
        )
      }
    )
    (C {<test_expect_success>} {(SQ <'signoff: detect garbage in non-conforming footer'>)} 
      {
        (SQ <'\n'> <'\tappend_signoff <<\\EOF >actual &&\n'> <'subject\n'> <'\n'> <'body\n'> <'\n'> 
          <'Tested-by: my@house\n'> <'Some Trash\n'> <'Signed-off-by: C O Mitter <committer@example.com>\n'> <'EOF\n'> 
          <'\tcat >expected <<\\EOF &&\n'> <'4:Subject: [PATCH] subject\n'> <'8:\n'> <'10:\n'> 
          <'13:Signed-off-by: C O Mitter <committer@example.com>\n'> <'14:\n'> <'15:Signed-off-by: C O Mitter <committer@example.com>\n'> <'EOF\n'> 
          <'\ttest_cmp expected actual\n'>
        )
      }
    )
    (C {<test_expect_success>} {(SQ <'signoff: footer begins with non-signoff without @ sign'>)} 
      {
        (SQ <'\n'> <'\tappend_signoff <<\\EOF >actual &&\n'> <'subject\n'> <'\n'> <'body\n'> <'\n'> 
          <'Reviewed-id: Noone\n'> <'Tested-by: my@house\n'> <'Change-id: Ideadbeef\n'> 
          <'Signed-off-by: C O Mitter <committer@example.com>\n'> <'Bug: 1234\n'> <'EOF\n'> <'\tcat >expected <<\\EOF &&\n'> <'4:Subject: [PATCH] subject\n'> <'8:\n'> 
          <'10:\n'> <'14:Signed-off-by: C O Mitter <committer@example.com>\n'> <'EOF\n'> <'\ttest_cmp expected actual\n'>
        )
      }
    )
    (C {<test_expect_success>} {(SQ <'format patch ignores color.ui'>)} 
      {
        (SQ <'\n'> <'\ttest_unconfig color.ui &&\n'> <'\tgit format-patch --stdout -1 >expect &&\n'> 
          <'\ttest_config color.ui always &&\n'> <'\tgit format-patch --stdout -1 >actual &&\n'> <'\ttest_cmp expect actual\n'>
        )
      }
    )
    (C {<test_expect_success>} {(SQ <'cover letter using branch description (1)'>)} 
      {
        (SQ <'\n'> <'\tgit checkout rebuild-1 &&\n'> 
          <'\ttest_config branch.rebuild-1.description hello &&\n'> <'\tgit format-patch --stdout --cover-letter master >actual &&\n'> 
          <'\tgrep hello actual >/dev/null\n'>
        )
      }
    )
    (C {<test_expect_success>} {(SQ <'cover letter using branch description (2)'>)} 
      {
        (SQ <'\n'> <'\tgit checkout rebuild-1 &&\n'> 
          <'\ttest_config branch.rebuild-1.description hello &&\n'> <'\tgit format-patch --stdout --cover-letter rebuild-1~2..rebuild-1 >actual &&\n'> 
          <'\tgrep hello actual >/dev/null\n'>
        )
      }
    )
    (C {<test_expect_success>} {(SQ <'cover letter using branch description (3)'>)} 
      {
        (SQ <'\n'> <'\tgit checkout rebuild-1 &&\n'> 
          <'\ttest_config branch.rebuild-1.description hello &&\n'> <'\tgit format-patch --stdout --cover-letter ^master rebuild-1 >actual &&\n'> 
          <'\tgrep hello actual >/dev/null\n'>
        )
      }
    )
    (C {<test_expect_success>} {(SQ <'cover letter using branch description (4)'>)} 
      {
        (SQ <'\n'> <'\tgit checkout rebuild-1 &&\n'> 
          <'\ttest_config branch.rebuild-1.description hello &&\n'> <'\tgit format-patch --stdout --cover-letter master.. >actual &&\n'> 
          <'\tgrep hello actual >/dev/null\n'>
        )
      }
    )
    (C {<test_expect_success>} {(SQ <'cover letter using branch description (5)'>)} 
      {
        (SQ <'\n'> <'\tgit checkout rebuild-1 &&\n'> 
          <'\ttest_config branch.rebuild-1.description hello &&\n'> <'\tgit format-patch --stdout --cover-letter -2 HEAD >actual &&\n'> 
          <'\tgrep hello actual >/dev/null\n'>
        )
      }
    )
    (C {<test_expect_success>} {(SQ <'cover letter using branch description (6)'>)} 
      {
        (SQ <'\n'> <'\tgit checkout rebuild-1 &&\n'> 
          <'\ttest_config branch.rebuild-1.description hello &&\n'> <'\tgit format-patch --stdout --cover-letter -2 >actual &&\n'> <'\tgrep hello actual >/dev/null\n'>
        )
      }
    )
    (C {<test_expect_success>} {(SQ <'cover letter with nothing'>)} 
      {
        (SQ <'\n'> <'\tgit format-patch --stdout --cover-letter >actual &&\n'> 
          <'\ttest_line_count = 0 actual\n'>
        )
      }
    )
    (C {<test_expect_success>} {(SQ <'cover letter auto'>)} 
      {
        (SQ <'\n'> <'\tmkdir -p tmp &&\n'> <'\ttest_when_finished "rm -rf tmp;\n'> 
          <'\t\tgit config --unset format.coverletter" &&\n'> <'\n'> <'\tgit config format.coverletter auto &&\n'> <'\tgit format-patch -o tmp -1 >list &&\n'> 
          <'\ttest_line_count = 1 list &&\n'> <'\tgit format-patch -o tmp -2 >list &&\n'> <'\ttest_line_count = 3 list\n'>
        )
      }
    )
    (C {<test_expect_success>} {(SQ <'cover letter auto user override'>)} 
      {
        (SQ <'\n'> <'\tmkdir -p tmp &&\n'> <'\ttest_when_finished "rm -rf tmp;\n'> 
          <'\t\tgit config --unset format.coverletter" &&\n'> <'\n'> <'\tgit config format.coverletter auto &&\n'> 
          <'\tgit format-patch -o tmp --cover-letter -1 >list &&\n'> <'\ttest_line_count = 2 list &&\n'> <'\tgit format-patch -o tmp --cover-letter -2 >list &&\n'> 
          <'\ttest_line_count = 3 list &&\n'> <'\tgit format-patch -o tmp --no-cover-letter -1 >list &&\n'> <'\ttest_line_count = 1 list &&\n'> 
          <'\tgit format-patch -o tmp --no-cover-letter -2 >list &&\n'> <'\ttest_line_count = 2 list\n'>
        )
      }
    )
    (C {<test_expect_success>} {(SQ <'format-patch --zero-commit'>)} 
      {
        (SQ <'\n'> <'\tgit format-patch --zero-commit --stdout v2..v1 >patch2 &&\n'> 
          <'\tgrep "^From " patch2 | sort | uniq >actual &&\n'> <'\techo "From $_z40 Mon Sep 17 00:00:00 2001" >expect &&\n'> <'\ttest_cmp expect actual\n'>
        )
      }
    )
    (C {<test_expect_success>} {(SQ <'From line has expected format'>)} 
      {
        (SQ <'\n'> <'\tgit format-patch --stdout v2..v1 >patch2 &&\n'> 
          <'\tgrep "^From " patch2 >from &&\n'> <'\tgrep "^From $_x40 Mon Sep 17 00:00:00 2001$" patch2 >filtered &&\n'> 
          <'\ttest_cmp from filtered\n'>
        )
      }
    )
    (C {<test_expect_success>} {(SQ <'format-patch format.outputDirectory option'>)} 
      {
        (SQ <'\n'> <'\ttest_config format.outputDirectory patches &&\n'> <'\trm -fr patches &&\n'> 
          <'\tgit format-patch master..side &&\n'> <'\ttest $(git rev-list master..side | wc -l) -eq $(ls patches | wc -l)\n'>
        )
      }
    )
    (C {<test_expect_success>} {(SQ <'format-patch -o overrides format.outputDirectory'>)} 
      {
        (SQ <'\n'> <'\ttest_config format.outputDirectory patches &&\n'> 
          <'\trm -fr patches patchset &&\n'> <'\tgit format-patch master..side -o patchset &&\n'> <'\ttest_path_is_missing patches &&\n'> 
          <'\ttest_path_is_dir patchset\n'>
        )
      }
    )
    (C {<test_expect_success>} {(SQ <'format-patch --base'>)} 
      {
        (SQ <'\n'> <'\tgit checkout side &&\n'> 
          <'\tgit format-patch --stdout --base=HEAD~3 -1 | tail -n 7 >actual &&\n'> <'\techo >expected &&\n'> <'\techo "base-commit: $(git rev-parse HEAD~3)" >>expected &&\n'> 
          <
'\techo "prerequisite-patch-id: $(git show --patch HEAD~2 | git patch-id --stable | awk "{print \\$1}")" >>expected &&\n'
          > 
          <
'\techo "prerequisite-patch-id: $(git show --patch HEAD~1 | git patch-id --stable | awk "{print \\$1}")" >>expected &&\n'
          > <'\tsignature >> expected &&\n'> <'\ttest_cmp expected actual\n'>
        )
      }
    )
    (C {<test_expect_success>} 
      {(SQ <'format-patch --base errors out when base commit is in revision list'>)} 
      {
        (SQ <'\n'> <'\ttest_must_fail git format-patch --base=HEAD -2 &&\n'> 
          <'\ttest_must_fail git format-patch --base=HEAD~1 -2 &&\n'> <'\tgit format-patch --stdout --base=HEAD~2 -2 >patch &&\n'> 
          <'\tgrep "^base-commit:" patch >actual &&\n'> <'\techo "base-commit: $(git rev-parse HEAD~2)" >expected &&\n'> <'\ttest_cmp expected actual\n'>
        )
      }
    )
    (C {<test_expect_success>} 
      {(SQ <'format-patch --base errors out when base commit is not ancestor of revision list'>)} 
      {
        (SQ <'\n'> <'\t# For history as below:\n'> <'\t#\n'> <'\t#    ---Q---P---Z---Y---*---X\n'> 
          <'\t#\t \\             /\n'> <'\t#\t  ------------W\n'> <'\t#\n'> 
          <'\t# If "format-patch Z..X" is given, P and Z can not be specified as the base commit\n'> <'\tgit checkout -b topic1 master &&\n'> <'\tgit rev-parse HEAD >commit-id-base &&\n'> 
          <'\ttest_commit P &&\n'> <'\tgit rev-parse HEAD >commit-id-P &&\n'> <'\ttest_commit Z &&\n'> 
          <'\tgit rev-parse HEAD >commit-id-Z &&\n'> <'\ttest_commit Y &&\n'> <'\tgit checkout -b topic2 master &&\n'> <'\ttest_commit W &&\n'> 
          <'\tgit merge topic1 &&\n'> <'\ttest_commit X &&\n'> <'\ttest_must_fail git format-patch --base=$(cat commit-id-P) -3 &&\n'> 
          <'\ttest_must_fail git format-patch --base=$(cat commit-id-Z) -3 &&\n'> <'\tgit format-patch --stdout --base=$(cat commit-id-base) -3 >patch &&\n'> 
          <'\tgrep "^base-commit:" patch >actual &&\n'> <'\techo "base-commit: $(cat commit-id-base)" >expected &&\n'> <'\ttest_cmp expected actual\n'>
        )
      }
    )
    (C {<test_expect_success>} {(SQ <'format-patch --base=auto'>)} 
      {
        (SQ <'\n'> <'\tgit checkout -b upstream master &&\n'> <'\tgit checkout -b local upstream &&\n'> 
          <'\tgit branch --set-upstream-to=upstream &&\n'> <'\ttest_commit N1 &&\n'> <'\ttest_commit N2 &&\n'> 
          <'\tgit format-patch --stdout --base=auto -2 >patch &&\n'> <'\tgrep "^base-commit:" patch >actual &&\n'> 
          <'\techo "base-commit: $(git rev-parse upstream)" >expected &&\n'> <'\ttest_cmp expected actual\n'>
        )
      }
    )
    (C {<test_expect_success>} {(SQ <'format-patch errors out when history involves criss-cross'>)} 
      {
        (SQ <'\n'> <'\t# setup criss-cross history\n'> <'\t#\n'> <'\t#   B---M1---D\n'> <'\t#  / \\ /\n'> 
          <'\t# A   X\n'> <'\t#  \\ / \\\n'> <'\t#   C---M2---E\n'> <'\t#\n'> <'\tgit checkout master &&\n'> 
          <'\ttest_commit A &&\n'> <'\tgit checkout -b xb master &&\n'> <'\ttest_commit B &&\n'> <'\tgit checkout -b xc master &&\n'> 
          <'\ttest_commit C &&\n'> <'\tgit checkout -b xbc xb -- &&\n'> <'\tgit merge xc &&\n'> <'\tgit checkout -b xcb xc -- &&\n'> 
          <'\tgit branch --set-upstream-to=xbc &&\n'> <'\tgit merge xb &&\n'> <'\tgit checkout xbc &&\n'> <'\ttest_commit D &&\n'> <'\tgit checkout xcb &&\n'> 
          <'\ttest_commit E &&\n'> <'\ttest_must_fail \tgit format-patch --base=auto -1\n'>
        )
      }
    )
    (C {<test_expect_success>} {(SQ <'format-patch format.useAutoBaseoption'>)} 
      {
        (SQ <'\n'> <'\ttest_when_finished "git config --unset format.useAutoBase" &&\n'> 
          <'\tgit checkout local &&\n'> <'\tgit config format.useAutoBase true &&\n'> <'\tgit format-patch --stdout -1 >patch &&\n'> 
          <'\tgrep "^base-commit:" patch >actual &&\n'> <'\techo "base-commit: $(git rev-parse upstream)" >expected &&\n'> <'\ttest_cmp expected actual\n'>
        )
      }
    )
    (C {<test_expect_success>} {(SQ <'format-patch --base overrides format.useAutoBase'>)} 
      {
        (SQ <'\n'> <'\ttest_when_finished "git config --unset format.useAutoBase" &&\n'> 
          <'\tgit config format.useAutoBase true &&\n'> <'\tgit format-patch --stdout --base=HEAD~1 -1 >patch &&\n'> 
          <'\tgrep "^base-commit:" patch >actual &&\n'> <'\techo "base-commit: $(git rev-parse HEAD~1)" >expected &&\n'> <'\ttest_cmp expected actual\n'>
        )
      }
    )
    (C {<test_expect_success>} {(SQ <'format-patch --base with --attach'>)} 
      {
        (SQ <'\n'> <'\tgit format-patch --attach=mimemime --stdout --base=HEAD~ -1 >patch &&\n'> 
          <'\tsed -n -e "/^base-commit:/s/.*/1/p" -e "/^---*mimemime--$/s/.*/2/p" \\\n'> <'\t\tpatch >actual &&\n'> <'\ttest_write_lines 1 2 >expect &&\n'> <'\ttest_cmp expect actual\n'>
        )
      }
    )
    (C {<test_expect_success>} {(SQ <'format-patch --pretty=mboxrd'>)} 
      {
        (SQ <'\n'> <'\tsp=" " &&\n'> <'\tcat >msg <<-INPUT_END &&\n'> 
          <'\tmboxrd should escape the body\n'> <'\n'> <'\tFrom could trip up a loose mbox parser\n'> <'\t>From extra escape for reversibility\n'> 
          <'\t>>From extra escape for reversibility 2\n'> <'\tfrom lower case not escaped\n'> <'\tFromm bad speling not escaped\n'> 
          <'\t From with leading space not escaped\n'> <'\n'> <'\tF\n'> <'\tFrom\n'> <'\tFrom$sp\n'> <'\tFrom    $sp\n'> <'\tFrom\t$sp\n'> <'\tINPUT_END\n'> <'\n'> 
          <'\tcat >expect <<-INPUT_END &&\n'> <'\t>From could trip up a loose mbox parser\n'> <'\t>>From extra escape for reversibility\n'> 
          <'\t>>>From extra escape for reversibility 2\n'> <'\tfrom lower case not escaped\n'> <'\tFromm bad speling not escaped\n'> 
          <'\t From with leading space not escaped\n'> <'\n'> <'\tF\n'> <'\tFrom\n'> <'\tFrom\n'> <'\tFrom\n'> <'\tFrom\n'> <'\tINPUT_END\n'> <'\n'> 
          <'\tC=$(git commit-tree HEAD^^{tree} -p HEAD <msg) &&\n'> <'\tgit format-patch --pretty=mboxrd --stdout -1 $C~1..$C >patch &&\n'> 
          <'\tgit grep -h --no-index -A11 \\\n'> <'\t\t"^>From could trip up a loose mbox parser" patch >actual &&\n'> <'\ttest_cmp expect actual\n'>
        )
      }
    )
    (C {<test_done>})
  ]
)