# [PATCH v4 0/3] git-svn: svn.pathnameencoding for dcommit

5 messages from 2016-02-22 to 2016-02-22. Participants: Eric Wong, Junio C Hamano.
Thread: https://gitlist.dev/t/41463

## Eric Wong, 2016-02-22 02:55

Subject: [PATCH v4 0/3] git-svn: svn.pathnameencoding for dcommit
Message-ID: <1456109711-26866-1-git-send-email-normalperson@yhbt.net>
URL: https://gitlist.dev/e/1456109711-26866-1-git-send-email-normalperson%40yhbt.net

```
The following changes since commit 0233b800c838ddda41db318ee396320b3c21a560:

  Merge branch 'maint' (2016-02-17 10:14:39 -0800)

are available in the git repository at:

  git://bogomips.org/git-svn.git ks/svn-pathnameencoding-4

for you to fetch changes up to 1b42f45255de5844b7fe8d0c60fea74cd5b9f954:

  git-svn: apply "svn.pathnameencoding" before URL encoding (2016-02-22 02:29:36 +0000)

----------------------------------------------------------------
Eric Wong (1):
      git-svn: hoist out utf8 prep from t9129 to lib-git-svn

Kazutoshi Satoda (2):
      git-svn: enable "svn.pathnameencoding" on dcommit
      git-svn: apply "svn.pathnameencoding" before URL encoding

 perl/Git/SVN/Editor.pm                   |  4 +++-
 t/lib-git-svn.sh                         | 12 ++++++++++
 t/t9115-git-svn-dcommit-funky-renames.sh | 40 ++++++++++++++++++++++++++++++--
 t/t9129-git-svn-i18n-commitencoding.sh   | 12 +---------
 4 files changed, 54 insertions(+), 14 deletions(-)

```

## Eric Wong, 2016-02-22 02:55

Subject: [PATCH v4 1/3] git-svn: hoist out utf8 prep from t9129 to lib-git-svn
Message-ID: <1456109711-26866-2-git-send-email-normalperson@yhbt.net>
URL: https://gitlist.dev/e/1456109711-26866-2-git-send-email-normalperson%40yhbt.net
In-Reply-To: <1456109711-26866-1-git-send-email-normalperson@yhbt.net>

```
We will be reusing this in t9115.

Suggested-by: Kazutoshi Satoda <k_satoda@f2.dion.ne.jp>
Signed-off-by: Eric Wong <normalperson@yhbt.net>
---
 t/lib-git-svn.sh                       | 12 ++++++++++++
 t/t9129-git-svn-i18n-commitencoding.sh | 12 +-----------
 2 files changed, 13 insertions(+), 11 deletions(-)

diff --git a/t/lib-git-svn.sh b/t/lib-git-svn.sh
index b0ec12f..6a50b87 100644
--- a/t/lib-git-svn.sh
+++ b/t/lib-git-svn.sh
@@ -186,3 +186,15 @@ start_svnserve () {
              --listen-host 127.0.0.1 &
 }
 
+prepare_a_utf8_locale () {
+	a_utf8_locale=$(locale -a | sed -n '/\.[uU][tT][fF]-*8$/{
+	p
+	q
+}')
+	if test -n "$a_utf8_locale"
+	then
+		test_set_prereq UTF8
+	else
+		say "# UTF-8 locale not available, some tests are skipped"
+	fi
+}
diff --git a/t/t9129-git-svn-i18n-commitencoding.sh b/t/t9129-git-svn-i18n-commitencoding.sh
index 39b6bcb..8dbd647 100755
--- a/t/t9129-git-svn-i18n-commitencoding.sh
+++ b/t/t9129-git-svn-i18n-commitencoding.sh
@@ -14,17 +14,7 @@ compare_git_head_with () {
 	test_cmp current "$1"
 }
 
-a_utf8_locale=$(locale -a | sed -n '/\.[uU][tT][fF]-*8$/{
-	p
-	q
-}')
-
-if test -n "$a_utf8_locale"
-then
-	test_set_prereq UTF8
-else
-	say "# UTF-8 locale not available, some tests are skipped"
-fi
+prepare_a_utf8_locale
 
 compare_svn_head_with () {
 	# extract just the log message and strip out committer info.
-- 
EW

```

## Eric Wong, 2016-02-22 02:55

Subject: [PATCH v4 2/3] git-svn: enable "svn.pathnameencoding" on dcommit
Message-ID: <1456109711-26866-3-git-send-email-normalperson@yhbt.net>
URL: https://gitlist.dev/e/1456109711-26866-3-git-send-email-normalperson%40yhbt.net
In-Reply-To: <1456109711-26866-1-git-send-email-normalperson@yhbt.net>

```
From: Kazutoshi Satoda <k_satoda@f2.dion.ne.jp>

Without the initialization of $self->{pathnameencoding}, conversion in
repo_path() is always skipped as $self->{pathnameencoding} is undefined
even if "svn.pathnameencoding" is configured.

The lack of conversion results in mysterious failure of dcommit (e.g.
"Malformed XML") which happen only when a commit involves a change on
non-ASCII path.

[ew: add test case to t9115,
 squash LC_ALL=$a_utf8_locale export from Kazutoshi for Cygwin]

Signed-off-by: Kazutoshi SATODA <k_satoda@f2.dion.ne.jp>
Signed-off-by: Eric Wong <normalperson@yhbt.net>
---
 perl/Git/SVN/Editor.pm                   |  1 +
 t/t9115-git-svn-dcommit-funky-renames.sh | 25 +++++++++++++++++++++++--
 2 files changed, 24 insertions(+), 2 deletions(-)

diff --git a/perl/Git/SVN/Editor.pm b/perl/Git/SVN/Editor.pm
index c50176e..d9d9bdf 100644
--- a/perl/Git/SVN/Editor.pm
+++ b/perl/Git/SVN/Editor.pm
@@ -41,6 +41,7 @@ sub new {
 	                       "$self->{svn_path}/" : '';
 	$self->{config} = $opts->{config};
 	$self->{mergeinfo} = $opts->{mergeinfo};
+	$self->{pathnameencoding} = Git::config('svn.pathnameencoding');
 	return $self;
 }
 
diff --git a/t/t9115-git-svn-dcommit-funky-renames.sh b/t/t9115-git-svn-dcommit-funky-renames.sh
index 6a48e40..a3927c4 100755
--- a/t/t9115-git-svn-dcommit-funky-renames.sh
+++ b/t/t9115-git-svn-dcommit-funky-renames.sh
@@ -77,11 +77,32 @@ test_expect_success 'make a commit to test rebase' '
 	'
 
 test_expect_success 'git svn rebase works inside a fresh-cloned repository' '
-	cd test-rebase &&
+	(
+		cd test-rebase &&
 		git svn rebase &&
 		test -e test-rebase-main &&
 		test -e test-rebase
-	'
+	)'
+
+# Without this, LC_ALL=C as set in test-lib.sh, and Cygwin converts
+# non-ASCII characters in filenames unexpectedly, and causes errors.
+# https://cygwin.com/cygwin-ug-net/using-specialnames.html#pathnames-specialchars
+# > Some characters are disallowed in filenames on Windows filesystems. ...
+# ...
+# > ... All of the above characters, except for the backslash, are converted
+# > to special UNICODE characters in the range 0xf000 to 0xf0ff (the
+# > "Private use area") when creating or accessing files.
+prepare_a_utf8_locale
+test_expect_success UTF8 'svn.pathnameencoding=cp932 new file on dcommit' '
+	LC_ALL=$a_utf8_locale &&
+	export LC_ALL &&
+	neq=$(printf "\201\202") &&
+	git config svn.pathnameencoding cp932 &&
+	echo neq >"$neq" &&
+	git add "$neq" &&
+	git commit -m "neq" &&
+	git svn dcommit
+'
 
 stop_httpd
 
-- 
EW

```

## Eric Wong, 2016-02-22 02:55

Subject: [PATCH v4 3/3] git-svn: apply "svn.pathnameencoding" before URL encoding
Message-ID: <1456109711-26866-4-git-send-email-normalperson@yhbt.net>
URL: https://gitlist.dev/e/1456109711-26866-4-git-send-email-normalperson%40yhbt.net
In-Reply-To: <1456109711-26866-1-git-send-email-normalperson@yhbt.net>

```
From: Kazutoshi Satoda <k_satoda@f2.dion.ne.jp>

The conversion from "svn.pathnameencoding" to UTF-8 should be applied
first, and then URL encoding should be applied on the resulting UTF-8
path. The reversed order of these transforms (used before this fix)
makes non-UTF-8 URL which causes error from Subversion such as
"Filesystem has no item: '...' path not found" when sending a rename (or
a copy) from non-ASCII path.

[ew: t9115 test case added (requires SVN_HTTPD_PORT set to test),
 squash LC_ALL=$a_utf8_locale export from Kazutoshi for Cygwin]

Signed-off-by: Kazutoshi SATODA <k_satoda@f2.dion.ne.jp>
Signed-off-by: Eric Wong <normalperson@yhbt.net>
---
 perl/Git/SVN/Editor.pm                   |  3 ++-
 t/t9115-git-svn-dcommit-funky-renames.sh | 15 +++++++++++++++
 2 files changed, 17 insertions(+), 1 deletion(-)

diff --git a/perl/Git/SVN/Editor.pm b/perl/Git/SVN/Editor.pm
index d9d9bdf..4c4199a 100644
--- a/perl/Git/SVN/Editor.pm
+++ b/perl/Git/SVN/Editor.pm
@@ -144,11 +144,12 @@ sub repo_path {
 
 sub url_path {
 	my ($self, $path) = @_;
+	$path = $self->repo_path($path);
 	if ($self->{url} =~ m#^https?://#) {
 		# characters are taken from subversion/libsvn_subr/path.c
 		$path =~ s#([^~a-zA-Z0-9_./!$&'()*+,-])#sprintf("%%%02X",ord($1))#eg;
 	}
-	$self->{url} . '/' . $self->repo_path($path);
+	$self->{url} . '/' . $path;
 }
 
 sub rmdirs {
diff --git a/t/t9115-git-svn-dcommit-funky-renames.sh b/t/t9115-git-svn-dcommit-funky-renames.sh
index a3927c4..0990f8d 100755
--- a/t/t9115-git-svn-dcommit-funky-renames.sh
+++ b/t/t9115-git-svn-dcommit-funky-renames.sh
@@ -104,6 +104,21 @@ test_expect_success UTF8 'svn.pathnameencoding=cp932 new file on dcommit' '
 	git svn dcommit
 '
 
+# See the comment on the above test for setting of LC_ALL.
+test_expect_success 'svn.pathnameencoding=cp932 rename on dcommit' '
+	LC_ALL=$a_utf8_locale &&
+	export LC_ALL &&
+	inf=$(printf "\201\207") &&
+	git config svn.pathnameencoding cp932 &&
+	echo inf >"$inf" &&
+	git add "$inf" &&
+	git commit -m "inf" &&
+	git svn dcommit &&
+	git mv "$inf" inf &&
+	git commit -m "inf rename" &&
+	git svn dcommit
+'
+
 stop_httpd
 
 test_done
-- 
EW

```

## Junio C Hamano, 2016-02-22 18:00

Subject: Re: [PATCH v4 0/3] git-svn: svn.pathnameencoding for dcommit
Message-ID: <xmqqr3g47hgx.fsf@gitster.mtv.corp.google.com>
URL: https://gitlist.dev/e/xmqqr3g47hgx.fsf%40gitster.mtv.corp.google.com
In-Reply-To: <1456109711-26866-1-git-send-email-normalperson@yhbt.net>

```
Eric Wong <normalperson@yhbt.net> writes:

> The following changes since commit 0233b800c838ddda41db318ee396320b3c21a560:
>
>   Merge branch 'maint' (2016-02-17 10:14:39 -0800)
>
> are available in the git repository at:
>
>   git://bogomips.org/git-svn.git ks/svn-pathnameencoding-4
>
> for you to fetch changes up to 1b42f45255de5844b7fe8d0c60fea74cd5b9f954:
>
>   git-svn: apply "svn.pathnameencoding" before URL encoding (2016-02-22 02:29:36 +0000)

Thanks.

```
