(command.CommandList children: [ (command.Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (lhs_expr.LhsName name:test_description) op: Equal rhs: {(SQ <'core.whitespace rules and git apply'>)} ) ] ) (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: 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') ] ) ] ) ] ) ) (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 ) ] ) ] ) ) (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_DollarName '$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) 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 '$('> ) } ) ] ) (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) op: Equal rhs: {($ VSub_DollarName '$fixed_cnt')} ) ] ) ] ) (case_arm pat_list: [{(Lit_Other '?') (Lit_Other '*')}] action: [ (command.Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (lhs_expr.LhsName name:expect_cnt) 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 '$('> ) } ) ] ) ] ) ] ) (command.AndOr ops: [Op_DPipe] children: [ (C {(test)} {($ VSub_DollarName '$fixed_cnt')} {(-eq)} {($ VSub_DollarName '$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) op:Equal rhs:{(0)})] ) ] ) (case_arm pat_list: [{(Lit_Other '?') (Lit_Other '*')}] action: [ (command.Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (lhs_expr.LhsName name:expect_cnt) 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 '$('> ) } ) ] ) ] ) ] ) (command.AndOr ops: [Op_DPipe] children: [ (C {(test)} {($ VSub_DollarName '$fixed_cnt')} {(-eq)} {($ VSub_DollarName '$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)})] ) ] ) ) (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_DollarName '$t'))} arms: [ (case_arm pat_list: [{(SQ )}] action: [ (command.Assignment keyword: Assign_None pairs: [(assign_pair lhs:(lhs_expr.LhsName name:tt) op:Equal rhs:{(SQ <'!'>)})] ) ] ) (case_arm pat_list: [{(Lit_Other '*')}] action: [ (command.Assignment keyword: Assign_None pairs: [(assign_pair lhs:(lhs_expr.LhsName name:tt) op:Equal rhs:(word.EmptyWord))] ) ] ) ] ) (command.ForEach iter_name: s iter_words: [{(-)} {(SQ )}] do_arg_iter: F body: (command.DoGroup children: [ (command.Case to_match: {(DQ ($ VSub_DollarName '$s'))} arms: [ (case_arm pat_list: [{(SQ )}] action: [ (command.Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (lhs_expr.LhsName name:ts) op: Equal rhs: {(SQ <'@'>)} ) ] ) ] ) (case_arm pat_list: [{(Lit_Other '*')}] action: [ (command.Assignment keyword: Assign_None pairs: [(assign_pair lhs:(lhs_expr.LhsName name:ts) op:Equal rhs:(word.EmptyWord))] ) ] ) ] ) (command.ForEach iter_name: i iter_words: [{(-)} {(SQ )}] do_arg_iter: F body: (command.DoGroup children: [ (command.Case to_match: {(DQ ($ VSub_DollarName '$i'))} arms: [ (case_arm pat_list: [{(SQ )}] action: [ (command.Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (lhs_expr.LhsName name:ti) op: Equal rhs: {(SQ <'#'>)} ) (assign_pair lhs: (lhs_expr.LhsName name:ti16) op: Equal rhs: {(SQ <'='>)} ) ] ) ] ) (case_arm pat_list: [{(Lit_Other '*')}] action: [ (command.Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (lhs_expr.LhsName name:ti) op: Equal rhs: (word.EmptyWord) ) (assign_pair lhs: (lhs_expr.LhsName name:ti16) op: Equal rhs: (word.EmptyWord) ) ] ) ] ) ] ) (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_DollarName '$h') ($ VSub_DollarName '$i'))} {(Lit_Other ']')} ) (command.ControlFlow token: <ControlFlow_Continue continue> ) ] ) (command.Case to_match: {(DQ ($ VSub_DollarName '$h'))} arms: [ (case_arm pat_list: [{(SQ )}] action: [ (command.Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (lhs_expr.LhsName name:th) op: Equal rhs: {(SQ <'%'>)} ) ] ) ] ) (case_arm pat_list: [{(Lit_Other '*')}] action: [ (command.Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (lhs_expr.LhsName name:th) op: Equal rhs: (word.EmptyWord) ) ] ) ] ) ] ) (command.Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (lhs_expr.LhsName name:rule) 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) } ) ] ) (C {(rm)} {(-f)} {(.gitattributes)}) (C {(test_expect_success)} {(DQ ('rule=') ($ 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=') ($ 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=') ($ 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=') ($ 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.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: 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') ] ) ] ) ] ) ) (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: 1204 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: 1245 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)}) ] )