git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] svn-git: Use binmode for reading/writing binary rev maps
@ 2008-04-18 13:12 Michael Weber
  2008-04-22 23:21 ` Eric Wong
  0 siblings, 1 reply; 2+ messages in thread
From: Michael Weber @ 2008-04-18 13:12 UTC (permalink / raw)
  To: git

Otherwise, there is a possible interaction with UTF-8 locales in
combination with PERL_UNICODE, resulting in "inconsistent size: 40" or
"read:"-type errors.

See also:
perldoc -f binmode
<http://perldoc.perl.org/perl581delta.html#UTF-8-no-longer-default-under-UTF-8-locales>

Signed-off-by: Michael Weber <michaelw@foldr.org>
---
 git-svn.perl |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)

diff --git a/git-svn.perl b/git-svn.perl
index b864b54..3d80b23 100755
--- a/git-svn.perl
+++ b/git-svn.perl
@@ -2519,6 +2519,7 @@ sub rebuild_from_rev_db {
 	my ($self, $path) = @_;
 	my $r = -1;
 	open my $fh, '<', $path or croak "open: $!";
+	binmode $fh or croak "binmode: $!";
 	while (<$fh>) {
 		length($_) == 41 or croak "inconsistent size in ($_) != 41";
 		chomp($_);
@@ -2616,6 +2617,7 @@ sub rebuild {
 sub _rev_map_set {
 	my ($fh, $rev, $commit) = @_;
 
+	binmode $fh or croak "binmode: $!";
 	my $size = (stat($fh))[7];
 	($size % 24) == 0 or croak "inconsistent size: $size";
 
@@ -2719,6 +2721,7 @@ sub rev_map_max {
 	my $map_path = $self->map_path;
 	stat $map_path or return $want_commit ? (0, undef) : 0;
 	sysopen(my $fh, $map_path, O_RDONLY) or croak "open: $!";
+	binmode $fh or croak "binmode: $!";
 	my $size = (stat($fh))[7];
 	($size % 24) == 0 or croak "inconsistent size: $size";
 
@@ -2751,6 +2754,7 @@ sub rev_map_get {
 	return undef unless -e $map_path;
 
 	sysopen(my $fh, $map_path, O_RDONLY) or croak "open: $!";
+	binmode $fh or croak "binmode: $!";
 	my $size = (stat($fh))[7];
 	($size % 24) == 0 or croak "inconsistent size: $size";
 
-- 
1.5.5.69.ga0a105

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

* Re: [PATCH] svn-git: Use binmode for reading/writing binary rev maps
  2008-04-18 13:12 [PATCH] svn-git: Use binmode for reading/writing binary rev maps Michael Weber
@ 2008-04-22 23:21 ` Eric Wong
  0 siblings, 0 replies; 2+ messages in thread
From: Eric Wong @ 2008-04-22 23:21 UTC (permalink / raw)
  To: Michael Weber; +Cc: git

Michael Weber <michaelw@foldr.org> wrote:
> Otherwise, there is a possible interaction with UTF-8 locales in
> combination with PERL_UNICODE, resulting in "inconsistent size: 40" or
> "read:"-type errors.
> 
> See also:
> perldoc -f binmode
> <http://perldoc.perl.org/perl581delta.html#UTF-8-no-longer-default-under-UTF-8-locales>
> 
> Signed-off-by: Michael Weber <michaelw@foldr.org>

Thanks, sorry for the latency.

Acked-by: Eric Wong <normalperson@yhbt.net>

> ---
>  git-svn.perl |    4 ++++
>  1 files changed, 4 insertions(+), 0 deletions(-)
> 
> diff --git a/git-svn.perl b/git-svn.perl
> index b864b54..3d80b23 100755
> --- a/git-svn.perl
> +++ b/git-svn.perl
> @@ -2519,6 +2519,7 @@ sub rebuild_from_rev_db {
>  	my ($self, $path) = @_;
>  	my $r = -1;
>  	open my $fh, '<', $path or croak "open: $!";
> +	binmode $fh or croak "binmode: $!";
>  	while (<$fh>) {
>  		length($_) == 41 or croak "inconsistent size in ($_) != 41";
>  		chomp($_);
> @@ -2616,6 +2617,7 @@ sub rebuild {
>  sub _rev_map_set {
>  	my ($fh, $rev, $commit) = @_;
>  
> +	binmode $fh or croak "binmode: $!";
>  	my $size = (stat($fh))[7];
>  	($size % 24) == 0 or croak "inconsistent size: $size";
>  
> @@ -2719,6 +2721,7 @@ sub rev_map_max {
>  	my $map_path = $self->map_path;
>  	stat $map_path or return $want_commit ? (0, undef) : 0;
>  	sysopen(my $fh, $map_path, O_RDONLY) or croak "open: $!";
> +	binmode $fh or croak "binmode: $!";
>  	my $size = (stat($fh))[7];
>  	($size % 24) == 0 or croak "inconsistent size: $size";
>  
> @@ -2751,6 +2754,7 @@ sub rev_map_get {
>  	return undef unless -e $map_path;
>  
>  	sysopen(my $fh, $map_path, O_RDONLY) or croak "open: $!";
> +	binmode $fh or croak "binmode: $!";
>  	my $size = (stat($fh))[7];
>  	($size % 24) == 0 or croak "inconsistent size: $size";
>  
> -- 

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

end of thread, other threads:[~2008-04-22 23:22 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-04-18 13:12 [PATCH] svn-git: Use binmode for reading/writing binary rev maps Michael Weber
2008-04-22 23:21 ` Eric Wong

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).