(command.CommandList children: [ (command.ShAssignment pairs: [ (assign_pair lhs: (sh_lhs_expr.Name name:test_description) op: assign_op.Equal rhs: {(SQ <'diff whitespace error detection'>)} spids: [4] ) ] ) (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.ShAssignment pairs: [ (assign_pair lhs: (sh_lhs_expr.Name name:blue_grep) op: assign_op.Equal rhs: {(SQ <'7;34m'>)} spids: [35] ) ] ) terminator: <Id.Op_Semi _> ) (command.Simple words: [ {<printf>} {(DQ <Id.Lit_BadBackslash '\\'> <'033[%s'>)} {(DQ ($ Id.VSub_DollarName '$blue_grep'))} ] redirects: [(redir op:<Id.Redir_Great '>'> loc:(redir_loc.Fd fd:1) arg:{<check-grep>})] do_fork: T ) (command.If arms: [ (if_arm cond: (condition.Shell commands: [ (command.Subshell child: (command.Pipeline children: [ (command.Simple words: [{<grep>} {(DQ ($ Id.VSub_DollarName '$blue_grep'))}] redirects: [ (redir op: <Id.Redir_Less '<'> loc: (redir_loc.Fd fd:0) arg: {<check-grep>} ) ] do_fork: T ) (C {<grep>} {(DQ ($ Id.VSub_DollarName '$blue_grep'))}) ] negated: F ) redirects: [ (redir op: <Id.Redir_Great '>'> loc: (redir_loc.Fd fd:1) arg: {<'/dev/null'>} ) (redir op: <Id.Redir_GreatAnd '2>&'> loc: (redir_loc.Fd fd:2) arg: {<1>} ) ] ) ] ) action: [ (command.ShAssignment pairs: [ (assign_pair lhs: (sh_lhs_expr.Name name:grep_a) op: assign_op.Equal rhs: {<grep>} spids: [89] ) ] ) ] spids: [59 86] ) (if_arm cond: (condition.Shell commands: [ (command.Subshell child: (command.Pipeline children: [ (command.Simple words: [{<grep>} {<-a>} {(DQ ($ Id.VSub_DollarName '$blue_grep'))}] redirects: [ (redir op: <Id.Redir_Less '<'> loc: (redir_loc.Fd fd:0) arg: {<check-grep>} ) ] do_fork: T ) (C {<grep>} {<-a>} {(DQ ($ Id.VSub_DollarName '$blue_grep'))}) ] negated: F ) redirects: [ (redir op: <Id.Redir_Great '>'> loc: (redir_loc.Fd fd:1) arg: {<'/dev/null'>} ) (redir op: <Id.Redir_GreatAnd '2>&'> loc: (redir_loc.Fd fd:2) arg: {<1>} ) ] ) ] ) action: [ (command.ShAssignment pairs: [ (assign_pair lhs: (sh_lhs_expr.Name name:grep_a) op: assign_op.Equal rhs: {(SQ <'grep -a'>)} spids: [126] ) ] ) ] spids: [92 123] ) ] else_action: [ (command.Sentence child: (command.ShAssignment pairs: [ (assign_pair lhs: (sh_lhs_expr.Name name:grep_a) op: assign_op.Equal rhs: {<grep>} spids: [134] ) ] ) terminator: <Id.Op_Semi _> ) ] ) (C {<rm>} {<-f>} {<check-grep>}) (command.ShFunction name: prepare_output body: (BraceGroup children: [ (command.Simple words: [{<git>} {<diff>} {<--color>}] redirects: [(redir op:<Id.Redir_Great '>'> loc:(redir_loc.Fd fd:1) arg:{<output>})] do_fork: T ) (command.Simple words: [ {($ Id.VSub_DollarName '$grep_a')} {(DQ ($ Id.VSub_DollarName '$blue_grep'))} {<output>} ] redirects: [(redir op:<Id.Redir_Great '>'> loc:(redir_loc.Fd fd:1) arg:{<error>})] do_fork: T ) (command.Simple words: [ {($ Id.VSub_DollarName '$grep_a')} {<-v>} {(DQ ($ Id.VSub_DollarName '$blue_grep'))} {<output>} ] redirects: [(redir op:<Id.Redir_Great '>'> loc:(redir_loc.Fd fd:1) arg:{<normal>})] do_fork: T ) (command.ControlFlow token:<Id.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>}) ] )