(command.CommandList
  children: [
    (command.Assignment
      keyword: Assign_None
      pairs: [
        (assign_pair
          lhs: (lhs_expr.LhsName name:test_description)
          op: Equal
          rhs: {(SQ <'diff whitespace error detection'>)}
        )
      ]
    )
    (C {(.)} {(./test-lib.sh)})
    (C {(test_expect_success)} {(setup)} 
      {
        (SQ <'\n'> <'\n'> <'\tgit config diff.color.whitespace "blue reverse" &&\n'> <'\t>F &&\n'> 
          <'\tgit add F &&\n'> <'\techo "         Eight SP indent" >>F &&\n'> <'\techo " \tHT and SP indent" >>F &&\n'> 
          <'\techo "With trailing SP " >>F &&\n'> <'\techo "Carriage ReturnQ" | tr Q "\\015" >>F &&\n'> <'\techo "No problem" >>F &&\n'> <'\techo >>F\n'> 
          <'\n'>
        )
      }
    )
    (command.Sentence
      child: 
        (command.Assignment
          keyword: Assign_None
          pairs: [(assign_pair lhs:(lhs_expr.LhsName name:blue_grep) op:Equal rhs:{(SQ <'7;34m'>)})]
        )
      terminator: <Op_Semi ';'>
    )
    (command.SimpleCommand
      words: [{(printf)} {(DQ (Lit_Other '\\') ('033[%s'))} {(DQ ($ VSub_DollarName '$blue_grep'))}]
      redirects: [(redir.Redir op:<Redir_Great '>'> fd:16777215 arg_word:{(check-grep)})]
    )
    (command.If
      arms: [
        (if_arm
          cond: [
            (command.Subshell
              command_list: 
                (command.CommandList
                  children: [
                    (command.Pipeline
                      children: [
                        (command.SimpleCommand
                          words: [{(grep)} {(DQ ($ VSub_DollarName '$blue_grep'))}]
                          redirects: [
                            (redir.Redir
                              op: <Redir_Less '<'>
                              fd: 16777215
                              arg_word: {(check-grep)}
                            )
                          ]
                        )
                        (C {(grep)} {(DQ ($ VSub_DollarName '$blue_grep'))})
                      ]
                      negated: F
                    )
                  ]
                )
              redirects: [
                (redir.Redir op:<Redir_Great '>'> fd:16777215 arg_word:{(/dev/null)})
                (redir.Redir op:<Redir_GreatAnd '2>&'> fd:2 arg_word:{(1)})
              ]
            )
          ]
          action: [
            (command.Assignment
              keyword: Assign_None
              pairs: [(assign_pair lhs:(lhs_expr.LhsName name:grep_a) op:Equal rhs:{(grep)})]
            )
          ]
        )
        (if_arm
          cond: [
            (command.Subshell
              command_list: 
                (command.CommandList
                  children: [
                    (command.Pipeline
                      children: [
                        (command.SimpleCommand
                          words: [{(grep)} {(-a)} {(DQ ($ VSub_DollarName '$blue_grep'))}]
                          redirects: [
                            (redir.Redir
                              op: <Redir_Less '<'>
                              fd: 16777215
                              arg_word: {(check-grep)}
                            )
                          ]
                        )
                        (C {(grep)} {(-a)} {(DQ ($ VSub_DollarName '$blue_grep'))})
                      ]
                      negated: F
                    )
                  ]
                )
              redirects: [
                (redir.Redir op:<Redir_Great '>'> fd:16777215 arg_word:{(/dev/null)})
                (redir.Redir op:<Redir_GreatAnd '2>&'> fd:2 arg_word:{(1)})
              ]
            )
          ]
          action: [
            (command.Assignment
              keyword: Assign_None
              pairs: [(assign_pair lhs:(lhs_expr.LhsName name:grep_a) op:Equal rhs:{(SQ <'grep -a'>)})]
            )
          ]
        )
      ]
      else_action: [
        (command.Sentence
          child: 
            (command.Assignment
              keyword: Assign_None
              pairs: [(assign_pair lhs:(lhs_expr.LhsName name:grep_a) op:Equal rhs:{(grep)})]
            )
          terminator: <Op_Semi ';'>
        )
      ]
    )
    (C {(rm)} {(-f)} {(check-grep)})
    (command.FuncDef
      name: prepare_output
      body: 
        (command.BraceGroup
          children: [
            (command.SimpleCommand
              words: [{(git)} {(diff)} {(--color)}]
              redirects: [(redir.Redir op:<Redir_Great '>'> fd:16777215 arg_word:{(output)})]
            )
            (command.SimpleCommand
              words: [{($ VSub_DollarName '$grep_a')} {(DQ ($ VSub_DollarName '$blue_grep'))} {(output)}]
              redirects: [(redir.Redir op:<Redir_Great '>'> fd:16777215 arg_word:{(error)})]
            )
            (command.SimpleCommand
              words: [
                {($ VSub_DollarName '$grep_a')}
                {(-v)}
                {(DQ ($ VSub_DollarName '$blue_grep'))}
                {(output)}
              ]
              redirects: [(redir.Redir op:<Redir_Great '>'> fd:16777215 arg_word:{(normal)})]
            )
            (command.ControlFlow token:<ControlFlow_Return return> arg_word:{(0)})
          ]
        )
    )
    (C {(test_expect_success)} {(default)} 
      {
        (SQ <'\n'> <'\n'> <'\tprepare_output &&\n'> <'\n'> <'\tgrep Eight normal >/dev/null &&\n'> 
          <'\tgrep HT error >/dev/null &&\n'> <'\tgrep With error >/dev/null &&\n'> <'\tgrep Return error >/dev/null &&\n'> 
          <'\tgrep No normal >/dev/null\n'> <'\n'>
        )
      }
    )
    (C {(test_expect_success)} {(SQ <'default (attribute)'>)} 
      {
        (SQ <'\n'> <'\n'> <'\ttest_might_fail git config --unset core.whitespace &&\n'> 
          <'\techo "F whitespace" >.gitattributes &&\n'> <'\tprepare_output &&\n'> <'\n'> <'\tgrep Eight error >/dev/null &&\n'> 
          <'\tgrep HT error >/dev/null &&\n'> <'\tgrep With error >/dev/null &&\n'> <'\tgrep Return error >/dev/null &&\n'> 
          <'\tgrep No normal >/dev/null\n'> <'\n'>
        )
      }
    )
    (C {(test_expect_success)} {(SQ <'default, tabwidth=10 (attribute)'>)} 
      {
        (SQ <'\n'> <'\n'> <'\tgit config core.whitespace "tabwidth=10" &&\n'> 
          <'\techo "F whitespace" >.gitattributes &&\n'> <'\tprepare_output &&\n'> <'\n'> <'\tgrep Eight normal >/dev/null &&\n'> 
          <'\tgrep HT error >/dev/null &&\n'> <'\tgrep With error >/dev/null &&\n'> <'\tgrep Return error >/dev/null &&\n'> 
          <'\tgrep No normal >/dev/null\n'> <'\n'>
        )
      }
    )
    (C {(test_expect_success)} {(SQ <'no check (attribute)'>)} 
      {
        (SQ <'\n'> <'\n'> <'\ttest_might_fail git config --unset core.whitespace &&\n'> 
          <'\techo "F -whitespace" >.gitattributes &&\n'> <'\tprepare_output &&\n'> <'\n'> <'\tgrep Eight normal >/dev/null &&\n'> 
          <'\tgrep HT normal >/dev/null &&\n'> <'\tgrep With normal >/dev/null &&\n'> <'\tgrep Return normal >/dev/null &&\n'> 
          <'\tgrep No normal >/dev/null\n'> <'\n'>
        )
      }
    )
    (C {(test_expect_success)} {(SQ <'no check, tabwidth=10 (attribute), must be irrelevant'>)} 
      {
        (SQ <'\n'> <'\n'> <'\tgit config core.whitespace "tabwidth=10" &&\n'> 
          <'\techo "F -whitespace" >.gitattributes &&\n'> <'\tprepare_output &&\n'> <'\n'> <'\tgrep Eight normal >/dev/null &&\n'> 
          <'\tgrep HT normal >/dev/null &&\n'> <'\tgrep With normal >/dev/null &&\n'> <'\tgrep Return normal >/dev/null &&\n'> 
          <'\tgrep No normal >/dev/null\n'> <'\n'>
        )
      }
    )
    (C {(test_expect_success)} {(SQ <'without -trail'>)} 
      {
        (SQ <'\n'> <'\n'> <'\trm -f .gitattributes &&\n'> <'\tgit config core.whitespace -trail &&\n'> 
          <'\tprepare_output &&\n'> <'\n'> <'\tgrep Eight normal >/dev/null &&\n'> <'\tgrep HT error >/dev/null &&\n'> 
          <'\tgrep With normal >/dev/null &&\n'> <'\tgrep Return normal >/dev/null &&\n'> <'\tgrep No normal >/dev/null\n'> <'\n'>
        )
      }
    )
    (C {(test_expect_success)} {(SQ <'without -trail (attribute)'>)} 
      {
        (SQ <'\n'> <'\n'> <'\ttest_might_fail git config --unset core.whitespace &&\n'> 
          <'\techo "F whitespace=-trail" >.gitattributes &&\n'> <'\tprepare_output &&\n'> <'\n'> <'\tgrep Eight normal >/dev/null &&\n'> 
          <'\tgrep HT error >/dev/null &&\n'> <'\tgrep With normal >/dev/null &&\n'> <'\tgrep Return normal >/dev/null &&\n'> 
          <'\tgrep No normal >/dev/null\n'> <'\n'>
        )
      }
    )
    (C {(test_expect_success)} {(SQ <'without -space'>)} 
      {
        (SQ <'\n'> <'\n'> <'\trm -f .gitattributes &&\n'> <'\tgit config core.whitespace -space &&\n'> 
          <'\tprepare_output &&\n'> <'\n'> <'\tgrep Eight normal >/dev/null &&\n'> <'\tgrep HT normal >/dev/null &&\n'> 
          <'\tgrep With error >/dev/null &&\n'> <'\tgrep Return error >/dev/null &&\n'> <'\tgrep No normal >/dev/null\n'> <'\n'>
        )
      }
    )
    (C {(test_expect_success)} {(SQ <'without -space (attribute)'>)} 
      {
        (SQ <'\n'> <'\n'> <'\ttest_might_fail git config --unset core.whitespace &&\n'> 
          <'\techo "F whitespace=-space" >.gitattributes &&\n'> <'\tprepare_output &&\n'> <'\n'> <'\tgrep Eight normal >/dev/null &&\n'> 
          <'\tgrep HT normal >/dev/null &&\n'> <'\tgrep With error >/dev/null &&\n'> <'\tgrep Return error >/dev/null &&\n'> 
          <'\tgrep No normal >/dev/null\n'> <'\n'>
        )
      }
    )
    (C {(test_expect_success)} {(SQ <'with indent-non-tab only'>)} 
      {
        (SQ <'\n'> <'\n'> <'\trm -f .gitattributes &&\n'> 
          <'\tgit config core.whitespace indent,-trailing,-space &&\n'> <'\tprepare_output &&\n'> <'\n'> <'\tgrep Eight error >/dev/null &&\n'> 
          <'\tgrep HT normal >/dev/null &&\n'> <'\tgrep With normal >/dev/null &&\n'> <'\tgrep Return normal >/dev/null &&\n'> 
          <'\tgrep No normal >/dev/null\n'> <'\n'>
        )
      }
    )
    (C {(test_expect_success)} {(SQ <'with indent-non-tab only (attribute)'>)} 
      {
        (SQ <'\n'> <'\n'> <'\ttest_might_fail git config --unset core.whitespace &&\n'> 
          <'\techo "F whitespace=indent,-trailing,-space" >.gitattributes &&\n'> <'\tprepare_output &&\n'> <'\n'> <'\tgrep Eight error >/dev/null &&\n'> 
          <'\tgrep HT normal >/dev/null &&\n'> <'\tgrep With normal >/dev/null &&\n'> <'\tgrep Return normal >/dev/null &&\n'> 
          <'\tgrep No normal >/dev/null\n'> <'\n'>
        )
      }
    )
    (C {(test_expect_success)} {(SQ <'with indent-non-tab only, tabwidth=10'>)} 
      {
        (SQ <'\n'> <'\n'> <'\trm -f .gitattributes &&\n'> 
          <'\tgit config core.whitespace indent,tabwidth=10,-trailing,-space &&\n'> <'\tprepare_output &&\n'> <'\n'> <'\tgrep Eight normal >/dev/null &&\n'> 
          <'\tgrep HT normal >/dev/null &&\n'> <'\tgrep With normal >/dev/null &&\n'> <'\tgrep Return normal >/dev/null &&\n'> 
          <'\tgrep No normal >/dev/null\n'> <'\n'>
        )
      }
    )
    (C {(test_expect_success)} {(SQ <'with indent-non-tab only, tabwidth=10 (attribute)'>)} 
      {
        (SQ <'\n'> <'\n'> <'\ttest_might_fail git config --unset core.whitespace &&\n'> 
          <'\techo "F whitespace=indent,-trailing,-space,tabwidth=10" >.gitattributes &&\n'> <'\tprepare_output &&\n'> <'\n'> <'\tgrep Eight normal >/dev/null &&\n'> 
          <'\tgrep HT normal >/dev/null &&\n'> <'\tgrep With normal >/dev/null &&\n'> <'\tgrep Return normal >/dev/null &&\n'> 
          <'\tgrep No normal >/dev/null\n'> <'\n'>
        )
      }
    )
    (C {(test_expect_success)} {(SQ <'with cr-at-eol'>)} 
      {
        (SQ <'\n'> <'\n'> <'\trm -f .gitattributes &&\n'> 
          <'\tgit config core.whitespace cr-at-eol &&\n'> <'\tprepare_output &&\n'> <'\n'> <'\tgrep Eight normal >/dev/null &&\n'> 
          <'\tgrep HT error >/dev/null &&\n'> <'\tgrep With error >/dev/null &&\n'> <'\tgrep Return normal >/dev/null &&\n'> 
          <'\tgrep No normal >/dev/null\n'> <'\n'>
        )
      }
    )
    (C {(test_expect_success)} {(SQ <'with cr-at-eol (attribute)'>)} 
      {
        (SQ <'\n'> <'\n'> <'\ttest_might_fail git config --unset core.whitespace &&\n'> 
          <'\techo "F whitespace=trailing,cr-at-eol" >.gitattributes &&\n'> <'\tprepare_output &&\n'> <'\n'> <'\tgrep Eight normal >/dev/null &&\n'> 
          <'\tgrep HT error >/dev/null &&\n'> <'\tgrep With error >/dev/null &&\n'> <'\tgrep Return normal >/dev/null &&\n'> 
          <'\tgrep No normal >/dev/null\n'> <'\n'>
        )
      }
    )
    (C {(test_expect_success)} {(SQ <'trailing empty lines (1)'>)} 
      {
        (SQ <'\n'> <'\n'> <'\trm -f .gitattributes &&\n'> 
          <'\ttest_must_fail git diff --check >output &&\n'> <'\tgrep "new blank line at" output &&\n'> <'\tgrep "trailing whitespace" output\n'> <'\n'>
        )
      }
    )
    (C {(test_expect_success)} {(SQ <'trailing empty lines (2)'>)} 
      {
        (SQ <'\n'> <'\n'> <'\techo "F -whitespace" >.gitattributes &&\n'> 
          <'\tgit diff --check >output &&\n'> <'\t! test -s output\n'> <'\n'>
        )
      }
    )
    (C {(test_expect_success)} {(SQ <'checkdiff shows correct line number for trailing blank lines'>)} 
      {
        (SQ <'\n'> <'\n'> <'\tprintf "a\\nb\\n" > G &&\n'> <'\tgit add G &&\n'> 
          <'\tprintf "x\\nx\\nx\\na\\nb\\nc\\n\\n" > G &&\n'> <'\t[ "$(git diff --check -- G)" = "G:7: new blank line at EOF." ]\n'> <'\n'>
        )
      }
    )
    (C {(test_expect_success)} {(SQ <'do not color trailing cr in context'>)} 
      {
        (SQ <'\n'> <'\ttest_might_fail git config --unset core.whitespace &&\n'> 
          <'\trm -f .gitattributes &&\n'> <'\techo AAAQ | tr Q "\\015" >G &&\n'> <'\tgit add G &&\n'> <'\techo BBBQ | tr Q "\\015" >>G &&\n'> 
          <'\tgit diff --color G | tr "\\015" Q >output &&\n'> <'\tgrep "BBB.*${blue_grep}Q" output &&\n'> <'\tgrep "AAA.*\\[mQ" output\n'> <'\n'>
        )
      }
    )
    (C {(test_expect_success)} {(SQ <'color new trailing blank lines'>)} 
      {
        (SQ <'\n'> <'\t{ echo a; echo b; echo; echo; } >x &&\n'> <'\tgit add x &&\n'> 
          <'\t{ echo a; echo; echo; echo; echo c; echo; echo; echo; echo; } >x &&\n'> <'\tgit diff --color x >output &&\n'> <'\tcnt=$($grep_a "${blue_grep}" output | wc -l) &&\n'> 
          <'\ttest $cnt = 2\n'>
        )
      }
    )
    (C {(test_done)})
  ]
)