git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH] Add a test for a problem in "rebase --whitespace=fix"

From
Björn Gustavsson <bgustavsson@gmail.com>
Date
Feb 7, 2010, 08:10 UTC
Message-ID
<4B6E7564.7040109@gmail.com>

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
Next: Junio C Hamano
Message 1 of 7 in “Add a test for a problem in "rebase --whitespace=fix"”
  1. Add a test for a problem in "rebase --whitespace=fix"Björn Gustavsson, Feb 7, 2010
  2. Junio C HamanoFeb 7, 2010
  3. Björn GustavssonFeb 7, 2010
  4. Junio C HamanoFeb 8, 2010
  5. Björn GustavssonFeb 8, 2010
  6. Junio C HamanoFeb 9, 2010
  7. Björn GustavssonFeb 10, 2010

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.