@@ -223,11 +223,13 @@ BEGIN
223223 " but it is not a directory\n " ;
224224 }
225225 my $git_dir = delete $ENV {GIT_DIR };
226- chomp (my $cdup = command_oneline(qw/ rev-parse --show-cdup/ ));
227- unless (length $cdup ) {
228- die " Already at toplevel, but $git_dir " ,
229- " not found '$cdup '\n " ;
230- }
226+ my $cdup = undef ;
227+ git_cmd_try {
228+ $cdup = command_oneline(qw/ rev-parse --show-cdup/ );
229+ $git_dir = ' .' unless ($cdup );
230+ chomp $cdup if ($cdup );
231+ $cdup = " ." unless ($cdup && length $cdup );
232+ } " Already at toplevel, but $git_dir not found\n " ;
231233 chdir $cdup or die " Unable to chdir up to '$cdup '\n " ;
232234 unless (-d $git_dir ) {
233235 die " $git_dir still not found after going to " ,
@@ -852,7 +854,7 @@ sub escape_uri_only {
852854 my ($uri ) = @_ ;
853855 my @tmp ;
854856 foreach (split m { /} , $uri ) {
855- s / ([^\w .%+-]|%(?![a-fA-F0-9]{2}))/ sprintf("%%%02X",ord($1 ))/ eg ;
857+ s / ([^~ \w .%+-]|%(?![a-fA-F0-9]{2}))/ sprintf("%%%02X",ord($1 ))/ eg ;
856858 push @tmp , $_ ;
857859 }
858860 join (' /' , @tmp );
@@ -1136,9 +1138,19 @@ sub get_commit_entry {
11361138 system ($editor , $commit_editmsg );
11371139 }
11381140 rename $commit_editmsg , $commit_msg or croak $! ;
1139- open $log_fh , ' <' , $commit_msg or croak $! ;
1140- { local $/ ; chomp ($log_entry {log } = <$log_fh >); }
1141- close $log_fh or croak $! ;
1141+ {
1142+ # SVN requires messages to be UTF-8 when entering the repo
1143+ local $/ ;
1144+ open $log_fh , ' <' , $commit_msg or croak $! ;
1145+ binmode $log_fh ;
1146+ chomp ($log_entry {log } = <$log_fh >);
1147+
1148+ if (my $enc = Git::config(' i18n.commitencoding' )) {
1149+ require Encode;
1150+ Encode::from_to($log_entry {log }, $enc , ' UTF-8' );
1151+ }
1152+ close $log_fh or croak $! ;
1153+ }
11421154 unlink $commit_msg ;
11431155 \%log_entry ;
11441156}
@@ -2273,6 +2285,14 @@ sub do_git_commit {
22732285 }
22742286 defined (my $pid = open3(my $msg_fh , my $out_fh , ' >&STDERR' , @exec ))
22752287 or croak $! ;
2288+ binmode $msg_fh ;
2289+
2290+ # we always get UTF-8 from SVN, but we may want our commits in
2291+ # a different encoding.
2292+ if (my $enc = Git::config(' i18n.commitencoding' )) {
2293+ require Encode;
2294+ Encode::from_to($log_entry -> {log }, ' UTF-8' , $enc );
2295+ }
22762296 print $msg_fh $log_entry -> {log } or croak $! ;
22772297 restore_commit_header_env($old_env );
22782298 unless ($self -> no_metadata) {
@@ -3537,7 +3557,7 @@ sub repo_path {
35373557sub url_path {
35383558 my ($self , $path ) = @_ ;
35393559 if ($self -> {url } =~ m # ^https?://# ) {
3540- $path =~ s / ([^a-zA-Z0-9_.-])/ uc sprintf("%%%02x",ord($1 ))/ eg ;
3560+ $path =~ s / ([^~ a-zA-Z0-9_.-])/ uc sprintf("%%%02x",ord($1 ))/ eg ;
35413561 }
35423562 $self -> {url } . ' /' . $self -> repo_path($path );
35433563}
@@ -3890,7 +3910,7 @@ sub escape_uri_only {
38903910 my ($uri ) = @_ ;
38913911 my @tmp ;
38923912 foreach (split m { /} , $uri ) {
3893- s / ([^\w .%+-]|%(?![a-fA-F0-9]{2}))/ sprintf("%%%02X",ord($1 ))/ eg ;
3913+ s / ([^~ \w .%+-]|%(?![a-fA-F0-9]{2}))/ sprintf("%%%02X",ord($1 ))/ eg ;
38943914 push @tmp , $_ ;
38953915 }
38963916 join (' /' , @tmp );
0 commit comments