(command.CommandList children: [ (command.Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (lhs_expr.LhsName name:test_description spids:[12]) op: Equal rhs: {(SQ <'core.whitespace rules and git apply'>)} spids: [12] ) ] spids: [12] ) (C {(.)} {(./test-lib.sh)}) (command.FuncDef name: prepare_test_file body: (command.BraceGroup children: [ (command.SimpleCommand words: [{(sed)} {(-e)} {(DQ ('s/_/ /g'))} {(-e)} {(DQ ('s/>/\t/'))}] redirects: [ (redir.HereDoc op: <Redir_DLessDash '<<-'> fd: 16777215 here_begin: {(word_part.EscapedLiteralPart token:<Lit_EscapedChar '\\E'>) (OF)} here_end_span_id: 95 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') ] ) ] ) ] spids: [28] ) spids: [23 27] ) (command.FuncDef name: apply_patch body: (command.BraceGroup children: [ (command.AndOr ops: [Op_DAmp] children: [ (command.SimpleCommand redirects: [(redir.Redir op:<Redir_Great '>'> fd:16777215 arg_word:{(target)})] ) (command.Pipeline children: [ (command.SimpleCommand words: [ {(sed)} {(-e)} { (DQ ('s|') (Lit_Other '\\') ('([ab]') (Lit_Other '\\') (')/file|') (Lit_Other '\\') ('1/target|') ) } ] redirects: [(redir.Redir op:<Redir_Less '<'> fd:16777215 arg_word:{(patch)})] ) (C {(git)} {(apply)} {(DQ ($ VSub_At '$@'))}) ] negated: F ) ] ) ] spids: [104] ) spids: [99 103] ) (command.FuncDef name: test_fix body: (command.BraceGroup children: [ (command.AndOr ops: [Op_DPipe] children: [ (C {(apply_patch)} {(--whitespace) (Lit_Other '=') (fix)}) (command.ControlFlow token:<ControlFlow_Return return> arg_word:{(1)}) ] ) (command.Pipeline children: [ (C {($ VSub_Name '$DIFF')} {(file)} {(target)}) (command.SimpleCommand words: [{(sed)} {(-n)} {(-e)} {(DQ ('s/^> //p'))}] redirects: [(redir.Redir op:<Redir_Great '>'> fd:16777215 arg_word:{(fixed)})] ) ] negated: F ) (command.Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (lhs_expr.LhsName name:fixed_cnt spids:[201]) op: Equal rhs: { (word_part.CommandSubPart command_list: (command.CommandList children: [ (command.SimpleCommand words: [{(wc)} {(-l)}] redirects: [ (redir.Redir op: <Redir_Less '<'> fd: 16777215 arg_word: {(fixed)} ) ] ) ] ) left_token: <Left_CommandSub '$('> spids: [202 209] ) } spids: [201] ) ] spids: [201] ) (command.Case to_match: {(DQ ($ VSub_Number '$1'))} arms: [ (case_arm pat_list: [{(SQ )}] action: [ (command.Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (lhs_expr.LhsName name:expect_cnt spids:[225]) op: Equal rhs: {($ VSub_Name '$fixed_cnt')} spids: [225] ) ] spids: [225] ) ] spids: [221 223 228 16777215] ) (case_arm pat_list: [{(Lit_Other '?') (Lit_Other '*')}] action: [ (command.Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (lhs_expr.LhsName name:expect_cnt spids:[235]) op: Equal rhs: { (word_part.CommandSubPart command_list: (command.CommandList children: [ (command.Pipeline children: [ (command.SimpleCommand words: [{(grep)} {(DQ ('[') ($ VSub_Number '$1') (']'))}] redirects: [ (redir.Redir op: <Redir_Less '<'> fd: 16777215 arg_word: {(fixed)} ) ] ) (C {(wc)} {(-l)}) ] negated: F ) ] ) left_token: <Left_CommandSub '$('> spids: [236 253] ) } spids: [235] ) ] spids: [235] ) ] spids: [231 233 255 16777215] ) ] spids: [212 218 258] ) (command.AndOr ops: [Op_DPipe] children: [ (C {(test)} {($ VSub_Name '$fixed_cnt')} {(-eq)} {($ VSub_Name '$expect_cnt')}) (command.ControlFlow token:<ControlFlow_Return return> arg_word:{(1)}) ] ) (command.Case to_match: {(DQ ($ VSub_Number '$1'))} arms: [ (case_arm pat_list: [{(SQ )}] action: [ (command.Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (lhs_expr.LhsName name:expect_cnt spids:[294]) op: Equal rhs: {(0)} spids: [294] ) ] spids: [294] ) ] spids: [290 292 297 16777215] ) (case_arm pat_list: [{(Lit_Other '?') (Lit_Other '*')}] action: [ (command.Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (lhs_expr.LhsName name:expect_cnt spids:[304]) op: Equal rhs: { (word_part.CommandSubPart command_list: (command.CommandList children: [ (command.Pipeline children: [ (command.SimpleCommand words: [{(grep)} {(DQ ('[') ($ VSub_Number '$1') (']'))}] redirects: [ (redir.Redir op: <Redir_Less '<'> fd: 16777215 arg_word: {(file)} ) ] ) (C {(wc)} {(-l)}) ] negated: F ) ] ) left_token: <Left_CommandSub '$('> spids: [305 322] ) } spids: [304] ) ] spids: [304] ) ] spids: [300 302 324 16777215] ) ] spids: [281 287 327] ) (command.AndOr ops: [Op_DPipe] children: [ (C {(test)} {($ VSub_Name '$fixed_cnt')} {(-eq)} {($ VSub_Name '$expect_cnt')}) (command.ControlFlow token:<ControlFlow_Return return> arg_word:{(1)}) ] ) (command.SimpleCommand words: [{(git)} {(diff-files)} {(-p)} {(target)}] redirects: [(redir.Redir op:<Redir_Great '>'> fd:16777215 arg_word:{(fixed-patch)})] ) (command.AndOr ops: [Op_DAmp] children: [ (C {(test)} {(-s)} {(fixed-patch)}) (command.ControlFlow token:<ControlFlow_Return return> arg_word:{(0)}) ] ) (command.SimpleCommand redirects: [(redir.Redir op:<Redir_Great '>'> fd:16777215 arg_word:{(target)})] ) (command.SimpleCommand words: [{(git)} {(apply)} {(--whitespace) (Lit_Other '=') (error-all)}] redirects: [(redir.Redir op:<Redir_Less '<'> fd:16777215 arg_word:{(fixed-patch)})] ) ] spids: [149] ) spids: [144 148] ) (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 ($ VSub_Name '$t'))} arms: [ (case_arm pat_list: [{(SQ )}] action: [ (command.Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (lhs_expr.LhsName name:tt spids:[556]) op: Equal rhs: {(SQ <'!'>)} spids: [556] ) ] spids: [556] ) ] spids: [552 554 561 16777215] ) (case_arm pat_list: [{(Lit_Other '*')}] action: [ (command.Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (lhs_expr.LhsName name:tt spids:[566]) op: Equal rhs: (word.EmptyWord) spids: [566] ) ] spids: [566] ) ] spids: [563 564 568 16777215] ) ] spids: [544 550 570] ) (command.ForEach iter_name: s iter_words: [{(-)} {(SQ )}] do_arg_iter: F body: (command.DoGroup children: [ (command.Case to_match: {(DQ ($ VSub_Name '$s'))} arms: [ (case_arm pat_list: [{(SQ )}] action: [ (command.Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (lhs_expr.LhsName name:ts spids:[600]) op: Equal rhs: {(SQ <'@'>)} spids: [600] ) ] spids: [600] ) ] spids: [596 598 605 16777215] ) (case_arm pat_list: [{(Lit_Other '*')}] action: [ (command.Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (lhs_expr.LhsName name:ts spids:[610]) op: Equal rhs: (word.EmptyWord) spids: [610] ) ] spids: [610] ) ] spids: [607 608 612 16777215] ) ] spids: [588 594 614] ) (command.ForEach iter_name: i iter_words: [{(-)} {(SQ )}] do_arg_iter: F body: (command.DoGroup children: [ (command.Case to_match: {(DQ ($ VSub_Name '$i'))} arms: [ (case_arm pat_list: [{(SQ )}] action: [ (command.Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (lhs_expr.LhsName name:ti spids:[644]) op: Equal rhs: {(SQ <'#'>)} spids: [644] ) (assign_pair lhs: (lhs_expr.LhsName name:ti16 spids:[649]) op: Equal rhs: {(SQ <'='>)} spids: [649] ) ] spids: [644] ) ] spids: [640 642 653 16777215] ) (case_arm pat_list: [{(Lit_Other '*')}] action: [ (command.Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (lhs_expr.LhsName name:ti spids:[658]) op: Equal rhs: (word.EmptyWord) spids: [658] ) (assign_pair lhs: (lhs_expr.LhsName name:ti16 spids:[660]) op: Equal rhs: (word.EmptyWord) spids: [660] ) ] spids: [658] ) ] spids: [655 656 662 16777215] ) ] spids: [632 638 664] ) (command.ForEach iter_name: h iter_words: [{(-)} {(SQ )}] do_arg_iter: F body: (command.DoGroup children: [ (command.AndOr ops: [Op_DAmp] children: [ (C {(Lit_Other '[')} {(-z)} {(DQ ($ VSub_Name '$h') ($ VSub_Name '$i'))} {(Lit_Other ']')} ) (command.ControlFlow token: <ControlFlow_Continue continue> ) ] ) (command.Case to_match: {(DQ ($ VSub_Name '$h'))} arms: [ (case_arm pat_list: [{(SQ )}] action: [ (command.Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (lhs_expr.LhsName name:th spids:[710]) op: Equal rhs: {(SQ <'%'>)} spids: [710] ) ] spids: [710] ) ] spids: [706 708 715 16777215] ) (case_arm pat_list: [{(Lit_Other '*')}] action: [ (command.Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (lhs_expr.LhsName name:th spids:[720]) op: Equal rhs: (word.EmptyWord) spids: [720] ) ] spids: [720] ) ] spids: [717 718 722 16777215] ) ] spids: [698 704 724] ) (command.Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (lhs_expr.LhsName name:rule spids:[727]) op: Equal rhs: {(${ VSub_Name t) (trailing) (Lit_Comma ',') (${ VSub_Name s) (space) (Lit_Comma ',') (${ VSub_Name i) (indent) (Lit_Comma ',') (${ VSub_Name h) (tab) } spids: [727] ) ] spids: [727] ) (C {(rm)} {(-f)} {(.gitattributes)}) (C {(test_expect_success)} {(DQ ('rule=') ($ VSub_Name '$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=') ($ VSub_Name '$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=') ($ VSub_Name '$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=') ($ VSub_Name '$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'> ) } ) ] spids: [679 825] ) spids: [672 16777215] ) ] spids: [629 828] ) spids: [622 16777215] ) ] spids: [585 831] ) spids: [578 16777215] ) ] spids: [541 833] ) spids: [535 16777215] ) (command.FuncDef name: create_patch body: (command.BraceGroup children: [ (command.SimpleCommand words: [{(sed)} {(-e)} {(DQ ('s/_/ /'))}] redirects: [ (redir.HereDoc op: <Redir_DLessDash '<<-'> fd: 16777215 here_begin: {(word_part.EscapedLiteralPart token:<Lit_EscapedChar '\\E'>) (OF)} here_end_span_id: 865 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') ] ) ] ) ] spids: [841] ) spids: [836 840] ) (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.SimpleCommand words: [{(sed)} {(-e) (SQ <s/Z//>)}] redirects: [ (redir.Redir op:<Redir_Great '>'> fd:16777215 arg_word:{(one)}) (redir.HereDoc op: <Redir_DLess '<<'> fd: 16777215 here_begin: {(EOF)} here_end_span_id: 1212 stdin_parts: [('a\n') ('b\n') ('c\n') ('\t\t Z\n')] ) ] ) (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.SimpleCommand words: [{(sed)} {(-e) (SQ <s/Z//>)}] redirects: [ (redir.Redir op:<Redir_Great '>'> fd:16777215 arg_word:{(one)}) (redir.HereDoc op: <Redir_DLess '<<'> fd: 16777215 here_begin: {(EOF)} here_end_span_id: 1253 stdin_parts: [('a\n') ('b\n') ('c\n') ('\t\t Z\n')] ) ] ) (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)}) ] )