]> Sergey Matveev's repositories - public-inbox.git/commitdiff
searchidx: avoid modification of read-only `$_'
authorEric Wong <e@80x24.org>
Mon, 22 Nov 2021 18:23:52 +0000 (18:23 +0000)
committerEric Wong <e@80x24.org>
Mon, 22 Nov 2021 21:36:50 +0000 (21:36 +0000)
This fixes the "Modification of a read-only value attempted at ..."
error in an initial run of t/reindex-time-range.t.  It was
reproducible by running `rm -rf t/data-gen/reindex-time-range.v*'
before `make && prove -bvw t/reindex-time-range.t'.  Thanks to
Jörg Rödel for providing the backtrace which helped find this.

Debugged-by: Jörg Rödel <joro@8bytes.org>
Link: https://public-inbox.org/meta/YZuZEY+WSnm4wlrS@8bytes.org/
lib/PublicInbox/SearchIdx.pm

index 6e2e614c5085c7e45fa33ad06375a9137af1ee31..4e5d7d4417142250474ae0b3b30e25ad03d0c756 100644 (file)
@@ -896,20 +896,20 @@ sub log2stack ($$$) {
                push @cmd, "--$k=$v";
        }
        my $fh = $git->popen(@cmd, $range);
-       my ($at, $ct, $stk, $cmt);
-       while (<$fh>) {
+       my ($at, $ct, $stk, $cmt, $l);
+       while (defined($l = <$fh>)) {
                return if $sync->{quit};
-               if (/\A([0-9]+)-([0-9]+)-($OID)$/o) {
+               if ($l =~ /\A([0-9]+)-([0-9]+)-($OID)$/o) {
                        ($at, $ct, $cmt) = ($1 + 0, $2 + 0, $3);
                        $stk //= PublicInbox::IdxStack->new($cmt);
-               } elsif (/$del/) {
+               } elsif ($l =~ /$del/) {
                        my $oid = $1;
                        if ($D) { # reindex case
                                $D->{pack('H*', $oid)}++;
                        } else { # non-reindex case:
                                $stk->push_rec('d', $at, $ct, $oid, $cmt);
                        }
-               } elsif (/$add/) {
+               } elsif ($l =~ /$add/) {
                        my $oid = $1;
                        if ($D) {
                                my $oid_bin = pack('H*', $oid);