Skip to content

Commit 4f7ec79

Browse files
michaelwgitster
authored andcommitted
svn-git: Use binmode for reading/writing binary rev maps
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 <[email protected]> Acked-by: Eric Wong <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent a6f47b2 commit 4f7ec79

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

git-svn.perl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2506,6 +2506,7 @@ sub rebuild_from_rev_db {
25062506
my ($self, $path) = @_;
25072507
my $r = -1;
25082508
open my $fh, '<', $path or croak "open: $!";
2509+
binmode $fh or croak "binmode: $!";
25092510
while (<$fh>) {
25102511
length($_) == 41 or croak "inconsistent size in ($_) != 41";
25112512
chomp($_);
@@ -2603,6 +2604,7 @@ sub rebuild {
26032604
sub _rev_map_set {
26042605
my ($fh, $rev, $commit) = @_;
26052606

2607+
binmode $fh or croak "binmode: $!";
26062608
my $size = (stat($fh))[7];
26072609
($size % 24) == 0 or croak "inconsistent size: $size";
26082610

@@ -2706,6 +2708,7 @@ sub rev_map_max {
27062708
my $map_path = $self->map_path;
27072709
stat $map_path or return $want_commit ? (0, undef) : 0;
27082710
sysopen(my $fh, $map_path, O_RDONLY) or croak "open: $!";
2711+
binmode $fh or croak "binmode: $!";
27092712
my $size = (stat($fh))[7];
27102713
($size % 24) == 0 or croak "inconsistent size: $size";
27112714

@@ -2738,6 +2741,7 @@ sub rev_map_get {
27382741
return undef unless -e $map_path;
27392742

27402743
sysopen(my $fh, $map_path, O_RDONLY) or croak "open: $!";
2744+
binmode $fh or croak "binmode: $!";
27412745
my $size = (stat($fh))[7];
27422746
($size % 24) == 0 or croak "inconsistent size: $size";
27432747

0 commit comments

Comments
 (0)