git svn: add an option to recode pathnames
Introduce a new option 'svn.pathnameencoding' that instructs git svn to recode pathnames to a given encoding. It can be used by windows users and by those who work in non-utf8 locales to avoid corrupted file names with non-ascii characters. [rp: renamed the option and added manpage documentation] Signed-off-by: Dmitry Statyvka <dstatyvka@tmsoft-ltd.kiev.ua> Signed-off-by: Robert Pollak <robert.pollak@gmail.com> Acked-by: Eric Wong <normalperson@yhbt.net>
Dmitry Statyvka committed
Jul 30, 2010 at 04:30 UTC
3713e2226bcda64513efd537f370ce4d7f767a1e
2 files changed
+15
Documentation/git-svn.txt
+6
@@ -646,6 +646,12 @@ svn.brokenSymlinkWorkaround::
646
revision fetched. If unset, 'git svn' assumes this option to
647
be "true".
648
649
+svn.pathnameencoding::
650
+ This instructs git svn to recode pathnames to a given encoding.
651
+ It can be used by windows users and by those who work in non-utf8
652
+ locales to avoid corrupted file names with non-ASCII characters.
653
+ Valid encodings are the ones supported by Perl's Encode module.
654
+
655
Since the noMetadata, rewriteRoot, rewriteUUID, useSvnsyncProps and useSvmProps
656
options all affect the metadata generated and used by 'git svn'; they
657
*must* be set in the configuration file before any history is imported
git-svn.perl
+9
@@ -4050,6 +4050,7 @@ sub new {
4050
$self->{absent_dir} = {};
4051
$self->{absent_file} = {};
4052
$self->{gii} = $git_svn->tmp_index_do(sub { Git::IndexInfo->new });
4053
+ $self->{pathnameencoding} = Git::config('svn.pathnameencoding');
4054
$self;
4055
}
4056
@@ -4133,6 +4134,10 @@ sub open_directory {
4134
4135
sub git_path {
4136
my ($self, $path) = @_;
4137
+ if (my $enc = $self->{pathnameencoding}) {
4138
+ require Encode;
4139
+ Encode::from_to($path, 'UTF-8', $enc);
4140
+ }
4141
if ($self->{path_strip}) {
4142
$path =~ s!$self->{path_strip}!! or
4143
die "Failed to strip path '$path' ($self->{path_strip})\n";
@@ -4521,6 +4526,10 @@ sub split_path {
4526
4527
sub repo_path {
4528
my ($self, $path) = @_;
4529
+ if (my $enc = $self->{pathnameencoding}) {
4530
+ require Encode;
4531
+ Encode::from_to($path, $enc, 'UTF-8');
4532
+ }
4533
$self->{path_prefix}.(defined $path ? $path : '');
4534
}
4535