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

[PATCH RFC v2 4/4] t/t0021: Test that conversion changes are detected.

From
Henrik Grubbström (Grubba) <grubba@grubba.org>
Date
Apr 25, 2010, 16:29 UTC
Message-ID
<2be6dfd1358e8eda4d2ebb9b8a763602b46b60d8.1272210580.git.grubba@grubba.org>
In-Reply-To
<cover.1272210580.git.grubba@grubba.org>

Signed-off-by Henrik Grubbström <grubba@grubba.org> --- Thanks to Junio C Hamano for some of the tests.

 t/t0021-conversion.sh |   50 +++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 50 insertions(+), 0 deletions(-)
diff --git a/t/t0021-conversion.sh b/t/t0021-conversion.sh
index 6cb8d60..b6de203 100755
--- a/t/t0021-conversion.sh
+++ b/t/t0021-conversion.sh
@@ -89,4 +89,54 @@ test_expect_success expanded_in_repo '
 	cmp expanded-keywords expected-output
 '
 
+# Check that files that have had their canonical representation
+# changed since being checked in aren't reported as modified
+# directly after being checked out.
+test_expect_success keywords_not_modified '
+	{
+		echo "File with foreign keywords"
+		echo "\$Id\$"
+		echo "\$Id: NoTerminatingSymbol"
+		echo "\$Id: Foreign Commit With Spaces \$"
+		echo "\$Id: GitCommitId \$"
+		echo "\$Id: NoTerminatingSymbolAtEOF"
+	} > expanded-keywords2 &&
+
+	git add expanded-keywords2 &&
+	git commit -m "File with keywords expanded" &&
+
+	echo "expanded-keywords2 ident" >> .gitattributes &&
+
+	rm -f expanded-keywords2 &&
+	git checkout -- expanded-keywords2 &&
+
+	test "x`git status --porcelain -- expanded-keywords2`" = x
+'
+
+# Test detection of CRLF conversion changes CRLF ==> LF.
+test_expect_success crlf_conversion_change_crlf_to_lf '
+	# step 0. a blob with CRLF
+	git init one && cd one &&
+	echo -e "a quick brown fox\015" >kuzu &&
+	git add kuzu && git commit -m kuzu &&
+	# step 1. you want CRLF in work area, LF in repository
+	git config core.autocrlf true &&
+	# step 2. user edit and revert.
+	touch kuzu &&
+	git update-index --refresh
+'
+
+# Test detection of CRLF conversion changes LF ==> CRLF.
+test_expect_success crlf_conversion_change_lf_to_crlf '
+	# step 0 & 1. a project with LF ending
+	git init two && cd two &&
+	echo a quick brown fox >kuzu &&
+	git add kuzu && git commit -m kuzu &&
+	# step 2. you want CRLF in your work area
+	echo -e "a quick brown fox\015" >kuzu &&
+	git config core.autocrlf true &&
+	# step 3. oops, refresh
+	git update-index --refresh
+'
+
 test_done
-- 
1.7.0.4.369.g81e89
Previous: Henrik Grubbström (Grubba)
Message 5 of 5 in “Patches to avoid reporting conversion changes.”
  1. 0/4 Patches to avoid reporting conversion changes.Henrik Grubbström (Grubba), Apr 25, 2010
  2. 1/4 sha1_file: Added index_blob().Henrik Grubbström (Grubba), Apr 25, 2010
  3. 2/4 cache: Added ce_norm_sha1() and related cache_entry fields.Henrik Grubbström (Grubba), Apr 25, 2010
  4. 3/4 cache: Added index extension "NORM".Henrik Grubbström (Grubba), Apr 25, 2010
  5. 4/4 t/t0021: Test that conversion changes are detected.Henrik Grubbström (Grubba), Apr 25, 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.