git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Add a test for a problem in "rebase --whitespace=fix"
@ 2010-02-07  8:10 Björn Gustavsson
  2010-02-07 18:38 ` Junio C Hamano
  0 siblings, 1 reply; 7+ messages in thread
From: Björn Gustavsson @ 2010-02-07  8:10 UTC (permalink / raw)
  To: git; +Cc: Junio C Hamano

The command "git rebase --whitespace=fix HEAD~<N>" is supposed to
only clean up trailing whitespace, and the expectation is that it
cannot fail.

Unfortunately, if one commit adds a blank line at the end of a file
and a subsequent commit adds more non-blank lines after the blank
line, "git apply" (used indirectly by "git rebase") will fail to apply
the patch of the second commit.

Signed-off-by: Björn Gustavsson <bgustavsson@gmail.com>
---
 t/t3417-rebase-whitespace-fix.sh |   45 ++++++++++++++++++++++++++++++++++++++
 1 files changed, 45 insertions(+), 0 deletions(-)
 create mode 100755 t/t3417-rebase-whitespace-fix.sh

diff --git a/t/t3417-rebase-whitespace-fix.sh b/t/t3417-rebase-whitespace-fix.sh
new file mode 100755
index 0000000..55cbce7
--- /dev/null
+++ b/t/t3417-rebase-whitespace-fix.sh
@@ -0,0 +1,45 @@
+#!/bin/sh
+
+test_description='git rebase --whitespace=fix
+
+This test runs git rebase --whitespace=fix and make sure that it works.
+'
+
+. ./test-lib.sh
+
+# prepare initial revision of "file" with a blank line at the end
+cat >file <<EOF
+a
+b
+c
+
+EOF
+
+# expected contents in "file" after rebase
+cat >expect <<EOF
+a
+b
+c
+EOF
+
+# prepare second revision of "file"
+cat >second <<EOF
+a
+b
+c
+
+d
+e
+f
+EOF
+
+test_expect_failure 'blanks line at end of file; extend at end of file' '
+	git commit --allow-empty -m "Initial empty commit" &&
+	git add file && git commit -m first &&
+	mv second file &&
+	git add file &&	git commit -m second &&
+	git rebase --whitespace=fix HEAD^^ &&
+	git diff --exit-code HEAD^:file expect
+'
+
+test_done
-- 
1.7.0.rc1.46.g04bf4

^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2010-02-10 20:20 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-02-07  8:10 [PATCH] Add a test for a problem in "rebase --whitespace=fix" Björn Gustavsson
2010-02-07 18:38 ` Junio C Hamano
2010-02-07 22:44   ` Björn Gustavsson
2010-02-08  0:15     ` Junio C Hamano
2010-02-08  7:37       ` Björn Gustavsson
2010-02-09 21:58         ` Junio C Hamano
2010-02-10 20:20           ` Björn Gustavsson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).