Thread (1 message) 1 message, 1 author, 2026-02-18

Re: [PATCH v3 5/5] t6006: don't use iconv(1) without ICONV prereq

From: Junio C Hamano <hidden>
Date: 2026-02-18 17:46:08

Patrick Steinhardt [off-list ref] writes:
Two tests in t6006 depend on the iconv(1) prerequisite to reencode a
commit message. This executable may not even exist though in case the
prereq is not set, which will cause the tests to fail.

Fix this by using UTF-8 instead when the prereq is not set.
The above makes perfect sense, but would the rest of the test
involving this data need to be adjusted to expect utf-8 instead of
$test_encoding when iconv is not available?
quoted hunk
-iconv -f utf-8 -t $test_encoding > commit-msg <<EOF
-Test printing of complex bodies
+test_expect_success 'setup complex body' '
+	message=$(cat <<-EOF
+	Test printing of complex bodies
 
-This commit message is much longer than the others,
-and it will be encoded in $test_encoding. We should therefore
-include an ISO8859 character: ¡bueno!
-EOF
+	This commit message is much longer than the others,
+	and it will be encoded in $test_encoding. We should therefore
+	include an ISO8859 character: ¡bueno!
+	EOF
+	) &&
Creative use of "cat" only to strip leading.   Otherwise,

	message="Test printing of ...
	...
	include an ISO8859 character: ¡bueno!"

would have sufficed ;-).
quoted hunk
+	if test_have_prereq ICONV
+	then
+		echo "$message" | iconv -f utf-8 -t $test_encoding >commit-msg
+	else
+		echo "$message" >commit-msg
+	fi &&
So we have the message in the file encoded in either utf-8 or
the target encoding.
-test_expect_success 'setup complex body' '
 	git config i18n.commitencoding $test_encoding &&
But we claim unconditionally $test_encoding is used in the commit
object.  This is OK because test_encoding is also set to UTF-8 in the
IONV challenged environment.  Cute.
quoted hunk
@@ -448,7 +456,12 @@ test_expect_success 'setup expected messages (for test %b)' '
 	commit $head2
 	commit $head1
 	EOF
-	iconv -f utf-8 -t $test_encoding expected.utf-8 >expected.ISO8859-1
+	if test_have_prereq ICONV
+	then
+		iconv -f utf-8 -t $test_encoding expected.utf-8 >expected.ISO8859-1
+	else
+		cp expected.utf-8 expected.ISO8859-1
+	fi
 '
 
 test_format complex-body %b <expected.ISO8859-1
And this is the same idea.  It is confiusing that the data has
nothing to do with Latin-1 when iconv is not in use, but things will
even out.  Nice.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help