(command.CommandList
  children: [
    (command.ShAssignment
      pairs: [
        (assign_pair
          lhs: (sh_lhs_expr.Name name:test_description)
          op: assign_op.Equal
          rhs: {(SQ <'git-apply --ignore-whitespace.\n'> <'\n'>)}
          spids: [13]
        )
      ]
    )
    (C {<.>} {<'./test-lib.sh'>})
    (command.Simple
      words: [{<cat>}]
      redirects: [
        (redir op:<Id.Redir_Great '>'> loc:(redir_loc.Fd fd:1) arg:{<patch1.patch>})
        (redir
          op: <Id.Redir_DLess '<<'>
          loc: (redir_loc.Fd fd:0)
          arg: 
            (redir_param.HereDoc
              here_begin: {(word_part.EscapedLiteral token:<Id.Lit_EscapedChar '\\E'>) <OF>}
              here_end_span_id: 68
              stdin_parts: [
                <'diff --git a/main.c b/main.c\n'>
                <'new file mode 100644\n'>
                <'--- /dev/null\n'>
                <'+++ b/main.c\n'>
                <'@@ -0,0 +1,22 @@\n'>
                <'+#include <stdio.h>\n'>
                <'+\n'>
                <'+void print_int(int num);\n'>
                <'+int func(int num);\n'>
                <'+\n'>
                <'+int main() {\n'>
                <'+       int i;\n'>
                <'+\n'>
                <'+       for (i = 0; i < 10; i++) {\n'>
                <'+               print_int(func(i)); /* stuff */\n'>
                <'+       }\n'>
                <'+\n'>
                <'+       return 0;\n'>
                <'+}\n'>
                <'+\n'>
                <'+int func(int num) {\n'>
                <'+       return num * num;\n'>
                <'+}\n'>
                <'+\n'>
                <'+void print_int(int num) {\n'>
                <'+       printf("%d", num);\n'>
                <'+}\n'>
              ]
            )
        )
      ]
      do_fork: T
    )
    (command.Simple
      words: [{<sed>} {<-e>} {(SQ <'s/Z/ /g'>)}]
      redirects: [
        (redir op:<Id.Redir_Great '>'> loc:(redir_loc.Fd fd:1) arg:{<patch2.patch>})
        (redir
          op: <Id.Redir_DLess '<<'>
          loc: (redir_loc.Fd fd:0)
          arg: 
            (redir_param.HereDoc
              here_begin: {(word_part.EscapedLiteral token:<Id.Lit_EscapedChar '\\E'>) <OF>}
              here_end_span_id: 115
              stdin_parts: [
                <'diff --git a/main.c b/main.c\n'>
                <'--- a/main.c\n'>
                <'+++ b/main.c\n'>
                <'@@ -10,6 +10,8 @@\n'>
                <'Z\t\tprint_int(func(i)); /* stuff */\n'>
                <'Z\t}\n'>
                <'Z\n'>
                <'+\tprintf("\\n");\n'>
                <'+\n'>
                <'Z\treturn 0;\n'>
                <'Z}\n'>
                <'Z\n'>
              ]
            )
        )
      ]
      do_fork: T
    )
    (command.Simple
      words: [{<sed>} {<-e>} {(SQ <'s/Z/ /g'>)}]
      redirects: [
        (redir op:<Id.Redir_Great '>'> loc:(redir_loc.Fd fd:1) arg:{<patch3.patch>})
        (redir
          op: <Id.Redir_DLess '<<'>
          loc: (redir_loc.Fd fd:0)
          arg: 
            (redir_param.HereDoc
              here_begin: {(word_part.EscapedLiteral token:<Id.Lit_EscapedChar '\\E'>) <OF>}
              here_end_span_id: 154
              stdin_parts: [
                <'diff --git a/main.c b/main.c\n'>
                <'--- a/main.c\n'>
                <'+++ b/main.c\n'>
                <'@@ -10,3 +10,4 @@\n'>
                <'Z\tfor (i = 0; i < 10; i++) {\n'>
                <'Z\t\tprint_int(func(i));Z\n'>
                <'+\t\t/* stuff */\n'>
                <'Z\t}\n'>
              ]
            )
        )
      ]
      do_fork: T
    )
    (command.Simple
      words: [{<sed>} {<-e>} {(SQ <'s/Z/ /g'>)}]
      redirects: [
        (redir op:<Id.Redir_Great '>'> loc:(redir_loc.Fd fd:1) arg:{<patch4.patch>})
        (redir
          op: <Id.Redir_DLess '<<'>
          loc: (redir_loc.Fd fd:0)
          arg: 
            (redir_param.HereDoc
              here_begin: {(word_part.EscapedLiteral token:<Id.Lit_EscapedChar '\\E'>) <OF>}
              here_end_span_id: 186
              stdin_parts: [
                <'diff --git a/main.c b/main.c\n'>
                <'--- a/main.c\n'>
                <'+++ b/main.c\n'>
                <'@@ -21,1 +21,1 @@\n'>
                <'-\t};Z\n'>
                <'\\ No newline at end of file\n'>
                <'+\t};\n'>
              ]
            )
        )
      ]
      do_fork: T
    )
    (command.Simple
      words: [{<sed>} {<-e>} {(SQ <'s/Z/ /g'>)}]
      redirects: [
        (redir op:<Id.Redir_Great '>'> loc:(redir_loc.Fd fd:1) arg:{<patch5.patch>})
        (redir
          op: <Id.Redir_DLess '<<'>
          loc: (redir_loc.Fd fd:0)
          arg: 
            (redir_param.HereDoc
              here_begin: {(word_part.EscapedLiteral token:<Id.Lit_EscapedChar '\\E'>) <OF>}
              here_end_span_id: 215
              stdin_parts: [
                <'diff --git a/main.c b/main.c\n'>
                <'--- a/main.c\n'>
                <'+++ b/main.c\n'>
                <'@@ -2,2 +2,3 @@\n'>
                <'Z\tvoid print_int(int num);\n'>
                <'+\t/* a comment */\n'>
                <'Z\tint func(int num);\n'>
              ]
            )
        )
      ]
      do_fork: T
    )
    (command.Simple
      words: [{<sed>} {<-e>} {(SQ <'s/T/\t/g'>)}]
      redirects: [
        (redir op:<Id.Redir_Great '>'> loc:(redir_loc.Fd fd:1) arg:{<main.c.final>})
        (redir
          op: <Id.Redir_DLess '<<'>
          loc: (redir_loc.Fd fd:0)
          arg: 
            (redir_param.HereDoc
              here_begin: {(word_part.EscapedLiteral token:<Id.Lit_EscapedChar '\\E'>) <OF>}
              here_end_span_id: 264
              stdin_parts: [
                <'#include <stdio.h>\n'>
                <'\n'>
                <'void print_int(int num);\n'>
                <'int func(int num);\n'>
                <'\n'>
                <'int main() {\n'>
                <'       int i;\n'>
                <'\n'>
                <'       for (i = 0; i < 10; i++) {\n'>
                <'               print_int(func(i)); /* stuff */\n'>
                <'       }\n'>
                <'\n'>
                <'Tprintf("\\n");\n'>
                <'\n'>
                <'       return 0;\n'>
                <'}\n'>
                <'\n'>
                <'int func(int num) {\n'>
                <'       return num * num;\n'>
                <'}\n'>
                <'\n'>
                <'void print_int(int num) {\n'>
                <'       printf("%d", num);\n'>
                <'}\n'>
              ]
            )
        )
      ]
      do_fork: T
    )
    (C {<test_expect_success>} {(SQ <'file creation'>)} {(SQ <'\n'> <'\tgit apply patch1.patch\n'>)})
    (C {<test_expect_success>} {(SQ <'patch2 fails (retab)'>)} 
      {(SQ <'\n'> <'\ttest_must_fail git apply patch2.patch\n'>)}
    )
    (C {<test_expect_success>} {(SQ <'patch2 applies with --ignore-whitespace'>)} 
      {(SQ <'\n'> <'\tgit apply --ignore-whitespace patch2.patch\n'>)}
    )
    (C {<test_expect_success>} {(SQ <'patch2 reverse applies with --ignore-space-change'>)} 
      {(SQ <'\n'> <'\tgit apply -R --ignore-space-change patch2.patch\n'>)}
    )
    (C {<git>} {<config>} {<apply.ignorewhitespace>} {<change>})
    (C {<test_expect_success>} {(SQ <'patch2 applies (apply.ignorewhitespace = change)'>)} 
      {(SQ <'\n'> <'\tgit apply patch2.patch &&\n'> <'\ttest_cmp main.c.final main.c\n'>)}
    )
    (C {<test_expect_success>} {(SQ <'patch3 fails (missing string at EOL)'>)} 
      {(SQ <'\n'> <'\ttest_must_fail git apply patch3.patch\n'>)}
    )
    (C {<test_expect_success>} {(SQ <'patch4 fails (missing EOL at EOF)'>)} 
      {(SQ <'\n'> <'\ttest_must_fail git apply patch4.patch\n'>)}
    )
    (C {<test_expect_success>} {(SQ <'patch5 fails (leading whitespace differences matter)'>)} 
      {(SQ <'\n'> <'\ttest_must_fail git apply patch5.patch\n'>)}
    )
    (C {<test_expect_success>} {(SQ <'re-create file (with --ignore-whitespace)'>)} 
      {(SQ <'\n'> <'\trm -f main.c &&\n'> <'\tgit apply patch1.patch\n'>)}
    )
    (C {<test_expect_success>} {(SQ <'patch5 fails (--no-ignore-whitespace)'>)} 
      {(SQ <'\n'> <'\ttest_must_fail git apply --no-ignore-whitespace patch5.patch\n'>)}
    )
    (C {<test_done>})
  ]
)