(command.CommandList children: [ (command.ShAssignment pairs: [ (assign_pair lhs: (sh_lhs_expr.Name name:test_description) op: assign_op.Equal rhs: {(SQ <'core.whitespace rules and git apply'>)} spids: [4] ) ] ) (C {<.>} {<'./test-lib.sh'>}) (command.ShFunction name: prepare_test_file body: (BraceGroup children: [ (command.Simple words: [{<sed>} {<-e>} {(DQ <'s/_/ /g'>)} {<-e>} {(DQ <'s/>/\t/'>)}] redirects: [ (redir op: <Id.Redir_DLessDash '<<-'> 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: 87 stdin_parts: [ <'An_SP in an ordinary line>and a HT.\n'> <'>A HT (%).\n'> <'_>A SP and a HT (@%).\n'> <'_>_A SP, a HT and a SP (@%).\n'> <'_______Seven SP.\n'> <'________Eight SP (#).\n'> <'_______>Seven SP and a HT (@%).\n'> <'________>Eight SP and a HT (@#%).\n'> <'_______>_Seven SP, a HT and a SP (@%).\n'> <'________>_Eight SP, a HT and a SP (@#%).\n'> <'_______________Fifteen SP (#).\n'> <'_______________>Fifteen SP and a HT (@#%).\n'> <'________________Sixteen SP (#=).\n'> <'________________>Sixteen SP and a HT (@#%=).\n'> <'_____a__Five SP, a non WS, two SP.\n'> <'A line with a (!) trailing SP_\n'> <'A line with a (!) trailing HT>\n'> ] ) ) ] do_fork: T ) ] ) ) (command.ShFunction name: apply_patch body: (BraceGroup children: [ (command.AndOr ops: [Id.Op_DAmp] children: [ (command.Simple redirects: [(redir op:<Id.Redir_Great '>'> loc:(redir_loc.Fd fd:1) arg:{<target>})] do_fork: F ) (command.Pipeline children: [ (command.Simple words: [ {<sed>} {<-e>} { (DQ <'s|'> <Id.Lit_BadBackslash '\\'> <'([ab]'> <Id.Lit_BadBackslash '\\'> <')/file|'> <Id.Lit_BadBackslash '\\'> <'1/target|'> ) } ] redirects: [(redir op:<Id.Redir_Less '<'> loc:(redir_loc.Fd fd:0) arg:{<patch>})] do_fork: T ) (C {<git>} {<apply>} {(DQ ($ Id.VSub_At '$@'))}) ] negated: F ) ] ) ] ) ) (command.ShFunction name: test_fix body: (BraceGroup children: [ (command.AndOr ops: [Id.Op_DPipe] children: [ (C {<apply_patch>} {<--whitespace> <Id.Lit_Equals '='> <fix>}) (command.ControlFlow token: <Id.ControlFlow_Return return> arg_word: {<1>} ) ] ) (command.Pipeline children: [ (C {($ Id.VSub_DollarName '$DIFF')} {<file>} {<target>}) (command.Simple words: [{<sed>} {<-n>} {<-e>} {(DQ <'s/^> //p'>)}] redirects: [(redir op:<Id.Redir_Great '>'> loc:(redir_loc.Fd fd:1) arg:{<fixed>})] do_fork: T ) ] negated: F ) (command.ShAssignment pairs: [ (assign_pair lhs: (sh_lhs_expr.Name name:fixed_cnt) op: assign_op.Equal rhs: { (command_sub left_token: <Id.Left_DollarParen '$('> child: (command.Simple words: [{<wc>} {<-l>}] redirects: [ (redir op: <Id.Redir_Less '<'> loc: (redir_loc.Fd fd:0) arg: {<fixed>} ) ] do_fork: T ) ) } spids: [193] ) ] ) (command.Case to_match: {(DQ ($ Id.VSub_Number '$1'))} arms: [ (case_arm pat_list: [{(SQ )}] action: [ (command.ShAssignment pairs: [ (assign_pair lhs: (sh_lhs_expr.Name name:expect_cnt) op: assign_op.Equal rhs: {($ Id.VSub_DollarName '$fixed_cnt')} spids: [217] ) ] ) ] spids: [213 215 220 -1] ) (case_arm pat_list: [{<Id.Lit_QMark '?'> <Id.Lit_Star '*'>}] action: [ (command.ShAssignment pairs: [ (assign_pair lhs: (sh_lhs_expr.Name name:expect_cnt) op: assign_op.Equal rhs: { (command_sub left_token: <Id.Left_DollarParen '$('> child: (command.Pipeline children: [ (command.Simple words: [{<grep>} {(DQ <'['> ($ Id.VSub_Number '$1') <']'>)}] redirects: [ (redir op: <Id.Redir_Less '<'> loc: (redir_loc.Fd fd:0) arg: {<fixed>} ) ] do_fork: T ) (C {<wc>} {<-l>}) ] negated: F ) ) } spids: [227] ) ] ) ] spids: [223 225 247 -1] ) ] ) (command.AndOr ops: [Id.Op_DPipe] children: [ (C {<test>} {($ Id.VSub_DollarName '$fixed_cnt')} {<-eq>} {($ Id.VSub_DollarName '$expect_cnt')} ) (command.ControlFlow token: <Id.ControlFlow_Return return> arg_word: {<1>} ) ] ) (command.Case to_match: {(DQ ($ Id.VSub_Number '$1'))} arms: [ (case_arm pat_list: [{(SQ )}] action: [ (command.ShAssignment pairs: [ (assign_pair lhs: (sh_lhs_expr.Name name:expect_cnt) op: assign_op.Equal rhs: {<0>} spids: [286] ) ] ) ] spids: [282 284 289 -1] ) (case_arm pat_list: [{<Id.Lit_QMark '?'> <Id.Lit_Star '*'>}] action: [ (command.ShAssignment pairs: [ (assign_pair lhs: (sh_lhs_expr.Name name:expect_cnt) op: assign_op.Equal rhs: { (command_sub left_token: <Id.Left_DollarParen '$('> child: (command.Pipeline children: [ (command.Simple words: [{<grep>} {(DQ <'['> ($ Id.VSub_Number '$1') <']'>)}] redirects: [ (redir op: <Id.Redir_Less '<'> loc: (redir_loc.Fd fd:0) arg: {<file>} ) ] do_fork: T ) (C {<wc>} {<-l>}) ] negated: F ) ) } spids: [296] ) ] ) ] spids: [292 294 316 -1] ) ] ) (command.AndOr ops: [Id.Op_DPipe] children: [ (C {<test>} {($ Id.VSub_DollarName '$fixed_cnt')} {<-eq>} {($ Id.VSub_DollarName '$expect_cnt')} ) (command.ControlFlow token: <Id.ControlFlow_Return return> arg_word: {<1>} ) ] ) (command.Simple words: [{<git>} {<diff-files>} {<-p>} {<target>}] redirects: [(redir op:<Id.Redir_Great '>'> loc:(redir_loc.Fd fd:1) arg:{<fixed-patch>})] do_fork: T ) (command.AndOr ops: [Id.Op_DAmp] children: [ (C {<test>} {<-s>} {<fixed-patch>}) (command.ControlFlow token: <Id.ControlFlow_Return return> arg_word: {<0>} ) ] ) (command.Simple redirects: [(redir op:<Id.Redir_Great '>'> loc:(redir_loc.Fd fd:1) arg:{<target>})] do_fork: F ) (command.Simple words: [{<git>} {<apply>} {<--whitespace> <Id.Lit_Equals '='> <error-all>}] redirects: [(redir op:<Id.Redir_Less '<'> loc:(redir_loc.Fd fd:0) arg:{<fixed-patch>})] do_fork: T ) ] ) ) (C {<test_expect_success>} {<setup>} { (SQ <'\n'> <'\n'> <'\t>file &&\n'> <'\tgit add file &&\n'> <'\tprepare_test_file >file &&\n'> <'\tgit diff-files -p >patch &&\n'> <'\t>target &&\n'> <'\tgit add target\n'> <'\n'> ) } ) (C {<test_expect_success>} {(SQ <'whitespace=nowarn, default rule'>)} { (SQ <'\n'> <'\n'> <'\tapply_patch --whitespace=nowarn &&\n'> <'\ttest_cmp file target\n'> <'\n'>) } ) (C {<test_expect_success>} {(SQ <'whitespace=warn, default rule'>)} { (SQ <'\n'> <'\n'> <'\tapply_patch --whitespace=warn &&\n'> <'\ttest_cmp file target\n'> <'\n'>) } ) (C {<test_expect_success>} {(SQ <'whitespace=error-all, default rule'>)} { (SQ <'\n'> <'\n'> <'\ttest_must_fail apply_patch --whitespace=error-all &&\n'> <'\t! test -s target\n'> <'\n'> ) } ) (C {<test_expect_success>} {(SQ <'whitespace=error-all, no rule'>)} { (SQ <'\n'> <'\n'> <'\tgit config core.whitespace -trailing,-space-before,-indent &&\n'> <'\tapply_patch --whitespace=error-all &&\n'> <'\ttest_cmp file target\n'> <'\n'> ) } ) (C {<test_expect_success>} {(SQ <'whitespace=error-all, no rule (attribute)'>)} { (SQ <'\n'> <'\n'> <'\tgit config --unset core.whitespace &&\n'> <'\techo "target -whitespace" >.gitattributes &&\n'> <'\tapply_patch --whitespace=error-all &&\n'> <'\ttest_cmp file target\n'> <'\n'> ) } ) (C {<test_expect_success>} {(SQ <'spaces inserted by tab-in-indent'>)} { (SQ <'\n'> <'\n'> <'\tgit config core.whitespace -trailing,-space,-indent,tab &&\n'> <'\trm -f .gitattributes &&\n'> <'\ttest_fix % &&\n'> <'\tsed -e "s/_/ /g" -e "s/>/\t/" <<-\\EOF >expect &&\n'> <'\t\tAn_SP in an ordinary line>and a HT.\n'> <'\t\t________A HT (%).\n'> <'\t\t________A SP and a HT (@%).\n'> <'\t\t_________A SP, a HT and a SP (@%).\n'> <'\t\t_______Seven SP.\n'> <'\t\t________Eight SP (#).\n'> <'\t\t________Seven SP and a HT (@%).\n'> <'\t\t________________Eight SP and a HT (@#%).\n'> <'\t\t_________Seven SP, a HT and a SP (@%).\n'> <'\t\t_________________Eight SP, a HT and a SP (@#%).\n'> <'\t\t_______________Fifteen SP (#).\n'> <'\t\t________________Fifteen SP and a HT (@#%).\n'> <'\t\t________________Sixteen SP (#=).\n'> <'\t\t________________________Sixteen SP and a HT (@#%=).\n'> <'\t\t_____a__Five SP, a non WS, two SP.\n'> <'\t\tA line with a (!) trailing SP_\n'> <'\t\tA line with a (!) trailing HT>\n'> <'\tEOF\n'> <'\ttest_cmp expect target\n'> <'\n'> ) } ) (command.ForEach iter_name: t iter_words: [{<->} {(SQ )}] do_arg_iter: F body: (command.DoGroup children: [ (command.Case to_match: {(DQ ($ Id.VSub_DollarName '$t'))} arms: [ (case_arm pat_list: [{(SQ )}] action: [ (command.ShAssignment pairs: [ (assign_pair lhs: (sh_lhs_expr.Name name:tt) op: assign_op.Equal rhs: {(SQ <'!'>)} spids: [548] ) ] ) ] spids: [544 546 553 -1] ) (case_arm pat_list: [{<Id.Lit_Star '*'>}] action: [ (command.ShAssignment pairs: [ (assign_pair lhs: (sh_lhs_expr.Name name:tt) op: assign_op.Equal rhs: (word.Empty) spids: [558] ) ] ) ] spids: [555 556 560 -1] ) ] ) (command.ForEach iter_name: s iter_words: [{<->} {(SQ )}] do_arg_iter: F body: (command.DoGroup children: [ (command.Case to_match: {(DQ ($ Id.VSub_DollarName '$s'))} arms: [ (case_arm pat_list: [{(SQ )}] action: [ (command.ShAssignment pairs: [ (assign_pair lhs: (sh_lhs_expr.Name name:ts) op: assign_op.Equal rhs: {(SQ <'@'>)} spids: [592] ) ] ) ] spids: [588 590 597 -1] ) (case_arm pat_list: [{<Id.Lit_Star '*'>}] action: [ (command.ShAssignment pairs: [ (assign_pair lhs: (sh_lhs_expr.Name name:ts) op: assign_op.Equal rhs: (word.Empty) spids: [602] ) ] ) ] spids: [599 600 604 -1] ) ] ) (command.ForEach iter_name: i iter_words: [{<->} {(SQ )}] do_arg_iter: F body: (command.DoGroup children: [ (command.Case to_match: {(DQ ($ Id.VSub_DollarName '$i'))} arms: [ (case_arm pat_list: [{(SQ )}] action: [ (command.ShAssignment pairs: [ (assign_pair lhs: (sh_lhs_expr.Name name:ti) op: assign_op.Equal rhs: {(SQ <'#'>)} spids: [636] ) (assign_pair lhs: (sh_lhs_expr.Name name:ti16) op: assign_op.Equal rhs: {(SQ <'='>)} spids: [641] ) ] ) ] spids: [632 634 645 -1] ) (case_arm pat_list: [{<Id.Lit_Star '*'>}] action: [ (command.ShAssignment pairs: [ (assign_pair lhs: (sh_lhs_expr.Name name:ti) op: assign_op.Equal rhs: (word.Empty) spids: [650] ) (assign_pair lhs: (sh_lhs_expr.Name name:ti16) op: assign_op.Equal rhs: (word.Empty) spids: [652] ) ] ) ] spids: [647 648 654 -1] ) ] ) (command.ForEach iter_name: h iter_words: [{<->} {(SQ )}] do_arg_iter: F body: (command.DoGroup children: [ (command.AndOr ops: [Id.Op_DAmp] children: [ (C {<Id.Lit_LBracket '['>} {<-z>} { (DQ ($ Id.VSub_DollarName '$h') ($ Id.VSub_DollarName '$i') ) } {<Id.Lit_RBracket ']'>} ) (command.ControlFlow token: <Id.ControlFlow_Continue continue> ) ] ) (command.Case to_match: {(DQ ($ Id.VSub_DollarName '$h'))} arms: [ (case_arm pat_list: [{(SQ )}] action: [ (command.ShAssignment pairs: [ (assign_pair lhs: (sh_lhs_expr.Name name:th) op: assign_op.Equal rhs: {(SQ <'%'>)} spids: [702] ) ] ) ] spids: [698 700 707 -1] ) (case_arm pat_list: [{<Id.Lit_Star '*'>}] action: [ (command.ShAssignment pairs: [ (assign_pair lhs: (sh_lhs_expr.Name name:th) op: assign_op.Equal rhs: (word.Empty) spids: [712] ) ] ) ] spids: [709 710 714 -1] ) ] ) (command.ShAssignment pairs: [ (assign_pair lhs: (sh_lhs_expr.Name name:rule) op: assign_op.Equal rhs: {(${ Id.VSub_Name t) <trailing> <Id.Lit_Comma ','> (${ Id.VSub_Name s) <space> <Id.Lit_Comma ','> (${ Id.VSub_Name i) <indent> <Id.Lit_Comma ','> (${ Id.VSub_Name h) <tab> } spids: [719] ) ] ) (C {<rm>} {<-f>} {<.gitattributes>}) (C {<test_expect_success>} {(DQ <'rule='> ($ Id.VSub_DollarName '$rule'))} { (SQ <'\n'> <'\t\t\t\t\tgit config core.whitespace "$rule" &&\n'> <'\t\t\t\t\ttest_fix "$tt$ts$ti$th"\n'> <'\t\t\t\t'> ) } ) (C {<test_expect_success>} {(DQ <'rule='> ($ Id.VSub_DollarName '$rule') <',tabwidth=16'>)} { (SQ <'\n'> < '\t\t\t\t\tgit config core.whitespace "$rule,tabwidth=16" &&\n' > <'\t\t\t\t\ttest_fix "$tt$ts$ti16$th"\n'> <'\t\t\t\t'> ) } ) (C {<test_expect_success>} { (DQ <'rule='> ($ Id.VSub_DollarName '$rule') <' (attributes)'>) } { (SQ <'\n'> <'\t\t\t\t\tgit config --unset core.whitespace &&\n'> <'\t\t\t\t\techo "target whitespace=$rule" >.gitattributes &&\n'> <'\t\t\t\t\ttest_fix "$tt$ts$ti$th"\n'> <'\t\t\t\t'> ) } ) (C {<test_expect_success>} { (DQ <'rule='> ($ Id.VSub_DollarName '$rule') <',tabwidth=16 (attributes)'> ) } { (SQ <'\n'> < '\t\t\t\t\techo "target whitespace=$rule,tabwidth=16" >.gitattributes &&\n' > <'\t\t\t\t\ttest_fix "$tt$ts$ti16$th"\n'> <'\t\t\t\t'> ) } ) ] ) ) ] ) ) ] ) ) ] ) ) (command.ShFunction name: create_patch body: (BraceGroup children: [ (command.Simple words: [{<sed>} {<-e>} {(DQ <'s/_/ /'>)}] redirects: [ (redir op: <Id.Redir_DLessDash '<<-'> 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: 857 stdin_parts: [ <'diff --git a/target b/target\n'> <'index e69de29..8bd6648 100644\n'> <'--- a/target\n'> <'+++ b/target\n'> <'@@ -0,0 +1,3 @@\n'> <'+An empty line follows\n'> <'+\n'> <'+A line with trailing whitespace and no newline_\n'> <'\\ No newline at end of file\n'> ] ) ) ] do_fork: T ) ] ) ) (C {<test_expect_success>} {(SQ <'trailing whitespace & no newline at the end of file'>)} { (SQ <'\n'> <'\t>target &&\n'> <'\tcreate_patch >patch-file &&\n'> <'\tgit apply --whitespace=fix patch-file &&\n'> <'\tgrep "newline$" target &&\n'> <'\tgrep "^$" target\n'> ) } ) (C {<test_expect_success>} {(SQ <'blank at EOF with --whitespace=fix (1)'>)} { (SQ <'\n'> <'\ttest_might_fail git config --unset core.whitespace &&\n'> <'\trm -f .gitattributes &&\n'> <'\n'> <'\t{ echo a; echo b; echo c; } >one &&\n'> <'\tgit add one &&\n'> <'\t{ echo a; echo b; echo c; } >expect &&\n'> <'\t{ cat expect; echo; } >one &&\n'> <'\tgit diff -- one >patch &&\n'> <'\n'> <'\tgit checkout one &&\n'> <'\tgit apply --whitespace=fix patch &&\n'> <'\ttest_cmp expect one\n'> ) } ) (C {<test_expect_success>} {(SQ <'blank at EOF with --whitespace=fix (2)'>)} { (SQ <'\n'> <'\t{ echo a; echo b; echo c; } >one &&\n'> <'\tgit add one &&\n'> <'\t{ echo a; echo c; } >expect &&\n'> <'\t{ cat expect; echo; echo; } >one &&\n'> <'\tgit diff -- one >patch &&\n'> <'\n'> <'\tgit checkout one &&\n'> <'\tgit apply --whitespace=fix patch &&\n'> <'\ttest_cmp expect one\n'> ) } ) (C {<test_expect_success>} {(SQ <'blank at EOF with --whitespace=fix (3)'>)} { (SQ <'\n'> <'\t{ echo a; echo b; echo; } >one &&\n'> <'\tgit add one &&\n'> <'\t{ echo a; echo c; echo; } >expect &&\n'> <'\t{ cat expect; echo; echo; } >one &&\n'> <'\tgit diff -- one >patch &&\n'> <'\n'> <'\tgit checkout one &&\n'> <'\tgit apply --whitespace=fix patch &&\n'> <'\ttest_cmp expect one\n'> ) } ) (C {<test_expect_success>} {(SQ <'blank at end of hunk, not at EOF with --whitespace=fix'>)} { (SQ <'\n'> <'\t{ echo a; echo b; echo; echo; echo; echo; echo; echo d; } >one &&\n'> <'\tgit add one &&\n'> <'\t{ echo a; echo c; echo; echo; echo; echo; echo; echo; echo d; } >expect &&\n'> <'\tcp expect one &&\n'> <'\tgit diff -- one >patch &&\n'> <'\n'> <'\tgit checkout one &&\n'> <'\tgit apply --whitespace=fix patch &&\n'> <'\ttest_cmp expect one\n'> ) } ) (C {<test_expect_success>} {(SQ <'blank at EOF with --whitespace=warn'>)} { (SQ <'\n'> <'\t{ echo a; echo b; echo c; } >one &&\n'> <'\tgit add one &&\n'> <'\techo >>one &&\n'> <'\tcat one >expect &&\n'> <'\tgit diff -- one >patch &&\n'> <'\n'> <'\tgit checkout one &&\n'> <'\tgit apply --whitespace=warn patch 2>error &&\n'> <'\ttest_cmp expect one &&\n'> <'\tgrep "new blank line at EOF" error\n'> ) } ) (C {<test_expect_success>} {(SQ <'blank at EOF with --whitespace=error'>)} { (SQ <'\n'> <'\t{ echo a; echo b; echo c; } >one &&\n'> <'\tgit add one &&\n'> <'\tcat one >expect &&\n'> <'\techo >>one &&\n'> <'\tgit diff -- one >patch &&\n'> <'\n'> <'\tgit checkout one &&\n'> <'\ttest_must_fail git apply --whitespace=error patch 2>error &&\n'> <'\ttest_cmp expect one &&\n'> <'\tgrep "new blank line at EOF" error\n'> ) } ) (C {<test_expect_success>} {(SQ <'blank but not empty at EOF'>)} { (SQ <'\n'> <'\t{ echo a; echo b; echo c; } >one &&\n'> <'\tgit add one &&\n'> <'\techo " " >>one &&\n'> <'\tcat one >expect &&\n'> <'\tgit diff -- one >patch &&\n'> <'\n'> <'\tgit checkout one &&\n'> <'\tgit apply --whitespace=warn patch 2>error &&\n'> <'\ttest_cmp expect one &&\n'> <'\tgrep "new blank line at EOF" error\n'> ) } ) (C {<test_expect_success>} {(SQ <'applying beyond EOF requires one non-blank context line'>)} { (SQ <'\n'> <'\t{ echo; echo; echo; echo; } >one &&\n'> <'\tgit add one &&\n'> <'\t{ echo b; } >>one &&\n'> <'\tgit diff -- one >patch &&\n'> <'\n'> <'\tgit checkout one &&\n'> <'\t{ echo a; echo; } >one &&\n'> <'\tcp one expect &&\n'> <'\ttest_must_fail git apply --whitespace=fix patch &&\n'> <'\ttest_cmp one expect &&\n'> <'\ttest_must_fail git apply --ignore-space-change --whitespace=fix patch &&\n'> <'\ttest_cmp one expect\n'> ) } ) (C {<test_expect_success>} {(SQ <'tons of blanks at EOF should not apply'>)} { (SQ <'\n'> <'\tfor i in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16; do\n'> <'\t\techo; echo; echo; echo;\n'> <'\tdone >one &&\n'> <'\tgit add one &&\n'> <'\techo a >>one &&\n'> <'\tgit diff -- one >patch &&\n'> <'\n'> <'\t>one &&\n'> <'\ttest_must_fail git apply --whitespace=fix patch &&\n'> <'\ttest_must_fail git apply --ignore-space-change --whitespace=fix patch\n'> ) } ) (C {<test_expect_success>} {(SQ <'missing blank line at end with --whitespace=fix'>)} { (SQ <'\n'> <'\techo a >one &&\n'> <'\techo >>one &&\n'> <'\tgit add one &&\n'> <'\techo b >>one &&\n'> <'\tcp one expect &&\n'> <'\tgit diff -- one >patch &&\n'> <'\techo a >one &&\n'> <'\tcp one saved-one &&\n'> <'\ttest_must_fail git apply patch &&\n'> <'\tgit apply --whitespace=fix patch &&\n'> <'\ttest_cmp one expect &&\n'> <'\tmv saved-one one &&\n'> <'\tgit apply --ignore-space-change --whitespace=fix patch &&\n'> <'\ttest_cmp one expect\n'> ) } ) (C {<test_expect_success>} {(SQ <'two missing blank lines at end with --whitespace=fix'>)} { (SQ <'\n'> <'\t{ echo a; echo; echo b; echo c; } >one &&\n'> <'\tcp one no-blank-lines &&\n'> <'\t{ echo; echo; } >>one &&\n'> <'\tgit add one &&\n'> <'\techo d >>one &&\n'> <'\tcp one expect &&\n'> <'\techo >>one &&\n'> <'\tgit diff -- one >patch &&\n'> <'\tcp no-blank-lines one &&\n'> <'\ttest_must_fail git apply patch &&\n'> <'\tgit apply --whitespace=fix patch &&\n'> <'\ttest_cmp one expect &&\n'> <'\tmv no-blank-lines one &&\n'> <'\ttest_must_fail git apply patch &&\n'> <'\tgit apply --ignore-space-change --whitespace=fix patch &&\n'> <'\ttest_cmp one expect\n'> ) } ) (C {<test_expect_success>} {(SQ <'missing blank line at end, insert before end, --whitespace=fix'>)} { (SQ <'\n'> <'\t{ echo a; echo; } >one &&\n'> <'\tgit add one &&\n'> <'\t{ echo b; echo a; echo; } >one &&\n'> <'\tcp one expect &&\n'> <'\tgit diff -- one >patch &&\n'> <'\techo a >one &&\n'> <'\ttest_must_fail git apply patch &&\n'> <'\tgit apply --whitespace=fix patch &&\n'> <'\ttest_cmp one expect\n'> ) } ) (C {<test_expect_success>} {(SQ <'shrink file with tons of missing blanks at end of file'>)} { (SQ <'\n'> <'\t{ echo a; echo b; echo c; } >one &&\n'> <'\tcp one no-blank-lines &&\n'> <'\tfor i in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16; do\n'> <'\t\techo; echo; echo; echo;\n'> <'\tdone >>one &&\n'> <'\tgit add one &&\n'> <'\techo a >one &&\n'> <'\tcp one expect &&\n'> <'\tgit diff -- one >patch &&\n'> <'\tcp no-blank-lines one &&\n'> <'\ttest_must_fail git apply patch &&\n'> <'\tgit apply --whitespace=fix patch &&\n'> <'\ttest_cmp one expect &&\n'> <'\tmv no-blank-lines one &&\n'> <'\tgit apply --ignore-space-change --whitespace=fix patch &&\n'> <'\ttest_cmp one expect\n'> ) } ) (C {<test_expect_success>} {(SQ <'missing blanks at EOF must only match blank lines'>)} { (SQ <'\n'> <'\t{ echo a; echo b; } >one &&\n'> <'\tgit add one &&\n'> <'\t{ echo c; echo d; } >>one &&\n'> <'\tgit diff -- one >patch &&\n'> <'\n'> <'\techo a >one &&\n'> <'\ttest_must_fail git apply patch &&\n'> <'\ttest_must_fail git apply --whitespace=fix patch &&\n'> <'\ttest_must_fail git apply --ignore-space-change --whitespace=fix patch\n'> ) } ) (command.Simple words: [{<sed>} {<-e> (SQ <'s/Z//'>)}] redirects: [ (redir op:<Id.Redir_Great '>'> loc:(redir_loc.Fd fd:1) arg:{<one>}) (redir op: <Id.Redir_DLess '<<'> loc: (redir_loc.Fd fd:0) arg: (redir_param.HereDoc here_begin: {<EOF>} here_end_span_id: 1204 stdin_parts: [<'a\n'> <'b\n'> <'c\n'> <'\t\t Z\n'>] ) ) ] do_fork: T ) (C {<test_expect_success>} {(SQ <'missing blank line should match context line with spaces'>)} { (SQ <'\n'> <'\tgit add one &&\n'> <'\techo d >>one &&\n'> <'\tgit diff -- one >patch &&\n'> <'\t{ echo a; echo b; echo c; } >one &&\n'> <'\tcp one expect &&\n'> <'\t{ echo; echo d; } >>expect &&\n'> <'\tgit add one &&\n'> <'\n'> <'\tgit apply --whitespace=fix patch &&\n'> <'\ttest_cmp one expect\n'> ) } ) (command.Simple words: [{<sed>} {<-e> (SQ <'s/Z//'>)}] redirects: [ (redir op:<Id.Redir_Great '>'> loc:(redir_loc.Fd fd:1) arg:{<one>}) (redir op: <Id.Redir_DLess '<<'> loc: (redir_loc.Fd fd:0) arg: (redir_param.HereDoc here_begin: {<EOF>} here_end_span_id: 1245 stdin_parts: [<'a\n'> <'b\n'> <'c\n'> <'\t\t Z\n'>] ) ) ] do_fork: T ) (C {<test_expect_success>} {(SQ <'same, but with the --ignore-space-option'>)} { (SQ <'\n'> <'\tgit add one &&\n'> <'\techo d >>one &&\n'> <'\tcp one expect &&\n'> <'\tgit diff -- one >patch &&\n'> <'\t{ echo a; echo b; echo c; } >one &&\n'> <'\tgit add one &&\n'> <'\n'> <'\tgit checkout-index -f one &&\n'> <'\tgit apply --ignore-space-change --whitespace=fix patch &&\n'> <'\ttest_cmp one expect\n'> ) } ) (C {<test_expect_success>} {(SQ <'same, but with CR-LF line endings && cr-at-eol set'>)} { (SQ <'\n'> <'\tgit config core.whitespace cr-at-eol &&\n'> <'\tprintf "a\\r\\n" >one &&\n'> <'\tprintf "b\\r\\n" >>one &&\n'> <'\tprintf "c\\r\\n" >>one &&\n'> <'\tcp one save-one &&\n'> <'\tprintf " \\r\\n" >>one &&\n'> <'\tgit add one &&\n'> <'\tprintf "d\\r\\n" >>one &&\n'> <'\tcp one expect &&\n'> <'\tgit diff -- one >patch &&\n'> <'\tmv save-one one &&\n'> <'\n'> <'\tgit apply --ignore-space-change --whitespace=fix patch &&\n'> <'\ttest_cmp one expect\n'> ) } ) (C {<test_expect_success>} {(SQ <'same, but with CR-LF line endings && cr-at-eol unset'>)} { (SQ <'\n'> <'\tgit config --unset core.whitespace &&\n'> <'\tprintf "a\\r\\n" >one &&\n'> <'\tprintf "b\\r\\n" >>one &&\n'> <'\tprintf "c\\r\\n" >>one &&\n'> <'\tcp one save-one &&\n'> <'\tprintf " \\r\\n" >>one &&\n'> <'\tgit add one &&\n'> <'\tcp one expect &&\n'> <'\tprintf "d\\r\\n" >>one &&\n'> <'\tgit diff -- one >patch &&\n'> <'\tmv save-one one &&\n'> <'\techo d >>expect &&\n'> <'\n'> <'\tgit apply --ignore-space-change --whitespace=fix patch &&\n'> <'\ttest_cmp one expect\n'> ) } ) (C {<test_expect_success>} {(SQ <'whitespace=fix to expand'>)} { (SQ <'\n'> <'\tqz_to_tab_space >preimage <<-\\EOF &&\n'> <'\tQQa\n'> <'\tQQb\n'> <'\tQQc\n'> <'\tZZZZZZZZZZZZZZZZd\n'> <'\tQQe\n'> <'\tQQf\n'> <'\tQQg\n'> <'\tEOF\n'> <'\tqz_to_tab_space >patch <<-\\EOF &&\n'> <'\tdiff --git a/preimage b/preimage\n'> <'\t--- a/preimage\n'> <'\t+++ b/preimage\n'> <'\t@@ -1,7 +1,6 @@\n'> <'\t QQa\n'> <'\t QQb\n'> <'\t QQc\n'> <'\t-QQd\n'> <'\t QQe\n'> <'\t QQf\n'> <'\t QQg\n'> <'\tEOF\n'> <'\tgit -c core.whitespace=tab-in-indent apply --whitespace=fix patch\n'> ) } ) (C {<test_expect_success>} {(SQ <'whitespace check skipped for excluded paths'>)} { (SQ <'\n'> <'\tgit config core.whitespace blank-at-eol &&\n'> <'\t>used &&\n'> <'\t>unused &&\n'> <'\tgit add used unused &&\n'> <'\techo "used" >used &&\n'> <'\techo "unused " >unused &&\n'> <'\tgit diff-files -p used unused >patch &&\n'> <'\tgit apply --include=used --stat --whitespace=error <patch\n'> ) } ) (C {<test_done>}) ] )