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

[PATCH 1/2] submodule: Demonstrate failure to add with auto/safecrlf

From
Brad King <brad.king@kitware.com>
Date
Jun 20, 2012, 14:43 UTC
Message-ID
<7b51d857a351dd0d4972b62b5ba52a7df6bfd988.1340202515.git.brad.king@kitware.com>
In-Reply-To
<cover.1340202515.git.brad.king@kitware.com>

If 'core.autocrlf' and 'core.safecrlf' are both enabled then 'git submodule add' fails with an error such as

 fatal: LF would be replaced by CRLF in .gitmodules
 Failed to register submodule 'submod'

because it generates a '.gitmodules' file with LF newlines that are rejected by 'git add' under this configuration. Demonstrate this known breakage with a new test in t7400-submodule-basic covering the case.

Signed-off-by: Brad King <brad.king@kitware.com>
---
 t/t7400-submodule-basic.sh |   13 +++++++++++++
 1 file changed, 13 insertions(+)
diff --git a/t/t7400-submodule-basic.sh b/t/t7400-submodule-basic.sh
index 81827e6..5eaeb04 100755
--- a/t/t7400-submodule-basic.sh
+++ b/t/t7400-submodule-basic.sh
@@ -43,6 +43,7 @@ test_expect_success 'setup - hide init subdirectory' '
 
 test_expect_success 'setup - repository to add submodules to' '
 	git init addtest &&
+	git init addtest-crlf &&
 	git init addtest-ignore
 '
 
@@ -98,6 +99,18 @@ test_expect_success 'submodule add' '
 	test_cmp empty untracked
 '
 
+test_expect_failure 'submodule add with core.autocrlf and core.safecrlf' '
+	(
+		cd addtest-crlf &&
+		git config core.autocrlf true &&
+		git config core.safecrlf true &&
+		git submodule add "$submodurl" submod &&
+		echo ".gitmodules" >expect &&
+		git ls-files -- .gitmodules >actual &&
+		test_cmp expect actual
+	)
+'
+
 test_expect_success 'submodule add to .gitignored path fails' '
 	(
 		cd addtest-ignore &&
-- 
1.7.10
Previous: Brad KingNext: Brad King
Message 2 of 12 in “submodule add + autocrlf + safecrlf”
  1. 0/2 submodule add + autocrlf + safecrlfBrad King, Jun 20, 2012
  2. 1/2 submodule: Demonstrate failure to add with auto/safecrlfBrad King, Jun 20, 2012
  3. 2/2 submodule: Tolerate auto/safecrlf when adding .gitmodulesBrad King, Jun 20, 2012
  4. Jens LehmannJun 20, 2012
  5. Brad KingJun 20, 2012
  6. Jens LehmannJun 20, 2012
  7. Jeff KingJun 20, 2012
  8. Junio C HamanoJun 20, 2012
  9. Jens LehmannJun 21, 2012
  10. Junio C HamanoJun 20, 2012
  11. Brad KingJun 20, 2012
  12. Junio C HamanoJun 20, 2012

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.