Skip to content

Commit

Permalink
svn-git: Use binmode for reading/writing binary rev maps
Browse files Browse the repository at this point in the history
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>
Acked-by: Eric Wong <normalperson@yhbt.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
Michael Weber authored and Junio C Hamano committed Apr 23, 2008
1 parent a6f47b2 commit 4f7ec79
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions git-svn.perl
Original file line number Diff line number Diff line change
Expand Up @@ -2506,6 +2506,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($_);
Expand Down Expand Up @@ -2603,6 +2604,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";

Expand Down Expand Up @@ -2706,6 +2708,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";

Expand Down Expand Up @@ -2738,6 +2741,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";

Expand Down

0 comments on commit 4f7ec79

Please sign in to comment.