Subject: SVN.pm produces "Wide character in setenv" warnings

From: Orivej Desh <[email-masked]>
Date: Thu, 19 Feb 2015 06:49:45 +0000

"git svn fetch" causes Perl 5.18 or newer to emit "Wide character in
setenv" warnings when used in combination with svn.authorsfile with
non-ASCII names:

     Wide character in setenv at /usr/lib64/perl5/vendor_perl/5.20.1/Git/SVN.pm line 969.
     Wide character in setenv at /usr/lib64/perl5/vendor_perl/5.20.1/Git/SVN.pm line 973.

I have no taste of Perl so I do not propose this patch for inclusion,
but it fixes this for me.

diff --git a/perl/Git/SVN.pm b/perl/Git/SVN.pm
index d9a52a5..2ffebfe 100644
--- a/perl/Git/SVN.pm
+++ b/perl/Git/SVN.pm
@@ -957,6 +957,17 @@ sub full_pushurl {
 	}
 }
 
+sub utf8_encode {
+	my ($s) = @_;
+	utf8::encode($s);
+	return $s;
+}
+
+sub UENV {
+	my ($var, $val) = @_;
+	$ENV{$var} = utf8_encode($val);
+}
+
 sub set_commit_header_env {
 	my ($log_entry) = @_;
 	my %env;
@@ -966,13 +977,13 @@ sub set_commit_header_env {
 		}
 	}
 
-	$ENV{GIT_AUTHOR_NAME} = $log_entry->{name};
+	UENV("GIT_AUTHOR_NAME", $log_entry->{name});
 	$ENV{GIT_AUTHOR_EMAIL} = $log_entry->{email};
 	$ENV{GIT_AUTHOR_DATE} = $ENV{GIT_COMMITTER_DATE} = $log_entry->{date};
 
-	$ENV{GIT_COMMITTER_NAME} = (defined $log_entry->{commit_name})
+	UENV("GIT_COMMITTER_NAME", (defined $log_entry->{commit_name})
 						? $log_entry->{commit_name}
-						: $log_entry->{name};
+						: $log_entry->{name});
 	$ENV{GIT_COMMITTER_EMAIL} = (defined $log_entry->{commit_email})
 						? $log_entry->{commit_email}
 						: $log_entry->{email};