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

[PATCH] t0020-crlf: test rebase with text conversion and safecrlf

From
Yann Droneaud <ydroneaud@opteya.com>
Date
Jun 21, 2013, 14:15 UTC
Message-ID
<1371824124-4242-1-git-send-email-ydroneaud@opteya.com>
In-Reply-To
<fb20a7d711fdd218f58f1f2090b1c515@meuh.org>
This patch add two tests to reproduce the problems described
in thread "git rebase fail with CRLF conversion"
 <fb20a7d711fdd218f58f1f2090b1c515@meuh.org>
 <http://thread.gmane.org/gmane.comp.version-control.git/228613>
 <http://marc.info/?l=git&m=137182211414404&w=2>
- Add and commit a file with CRLF,
- Add and commit a .gitattributes with text flag for the file,
- Convert CRLF to LF in file, commit the change,
- Rebase the whole on top of another parent
  The rebase currently failed.

This scenario is repeated twice, first with core.safecrlf set to warn, a second time with core.safecrlf set to true.

git diff will also fail when core.safecrlf is set to true and the file is not already converted to LF.

Signed-off-by: Yann Droneaud <ydroneaud@opteya.com>
---
 t/t0020-crlf.sh | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 52 insertions(+)
diff --git a/t/t0020-crlf.sh b/t/t0020-crlf.sh
index 1a8f44c..12147ba 100755
--- a/t/t0020-crlf.sh
+++ b/t/t0020-crlf.sh
@@ -506,4 +506,56 @@ test_expect_success 'New CRLF file gets LF in repo' '
 	test_cmp alllf alllf2
 '
 
+test_expect_success 'Prepare rebase test' '
+	test_config core.autocrlf false &&
+	test_config core.safecrlf warn &&
+	test_config core.eol native &&
+	git branch rebase-initial &&
+	git checkout -b rebase-other rebase-initial &&
+	git commit --allow-empty -m "Another commit" &&
+	git checkout rebase-initial
+'
+
+# git rebase will failed to apply the "normalization" commit
+test_expect_success 'Rebase with core.safecrlf set to warn (default)' '
+	test_config core.autocrlf false &&
+	test_config core.safecrlf warn &&
+	test_config core.eol native &&
+	git checkout -b rebase-warn rebase-initial &&
+	for w in A couple of lines ; do echo $w ; done | append_cr >rebase-warn.txt &&
+	git add rebase-warn.txt && git commit -m "Added raw text" &&
+	echo rebase-warn.txt text >> .gitattributes &&
+	git add .gitattributes && git commit -m "Added .gitattributes" &&
+	git rm --cached rebase-warn.txt && git reset --hard &&
+	git add rebase-warn.txt && git commit -m "Normalized" &&
+	git rebase rebase-other || {
+		git status && git diff &&
+		git add rebase-warn.txt && git rebase --continue ;
+	}
+'
+
+#
+# git rebase will failed to apply the "normalization" commit
+# additionnaly
+# git diff and git add will failed when core.safecrlf is set to true
+#
+test_expect_success 'Rebase with core.safecrlf set to true' '
+	test_config core.autocrlf false &&
+	test_config core.safecrlf true &&
+	test_config core.eol native &&
+	git checkout -b rebase-true rebase-initial &&
+	for w in Another couple of lines ; do echo $w ; done | append_cr >rebase-true.txt &&
+	git add rebase-true.txt && git commit -m "Added raw text" &&
+	echo rebase-true.txt text >> .gitattributes &&
+	git add .gitattributes && git commit -m "Added .gitattributes" &&
+	git diff || git add rebase-true.txt ||
+	for w in Another couple of lines ; do echo $w ; done >rebase-true.txt &&
+	git add rebase-true.txt && git commit -m "Normalized" &&
+	git rebase rebase-other || {
+		git status && git diff || git add rebase-true.txt ||
+		for w in Another couple of lines ; do echo $w ; done >rebase-true.txt &&
+		git add rebase-true.txt && git rebase --continue ;
+	}
+'
+
 test_done
-- 
1.8.2.1
Previous: Yann DroneaudNext: Yann Droneaud
Message 3 of 5 in “git rebase fail with CRLF conversion”
  1. Yann DroneaudJun 21, 2013
  2. Yann DroneaudJun 21, 2013
  3. t0020-crlf: test rebase with text conversion and safecrlfYann Droneaud, Jun 21, 2013
  4. Yann DroneaudJun 21, 2013
  5. Yann DroneaudJun 21, 2013

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.