git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] git svn: add an option to recode pathnames
@ 2009-07-29  9:16 Dmitry Statyvka
  2009-07-29 18:59 ` Eric Wong
  0 siblings, 1 reply; 5+ messages in thread
From: Dmitry Statyvka @ 2009-07-29  9:16 UTC (permalink / raw)


Introduce new option 'svn.pathnameenc' that instructs git svn to recode
pathnames to given encoding.  It's useful for windows users and for those
who works in non-utf8 locales, since otherwise they'll have corrupted file
names with non-ascii characters.

Signed-off-by: Dmitry Statyvka <dstatyvka@tmsoft-ltd.kiev.ua>
---
 git-svn.perl |    9 +++++++++
 1 files changed, 9 insertions(+), 0 deletions(-)

diff --git a/git-svn.perl b/git-svn.perl
index ef1d30d..bdd9af0 100755
--- a/git-svn.perl
+++ b/git-svn.perl
@@ -3343,6 +3343,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.pathnameenc');
 	$self;
 }
 
@@ -3426,6 +3427,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";
@@ -3814,6 +3819,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.2.1299.gee46c

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] git svn: add an option to recode pathnames
  2009-07-29  9:16 [PATCH] git svn: add an option to recode pathnames Dmitry Statyvka
@ 2009-07-29 18:59 ` Eric Wong
  2010-07-30  2:30   ` Robert Pollak
  0 siblings, 1 reply; 5+ messages in thread
From: Eric Wong @ 2009-07-29 18:59 UTC (permalink / raw)
  To: Dmitry Statyvka; +Cc: git

Dmitry Statyvka <dstatyvka@tmsoft-ltd.kiev.ua> wrote:
> Introduce new option 'svn.pathnameenc' that instructs git svn to recode
> pathnames to given encoding.  It's useful for windows users and for those
> who works in non-utf8 locales, since otherwise they'll have corrupted file
> names with non-ascii characters.
> 
> Signed-off-by: Dmitry Statyvka <dstatyvka@tmsoft-ltd.kiev.ua>
> ---
>  git-svn.perl |    9 +++++++++
>  1 files changed, 9 insertions(+), 0 deletions(-)
> 
> diff --git a/git-svn.perl b/git-svn.perl
> index ef1d30d..bdd9af0 100755
> --- a/git-svn.perl
> +++ b/git-svn.perl
> @@ -3343,6 +3343,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.pathnameenc');

Hi Dmitry,

Can we use a more consistent name for the user-visible config option?
"svn.pathnameencoding" would be more consistent with the other
encoding-related config options we have.

I'd also like this option documented in the manpage so more people know
about it.

Otherwise the patch looks fine though a testcase would be helpful, too.

Thanks!

-- 
Eric Wong

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] git svn: add an option to recode pathnames
  2009-07-29 18:59 ` Eric Wong
@ 2010-07-30  2:30   ` Robert Pollak
  2010-07-30  7:59     ` Eric Wong
  0 siblings, 1 reply; 5+ messages in thread
From: Robert Pollak @ 2010-07-30  2:30 UTC (permalink / raw)
  To: Eric Wong; +Cc: Dmitry Statyvka, git

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

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] git svn: add an option to recode pathnames
  2010-07-30  2:30   ` Robert Pollak
@ 2010-07-30  7:59     ` Eric Wong
  2010-08-02 10:36       ` Dmitry Statyvka
  0 siblings, 1 reply; 5+ messages in thread
From: Eric Wong @ 2010-07-30  7:59 UTC (permalink / raw)
  To: Robert Pollak; +Cc: Dmitry Statyvka, git

Robert Pollak <robert.pollak@gmail.com> wrote:
> 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.

Thanks Robert!

It looks alright to me and I've acked and pushed it out to
git://git.bogomips.org/git-svn (crediting Dmitry as the author)

If it's not too much trouble, having a test case to ensure it stays
working with future changes would be nice.

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

For addendum changes, the standard we seem to have adopted is
first initials above the Signed-off/Acked-by lines:

>From 3713e2226bcda64513efd537f370ce4d7f767a1e Mon Sep 17 00:00:00 2001
From: Dmitry Statyvka <dstatyvka@tmsoft-ltd.kiev.ua>
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 <dstatyvka@tmsoft-ltd.kiev.ua>
Signed-off-by: Robert Pollak <robert.pollak@gmail.com>
Acked-by: Eric Wong <normalperson@yhbt.net>
---
<snip>
-- 
Eric Wong

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] git svn: add an option to recode pathnames
  2010-07-30  7:59     ` Eric Wong
@ 2010-08-02 10:36       ` Dmitry Statyvka
  0 siblings, 0 replies; 5+ messages in thread
From: Dmitry Statyvka @ 2010-08-02 10:36 UTC (permalink / raw)
  To: Eric Wong; +Cc: Robert Pollak, git

>>>>> "EW" == Eric Wong <normalperson@yhbt.net> writes:
EW> Robert Pollak <robert.pollak@gmail.com> wrote:

[...]

>> 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.
EW> 
EW> Thanks Robert!
EW> 
EW> It looks alright to me and I've acked and pushed it out to
EW> git://git.bogomips.org/git-svn (crediting Dmitry as the author)

Great!  Thank you guys very much!

--
Dmitry Statyvka

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2010-08-02 11:02 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-07-29  9:16 [PATCH] git svn: add an option to recode pathnames Dmitry Statyvka
2009-07-29 18:59 ` Eric Wong
2010-07-30  2:30   ` Robert Pollak
2010-07-30  7:59     ` Eric Wong
2010-08-02 10:36       ` Dmitry Statyvka

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).