Re: [PATCH 2/2] git-send-email: use locale encoding for compose
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Oct 9, 2012, 21:34 UTC
- Message-ID
- <7vehl7e3cs.fsf@alter.siamese.dyndns.org>
- In-Reply-To
- <1349301931-11912-2-git-send-email-krzysiek@podlesie.net>
Krzysztof Mazur <krzysiek@podlesie.net> writes:
Show 38 quoted lines
> The introduction email (--compose option) use UTF-8 as default encoding.
> The current locale encoding is much better default value.
>
> Signed-off-by: Krzysztof Mazur <krzysiek@podlesie.net>
> ---
> git-send-email.perl | 12 +++++++++++-
> 1 file changed, 11 insertions(+), 1 deletion(-)
>
> diff --git a/git-send-email.perl b/git-send-email.perl
> index 107e814..139bb35 100755
> --- a/git-send-email.perl
> +++ b/git-send-email.perl
> @@ -590,6 +590,16 @@ sub get_patch_subject {
> die "No subject line in $fn ?";
> }
>
> +sub locale_encoding {
> + my $encoding = "UTF-8";
> + eval {
> + require I18N::Langinfo;
> + I18N::Langinfo->import(qw(langinfo CODESET));
> + $encoding = langinfo(CODESET());
> + };
> + return $encoding;
> +}
> +
> if ($compose) {
> # Note that this does not need to be secure, but we will make a small
> # effort to have it be unique
> @@ -643,7 +653,7 @@ EOT
> } elsif (/^\n$/) {
> $in_body = 1;
> if (!defined $compose_encoding) {
> - $compose_encoding = "UTF-8";
> + $compose_encoding = locale_encoding();
> }
> if ($need_8bit_cte) {
> print $c2 "MIME-Version: 1.0\n",These two patches make sense in general, but t9001.62 (--compose adds MIME for utf8 body) seems to be broken by it. I didn't check to see if the code is broken, or the test has expecting a wrong behaviour. If the latter, the test needs to be updated to match the improved new world order.
Thanks.