git-svn dcommits messages not in UTF-8 charset to mod_dav_svn?
Greetings,
I had tried to use git cvsimport and git svn to transfer a CVS repository (I have access to it) to an SVN repository (where I don't have access to the repo, so I cannot use cvs2svn or similar).
The problem is that the CVS repo had non-UTF-8 commit log messages, and I didn't bother to convert them to UTF-8. However, SVN insists on encoding filenames and log messages in UTF-8.
"git svn dcommit" (which uses the SVN Perl bindings under the hood) happily committed such a non-UTF-8 message and br0ke the repo. The actual reason is that the SVN server (https://...) is now wedged, as in:
$ svn log -r130 svn: REPORT of '/repos/!svn/bc/130': 200 OK (https://svn-serv...de)
$ svn --xml log -r130 2>/dev/null [stdout:] <?xml version="1.0"?> <log> [stderr:] svn: REPORT of '/repos/!svn/bc/130': 200 OK (https://svn-serv...de)
$ svn propget --revprop svn:log -r130 https://svn-serv...de/path/ aktuelle version (disclaimer) kopf und fu?\223zeilen etc.
While mod_dav_svn arguably shouldn't accept b0rked messages, git-svn shouldn't attempt to commit them either. It seems that the svn command line utilities validate the message format by themselves, and apparently the svn server module (likely mod_dav_svn - or are there others?) does not.
So, could
a) git-svn be modified to refuse dcommiting non-UTF-8 messages?
b) mod_dav_svn be modified to refuse commits/propedits/propsets with non-UTF-8 messages?
I'm sorry to say I don't have information how the SVN server is configured and which version it's running.
Thanks.
Signature · 1 line
Matthias Andree
Quoted 14 lines · Matthias Andree
Greetings,
I had tried to use git cvsimport and git svn to transfer a CVS repository (I have access to it) to an SVN repository (where I don't have access to the repo, so I cannot use cvs2svn or similar).
The problem is that the CVS repo had non-UTF-8 commit log messages, and I didn't bother to convert them to UTF-8. However, SVN insists on encoding filenames and log messages in UTF-8.
"git svn dcommit" (which uses the SVN Perl bindings under the hood) happily committed such a non-UTF-8 message and br0ke the repo. The actual reason is that the SVN server (https://...) is now wedged, as in:
Quoted 5 lines
While
mod_dav_svnarguably shouldn't accept b0rked messages, git-svn shouldn't attempt to commit them either. It seems that the svn command line utilities validate the message format by themselves, and apparently the svn server module (likelymod_dav_svn- or are there others?) does not.
This was partially fixed in commit 16fc08e2d86dad152194829d21bc55b2ef0c8fb1. You just need to manually specify the i18n.commitencoding in your .git/config
Quoted 2 lines
So, could
a) git-svn be modified to refuse dcommiting non-UTF-8 messages?
On the way is a patch that makes git-svn refuse to dcommit messages that are malformed UTF-8 and tell the user about i18n.commitencoding.
Thanks for reminding me
Signature · 1 line
Eric Wong
PATCH 1/1 git-svn: refuse to dcommit non-UTF-8 messages
...without i18n.commitencoding set in the config.
SVN tries to store all commit messages in UTF-8, however it is up to the job of the clients to enforce this rule. SVN servers themselves do not always enforce this; allowing clients to commit malformed UTF-8 messages and break repositories.
So git-svn will enforce this and tell the user to set i18n.commitencoding when a git commit is is not in UTF-8.
---
Also pushed to git://git.bogomips.org/git-svn.git
git-svn.perl | 17 ++++++++-- t/t9139-git-svn-non-utf8-commitencoding.sh | 47 ++++++++++++++++++++++++++++ 2 files changed, 61 insertions(+), 3 deletions(-) create mode 100755 t/t9139-git-svn-non-utf8-commitencoding.sh
git-svn.perl +14 -3
@@ -1178,16 +1178,27 @@ sub get_commit_entry { } rename $commit_editmsg, $commit_msg or croak $!; { + require Encode; # SVN requires messages to be UTF-8 when entering the repo local $/; open $log_fh, '<', $commit_msg or croak $!; binmode $log_fh; chomp($log_entry{log} = <$log_fh>); - if (my $enc = Git::config('i18n.commitencoding')) { - require Encode; - Encode::from_to($log_entry{log}, $enc, 'UTF-8'); + my $enc = Git::config('i18n.commitencoding') || 'UTF-8'; + my $msg = $log_entry{log}; + + eval { $msg = Encode::decode($enc, $msg, 1) }; + if ($@) { + die "Could not decode as $enc:\n", $msg, + "\nPerhaps you need to set i18n.commitencoding\n"; } + + eval { $msg = Encode::encode('UTF-8', $msg, 1) }; + die "Could not encode as UTF-8:\n$msg\n" if $@; + + $log_entry{log} = $msg; + close $log_fh or croak $!; } unlink $commit_msg;
t/t9139-git-svn-non-utf8-commitencoding.sh new file +47 -0
47 lines not on this page · raw message
Signature · 1 line
Eric Wong
Re: [PATCH] git-svn: refuse to dcommit non-UTF-8 messages
Quoted 1 line · Eric Wong
t/t9139-git-svn-non-utf8-commitencoding.sh | 47 ++++++++++++++++++++++++++++
Hmm.
t/t9139-git-svn-non-utf8-commitencoding.sh line 7
Quoted 5 lines
t/t9139-git-svn-non-utf8-commitencoding.sh new file +5
-0+# Copyright (c) 2009 Eric Wong + +test_description='git svn refuses to dcommit non-UTF8 messages' + +. ./lib-git-svn.sh
This passes when merged to 'master', but together with bc/old-iconv branch cooking in 'next' it breaks.
Re: [PATCH] git-svn: refuse to dcommit non-UTF-8 messages
Quoted 6 lines · Junio C Hamano
Quoted 1 line · Eric Wong
t/t9139-git-svn-non-utf8-commitencoding.sh | 47 ++++++++++++++++++++++++++++Hmm.
Quoted 8 lines
t/t9139-git-svn-non-utf8-commitencoding.sh line 7
Quoted 5 lines
t/t9139-git-svn-non-utf8-commitencoding.sh new file +5
-0+# Copyright (c) 2009 Eric Wong + +test_description='git svn refuses to dcommit non-UTF8 messages' + +. ./lib-git-svn.shThis passes when merged to 'master', but together with bc/old-iconv branch cooking in 'next' it breaks.
Yeah, it's the second for loop which accesses the files in t/t3900/. bc/old-iconv replaces each occurrence of ISO-8859-1 with ISO8859-1 and EUCJP with eucJP since old Solaris didn't know both names and modern platforms handle either name. The text files in t/t3900/ were renamed accordingly.
It would be nice to use these older names here too, even though I won't be able to test it since svn is not installed on the older platforms I have access to.
-brandon
PATCH 1/1 t9139 uses ancient, backwards-compatible iconv names
This is needed to work with 5ae93dfdccfe9457bdb1f54b33c76359f6c3b861:
t3900: use ancient iconv names for backward compatibility
---
Quoted 22 lines · Brandon Casey
Quoted 6 lines · Junio C Hamano
Quoted 1 line · Eric Wong
t/t9139-git-svn-non-utf8-commitencoding.sh | 47 ++++++++++++++++++++++++++++Hmm.
Quoted 8 lines
Review
Quoted 5 lines
(quoted diff) +5
-0+# Copyright (c) 2009 Eric Wong + +test_description='git svn refuses to dcommit non-UTF8 messages' + +. ./lib-git-svn.shThis passes when merged to 'master', but together with bc/old-iconv branch cooking in 'next' it breaks.
Yeah, it's the second for loop which accesses the files in t/t3900/. bc/old-iconv replaces each occurrence of ISO-8859-1 with ISO8859-1 and EUCJP with eucJP since old Solaris didn't know both names and modern platforms handle either name. The text files in t/t3900/ were renamed accordingly.
Quoted 3 lines
It would be nice to use these older names here too, even though I won't be able to test it since svn is not installed on the older platforms I have access to.
t/t9139-git-svn-non-utf8-commitencoding.sh | 6 +++--- 1 files changed, 3 insertions(+), 3 deletions(-)
t/t9139-git-svn-non-utf8-commitencoding.sh +3 -3
@@ -8,7 +8,7 @@ test_description='git svn refuses to dcommit non-UTF8 messages' # ISO-2022-JP can pass for valid UTF-8, so skipping that in this test -for H in ISO-8859-1 EUCJP +for H in ISO8859-1 eucJP do test_expect_success "$H setup" ' mkdir $H &&
@@ -17,7 +17,7 @@ do ' done -for H in ISO-8859-1 EUCJP +for H in ISO8859-1 eucJP do test_expect_success "$H commit on git side" ' (
@@ -33,7 +33,7 @@ do ' done -for H in ISO-8859-1 EUCJP +for H in ISO8859-1 eucJP do test_expect_success "$H dcommit to svn" ' (
Signature · 1 line
Eric Wong
Re: [PATCH] git-svn: refuse to dcommit non-UTF-8 messages
In reply to Eric WongThanks.