{"thread":{"id":"22691","subject":"[RFC/PATCH 3/3] t3417: Add test cases for \"rebase --whitespace=fix\"","startedAt":"2010-02-17T07:03:37Z","lastAt":"2010-02-17T07:03:37Z","messageCount":1,"participants":["Björn Gustavsson"],"isPatch":true,"patchVersion":1,"patchTotal":3},"messages":[{"id":"134841","messageId":"4B7B94C9.1050708@gmail.com","threadId":"22691","inReplyTo":null,"subject":"[RFC/PATCH 3/3] t3417: Add test cases for \"rebase --whitespace=fix\"","fromName":"Björn Gustavsson","fromEmail":"bgustavsson@gmail.com","sentAt":"2010-02-17T07:03:37Z","receivedAt":"2010-02-17T07:03:37Z","isPatch":true,"sender":{"key":"bgustavsson@gmail.com","avatar":"https://avatars.githubusercontent.com/u/74840?v=4"},"body":"The command \"git rebase --whitespace=fix HEAD~<N>\" is supposed to\nonly clean up trailing whitespace, and the expectation is that it\ncannot fail.\n\nUnfortunately, if one commit adds a blank line at the end of a file\nand a subsequent commit adds more non-blank lines after the blank\nline, \"git apply\" (used indirectly by \"git rebase\") will fail to apply\nthe patch of the second commit.\n\nSigned-off-by: Björn Gustavsson <bgustavsson@gmail.com>\n---\n t/t3417-rebase-whitespace-fix.sh |  126 ++++++++++++++++++++++++++++++++++++++\n 1 files changed, 126 insertions(+), 0 deletions(-)\n create mode 100755 t/t3417-rebase-whitespace-fix.sh\n\ndiff --git a/t/t3417-rebase-whitespace-fix.sh b/t/t3417-rebase-whitespace-fix.sh\nnew file mode 100755\nindex 0000000..417d109\n--- /dev/null\n+++ b/t/t3417-rebase-whitespace-fix.sh\n@@ -0,0 +1,126 @@\n+#!/bin/sh\n+\n+test_description='git rebase --whitespace=fix\n+\n+This test runs git rebase --whitespace=fix and make sure that it works.\n+'\n+\n+. ./test-lib.sh\n+\n+# prepare initial revision of \"file\" with a blank line at the end\n+cat >file <<EOF\n+a\n+b\n+c\n+\n+EOF\n+\n+# expected contents in \"file\" after rebase\n+cat >expect-first <<EOF\n+a\n+b\n+c\n+EOF\n+\n+# prepare second revision of \"file\"\n+cat >second <<EOF\n+a\n+b\n+c\n+\n+d\n+e\n+f\n+\n+\n+\n+\n+EOF\n+\n+# expected contents in second revision after rebase\n+cat >expect-second <<EOF\n+a\n+b\n+c\n+\n+d\n+e\n+f\n+EOF\n+\n+test_expect_success 'blank line at end of file; extend at end of file' '\n+\tgit commit --allow-empty -m \"Initial empty commit\" &&\n+\tgit add file && git commit -m first &&\n+\tmv second file &&\n+\tgit add file &&\tgit commit -m second &&\n+\tgit rebase --whitespace=fix HEAD^^ &&\n+\tgit diff --exit-code HEAD^:file expect-first &&\n+\ttest_cmp file expect-second\n+'\n+\n+# prepare third revision of \"file\"\n+sed -e's/Z//' >third <<EOF\n+a\n+b\n+c\n+\n+d\n+e\n+f\n+    Z\n+ Z\n+h\n+i\n+j\n+k\n+l\n+EOF\n+\n+sed -e's/ //g' <third >expect-third\n+\n+test_expect_success 'two blanks line at end of file; extend at end of file' '\n+\tcp third file && git add file && git commit -m third &&\n+\tgit rebase --whitespace=fix HEAD^^ &&\n+\tgit diff --exit-code HEAD^:file expect-second &&\n+\ttest_cmp file expect-third\n+'\n+\n+test_expect_success 'same, but do not remove trailing spaces' '\n+\tgit config core.whitespace \"-blank-at-eol\" &&\n+\tgit reset --hard HEAD^ &&\n+\tcp third file && git add file && git commit -m third &&\n+\tgit rebase --whitespace=fix HEAD^^\n+\tgit diff --exit-code HEAD^:file expect-second &&\n+\ttest_cmp file third\n+'\n+\n+sed -e's/Z//' >beginning <<EOF\n+a\n+                    Z\n+       Z\n+EOF\n+\n+cat >expect-beginning <<EOF\n+a\n+\n+\n+1\n+2\n+3\n+4\n+5\n+EOF\n+\n+test_expect_success 'at beginning of file' '\n+\tgit config core.whitespace \"blank-at-eol\" &&\n+\tcp beginning file &&\n+\tgit commit -m beginning file &&\n+\tfor i in 1 2 3 4 5; do\n+\t\techo $i\n+\tdone >> file &&\n+\tgit commit -m more file\t&&\n+\tgit rebase --whitespace=fix HEAD^^ &&\n+\ttest_cmp file expect-beginning\n+'\n+\n+test_done\n-- \n1.7.0\n"}]}