git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] git svn: add an option to recode pathnames

From
RPRobert Pollak <robert.pollak@gmail.com>
Date
Jul 30, 2010, 02:30 UTC
Message-ID
<4C523935.5070504@gmail.com>
In-Reply-To
<20090729185919.GA13518@dcvr.yhbt.net>

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.

Signed-off-by: Dmitry Statyvka <dstatyvka@tmsoft-ltd.kiev.ua>
[robert.pollak@gmail.com: renamed the option and added manpage documentation]
Signed-off-by: Robert Pollak <robert.pollak@gmail.com>
---
Hello Eric,

since the patch is useful to me, I have made the requested option name change and added some manpage documentation. Please consider applying the patch or give me additional feedback.

This is the first patch I submit on this list, so I hope it's ok.

Best regards, Robert

 Documentation/git-svn.txt |    6 ++++++
 git-svn.perl              |    9 +++++++++
 2 files changed, 15 insertions(+), 0 deletions(-)
diff --git a/Documentation/git-svn.txt b/Documentation/git-svn.txt
index b09bd97..4b84d08 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 c416358..c92238e 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 : '');
 }
-- 
1.6.3.3
Previous: Eric WongNext: Eric Wong
Message 3 of 5 in “git svn: add an option to recode pathnames”
  1. git svn: add an option to recode pathnamesDmitry Statyvka, Jul 29, 2009
  2. Eric WongJul 29, 2009
  3. Robert PollakJul 30, 2010
  4. Eric WongJul 30, 2010
  5. Dmitry StatyvkaAug 2, 2010

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.