From 3713e2226bcda64513efd537f370ce4d7f767a1e Mon Sep 17 00:00:00 2001 From: Dmitry Statyvka Date: Fri, 30 Jul 2010 04:30:13 +0200 Subject: [PATCH] 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 Signed-off-by: Robert Pollak Acked-by: Eric Wong --- Documentation/git-svn.txt | 6 ++++++ git-svn.perl | 9 +++++++++ 2 files changed, 15 insertions(+) diff --git a/Documentation/git-svn.txt b/Documentation/git-svn.txt index b09bd9761f..4b84d08fc8 100644 --- a/Documentation/git-svn.txt +++ b/Documentation/git-svn.txt @@ -646,6 +646,12 @@ svn.brokenSymlinkWorkaround:: revision fetched. If unset, 'git svn' assumes this option to be "true". +svn.pathnameencoding:: + This 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. + Valid encodings are the ones supported by Perl's Encode module. + Since the noMetadata, rewriteRoot, rewriteUUID, useSvnsyncProps and useSvmProps options all affect the metadata generated and used by 'git svn'; they *must* be set in the configuration file before any history is imported diff --git a/git-svn.perl b/git-svn.perl index c4163584a9..c92238ece2 100755 --- a/git-svn.perl +++ b/git-svn.perl @@ -4050,6 +4050,7 @@ sub new { $self->{absent_dir} = {}; $self->{absent_file} = {}; $self->{gii} = $git_svn->tmp_index_do(sub { Git::IndexInfo->new }); + $self->{pathnameencoding} = Git::config('svn.pathnameencoding'); $self; } @@ -4133,6 +4134,10 @@ sub open_directory { sub git_path { my ($self, $path) = @_; + if (my $enc = $self->{pathnameencoding}) { + require Encode; + Encode::from_to($path, 'UTF-8', $enc); + } if ($self->{path_strip}) { $path =~ s!$self->{path_strip}!! or die "Failed to strip path '$path' ($self->{path_strip})\n"; @@ -4521,6 +4526,10 @@ sub split_path { sub repo_path { my ($self, $path) = @_; + if (my $enc = $self->{pathnameencoding}) { + require Encode; + Encode::from_to($path, $enc, 'UTF-8'); + } $self->{path_prefix}.(defined $path ? $path : ''); }