Thread (26 messages) 26 messages, 5 authors, 2018-01-06

Re: [PATCH 5/5] convert: add support for 'checkout-encoding' attribute

From: Johannes Schindelin <hidden>
Date: 2018-01-05 14:45:18
Subsystem: the rest · Maintainer: Linus Torvalds

Hi,

On Sun, 31 Dec 2017, tboegi@web.de wrote:
quoted hunk ↗ jump to hunk
diff --git a/t/t0028-checkout-encoding.sh b/t/t0028-checkout-encoding.sh
new file mode 100755
index 0000000000..1a329ab933
--- /dev/null
+++ b/t/t0028-checkout-encoding.sh
@@ -0,0 +1,197 @@
+#!/bin/sh
+
+test_description='checkout-encoding conversion via gitattributes'
+
+. ./test-lib.sh
+
+test_expect_success 'setup test repo' '
+
+	text="hallo there!\ncan you read me?" &&
+
+	echo "*.utf16 text checkout-encoding=utf-16" >.gitattributes &&
+
+	printf "$text" >test.utf8.raw &&
+	printf "$text" | iconv -f UTF-8 -t UTF-16 >test.utf16.raw &&
+	cp test.utf16.raw test.utf16 &&
+
+	git add .gitattributes test.utf16 &&
+	git commit -m initial
+'
+
+test_expect_success 'ensure UTF-8 is stored in Git' '
+	git cat-file -p :test.utf16 >test.utf16.git &&
+	test_cmp_bin test.utf8.raw test.utf16.git &&
+	rm test.utf8.raw test.utf16.git
+'
+
+test_expect_success 're-encode to UTF-16 on checkout' '
+	rm test.utf16 &&
+	git checkout test.utf16 &&
+	test_cmp_bin test.utf16.raw test.utf16 &&
This fails here, due to an extra CR in test.utf16. This diff fixes it
(please include it in the next iteration of this patch series):

-- snipsnap --
diff --git a/t/t0028-checkout-encoding.sh b/t/t0028-checkout-encoding.sh
index 1a329ab933b..aaf61bc9d7c 100755
--- a/t/t0028-checkout-encoding.sh
+++ b/t/t0028-checkout-encoding.sh
@@ -6,6 +6,7 @@ test_description='checkout-encoding conversion via
gitattributes'
 
 test_expect_success 'setup test repo' '
 
+	git config core.eol lf &&
 	text="hallo there!\ncan you read me?" &&
 
 	echo "*.utf16 text checkout-encoding=utf-16" >.gitattributes &&
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help