Skip to content

Commit 148f193

Browse files
bk2204gitster
authored andcommitted
t/lib-git-svn: make hash size independent
The record size used in the git svn storage is four bytes plus the length of the binary hash. Pass the hash length into our Perl invocation and use it to compute the size of the records. Signed-off-by: brian m. carlson <[email protected]> Acked-by: Eric Wong <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 3e04b6e commit 148f193

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

t/lib-git-svn.sh

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -78,21 +78,24 @@ maybe_start_httpd () {
7878
}
7979

8080
convert_to_rev_db () {
81-
perl -w -- - "$@" <<\EOF
81+
perl -w -- - "$(test_oid rawsz)" "$@" <<\EOF
8282
use strict;
83+
my $oidlen = shift;
8384
@ARGV == 2 or die "usage: convert_to_rev_db <input> <output>";
85+
my $record_size = $oidlen + 4;
86+
my $hexlen = $oidlen * 2;
8487
open my $wr, '+>', $ARGV[1] or die "$!: couldn't open: $ARGV[1]";
8588
open my $rd, '<', $ARGV[0] or die "$!: couldn't open: $ARGV[0]";
8689
my $size = (stat($rd))[7];
87-
($size % 24) == 0 or die "Inconsistent size: $size";
88-
while (sysread($rd, my $buf, 24) == 24) {
89-
my ($r, $c) = unpack('NH40', $buf);
90-
my $offset = $r * 41;
90+
($size % $record_size) == 0 or die "Inconsistent size: $size";
91+
while (sysread($rd, my $buf, $record_size) == $record_size) {
92+
my ($r, $c) = unpack("NH$hexlen", $buf);
93+
my $offset = $r * ($hexlen + 1);
9194
seek $wr, 0, 2 or die $!;
9295
my $pos = tell $wr;
9396
if ($pos < $offset) {
94-
for (1 .. (($offset - $pos) / 41)) {
95-
print $wr (('0' x 40),"\n") or die $!;
97+
for (1 .. (($offset - $pos) / ($hexlen + 1))) {
98+
print $wr (('0' x $hexlen),"\n") or die $!;
9699
}
97100
}
98101
seek $wr, $offset, 0 or die $!;

0 commit comments

Comments
 (0)