@matheusbsbs / matheus-bagliano / commits / 4f7ec79708
Fork 0

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 <michaelw@foldr.org> Acked-by: Eric Wong <normalperson@yhbt.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Michael Weber committed Apr 18, 2008 at 15:12 UTC 4f7ec7970874d09be162bc7f16415a0ec2d36ae5
1 file changed +4
git-svn.perl
+4
@@ -2506,6 +2506,7 @@ sub rebuild_from_rev_db {
2506 my ($self, $path) = @_;
2507 my $r = -1;
2508 open my $fh, '<', $path or croak "open: $!";
2509 + binmode $fh or croak "binmode: $!";
2510 while (<$fh>) {
2511 length($_) == 41 or croak "inconsistent size in ($_) != 41";
2512 chomp($_);
@@ -2603,6 +2604,7 @@ sub rebuild {
2604 sub _rev_map_set {
2605 my ($fh, $rev, $commit) = @_;
2606
2607 + binmode $fh or croak "binmode: $!";
2608 my $size = (stat($fh))[7];
2609 ($size % 24) == 0 or croak "inconsistent size: $size";
2610
@@ -2706,6 +2708,7 @@ sub rev_map_max {
2708 my $map_path = $self->map_path;
2709 stat $map_path or return $want_commit ? (0, undef) : 0;
2710 sysopen(my $fh, $map_path, O_RDONLY) or croak "open: $!";
2711 + binmode $fh or croak "binmode: $!";
2712 my $size = (stat($fh))[7];
2713 ($size % 24) == 0 or croak "inconsistent size: $size";
2714
@@ -2738,6 +2741,7 @@ sub rev_map_get {
2741 return undef unless -e $map_path;
2742
2743 sysopen(my $fh, $map_path, O_RDONLY) or croak "open: $!";
2744 + binmode $fh or croak "binmode: $!";
2745 my $size = (stat($fh))[7];
2746 ($size % 24) == 0 or croak "inconsistent size: $size";
2747