Skip to content

Commit

Permalink
git svn: add an option to recode pathnames
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Dmitry Statyvka authored and Eric Wong committed Jul 30, 2010
1 parent 61bf126 commit 3713e22
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
6 changes: 6 additions & 0 deletions Documentation/git-svn.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 9 additions & 0 deletions git-svn.perl
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down Expand Up @@ -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";
Expand Down Expand Up @@ -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 : '');
}

Expand Down

0 comments on commit 3713e22

Please sign in to comment.