{"thread":{"id":"22942","subject":"[PATCH v4 4/5] t4124: Add additional tests of --whitespace=fix","startedAt":"2010-03-06T14:31:04Z","lastAt":"2010-03-06T14:31:04Z","messageCount":1,"participants":["Björn Gustavsson"],"isPatch":true,"patchVersion":4,"patchTotal":5},"messages":[{"id":"136326","messageId":"4B926728.1060003@gmail.com","threadId":"22942","inReplyTo":null,"subject":"[PATCH v4 4/5] t4124: Add additional tests of --whitespace=fix","fromName":"Björn Gustavsson","fromEmail":"bgustavsson@gmail.com","sentAt":"2010-03-06T14:31:04Z","receivedAt":"2010-03-06T14:31:04Z","isPatch":true,"sender":{"key":"bgustavsson@gmail.com","avatar":"https://avatars.githubusercontent.com/u/74840?v=4"},"body":"Signed-off-by: Björn Gustavsson <bgustavsson@gmail.com>\n---\n t/t4124-apply-ws-rule.sh |  170 ++++++++++++++++++++++++++++++++++++++++++++++\n 1 files changed, 170 insertions(+), 0 deletions(-)\n\ndiff --git a/t/t4124-apply-ws-rule.sh b/t/t4124-apply-ws-rule.sh\nindex ca26397..37bb767 100755\n--- a/t/t4124-apply-ws-rule.sh\n+++ b/t/t4124-apply-ws-rule.sh\n@@ -261,4 +261,174 @@ test_expect_success 'blank but not empty at EOF' '\n \tgrep \"new blank line at EOF\" error\n '\n \n+test_expect_success 'applying beyond EOF requires one non-blank context line' '\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+'\n+\n+test_expect_success 'tons of blanks at EOF should not apply' '\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+'\n+\n+test_expect_success 'missing blank line at end with --whitespace=fix' '\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+'\n+\n+test_expect_success 'two missing blank lines at end with --whitespace=fix' '\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+'\n+\n+test_expect_success 'shrink file with tons of missing blanks at end of file' '\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+'\n+\n+test_expect_success 'missing blanks at EOF must only match blank lines' '\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+'\n+\n+sed -e's/Z//' >one <<EOF\n+a\n+b\n+c\n+\t\t      Z\n+EOF\n+\n+test_expect_success 'missing blank line should match context line with spaces' '\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+'\n+\n+sed -e's/Z//' >one <<EOF\n+a\n+b\n+c\n+                      Z\n+EOF\n+\n+test_expect_success 'same, but with the --ignore-space-option' '\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+'\n+\n+test_expect_success 'same, but with CR-LF line endings && cr-at-eol set' '\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+'\n+\n+test_expect_success 'same, but with CR-LF line endings && cr-at-eol unset' '\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+'\n+\n test_done\n-- \n1.7.0\n"}]}