Message ID | 20200619223947.947067-8-sandals@crustytoothpaste.net (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | SHA-256 CVS and SVN patches | expand |
On Jun 19 2020, brian m. carlson wrote: > diff --git a/t/lib-git-svn.sh b/t/lib-git-svn.sh > index 7d248e6588..4780b45337 100644 > --- a/t/lib-git-svn.sh > +++ b/t/lib-git-svn.sh > @@ -78,29 +78,30 @@ maybe_start_httpd () { > } > > convert_to_rev_db () { > - perl -w -- - "$@" <<\EOF > -use strict; > + perl -w -e "use strict; my \$oidlen = $(test_oid rawsz);" -e ' $(test_oid rawsz) could be passed as an additional argument. perl -w -- - "$(test_oid rawsz)" "$@" <<\EOF use strict; my $oidlen = shift; ... EOF Andreas.
On 2020-06-20 at 08:02:53, Andreas Schwab wrote: > On Jun 19 2020, brian m. carlson wrote: > > > diff --git a/t/lib-git-svn.sh b/t/lib-git-svn.sh > > index 7d248e6588..4780b45337 100644 > > --- a/t/lib-git-svn.sh > > +++ b/t/lib-git-svn.sh > > @@ -78,29 +78,30 @@ maybe_start_httpd () { > > } > > > > convert_to_rev_db () { > > - perl -w -- - "$@" <<\EOF > > -use strict; > > + perl -w -e "use strict; my \$oidlen = $(test_oid rawsz);" -e ' > > $(test_oid rawsz) could be passed as an additional argument. > > perl -w -- - "$(test_oid rawsz)" "$@" <<\EOF > use strict; > my $oidlen = shift; > ... > EOF Sure, I could do that. I originally tried to pass it through the environment, but that didn't appear to work as I expected.
diff --git a/t/lib-git-svn.sh b/t/lib-git-svn.sh index 7d248e6588..4780b45337 100644 --- a/t/lib-git-svn.sh +++ b/t/lib-git-svn.sh @@ -78,29 +78,30 @@ maybe_start_httpd () { } convert_to_rev_db () { - perl -w -- - "$@" <<\EOF -use strict; + perl -w -e "use strict; my \$oidlen = $(test_oid rawsz);" -e ' @ARGV == 2 or die "usage: convert_to_rev_db <input> <output>"; -open my $wr, '+>', $ARGV[1] or die "$!: couldn't open: $ARGV[1]"; -open my $rd, '<', $ARGV[0] or die "$!: couldn't open: $ARGV[0]"; +my $record_size = $oidlen + 4; +my $hexlen = $oidlen * 2; +open my $wr, "+>", $ARGV[1] or die "$!: couldn'\''t open: $ARGV[1]"; +open my $rd, "<", $ARGV[0] or die "$!: couldn'\''t open: $ARGV[0]"; my $size = (stat($rd))[7]; -($size % 24) == 0 or die "Inconsistent size: $size"; -while (sysread($rd, my $buf, 24) == 24) { - my ($r, $c) = unpack('NH40', $buf); - my $offset = $r * 41; +($size % $record_size) == 0 or die "Inconsistent size: $size"; +while (sysread($rd, my $buf, $record_size) == $record_size) { + my ($r, $c) = unpack("NH$hexlen", $buf); + my $offset = $r * ($hexlen + 1); seek $wr, 0, 2 or die $!; my $pos = tell $wr; if ($pos < $offset) { - for (1 .. (($offset - $pos) / 41)) { - print $wr (('0' x 40),"\n") or die $!; + for (1 .. (($offset - $pos) / ($hexlen + 1))) { + print $wr (('0' x $hexlen),"\n") or die $!; } } seek $wr, $offset, 0 or die $!; print $wr $c,"\n" or die $!; } close $wr or die $!; -close $rd or die $!; -EOF +close $rd or die $!;' \ + -- "$@" } require_svnserve () {
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> --- t/lib-git-svn.sh | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-)