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 <sandals@crustytoothpaste.net> Acked-by: Eric Wong <e@80x24.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
brian m. carlson committed
Jun 22, 2020 at 18:04 UTC
148f193d16e3ca02b5ea2b72b5f069e722ac4a30
1 file changed
+10
-7
t/lib-git-svn.sh
+10
-7
@@ -78,21 +78,24 @@ maybe_start_httpd () {
78
}
79
80
convert_to_rev_db () {
81
- perl -w -- - "$@" <<\EOF
81
+ perl -w -- - "$(test_oid rawsz)" "$@" <<\EOF
82
use strict;
83
+my $oidlen = shift;
84
@ARGV == 2 or die "usage: convert_to_rev_db <input> <output>";
85
+my $record_size = $oidlen + 4;
86
+my $hexlen = $oidlen * 2;
87
open my $wr, '+>', $ARGV[1] or die "$!: couldn't open: $ARGV[1]";
88
open my $rd, '<', $ARGV[0] or die "$!: couldn't open: $ARGV[0]";
89
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);
94
seek $wr, 0, 2 or die $!;
95
my $pos = tell $wr;
96
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 $!;
99
}
100
}
101
seek $wr, $offset, 0 or die $!;