From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-Status: No, score=-4.0 required=3.0 tests=ALL_TRUSTED,BAYES_00 shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from localhost (dcvr.yhbt.net [127.0.0.1]) by dcvr.yhbt.net (Postfix) with ESMTP id 3CABD1F8EC for ; Fri, 24 Jul 2020 05:56:08 +0000 (UTC) From: Eric Wong To: meta@public-inbox.org Subject: [PATCH 06/20] v2writable: allow >= 40 byte git object IDs Date: Fri, 24 Jul 2020 05:55:52 +0000 Message-Id: <20200724055606.27332-7-e@yhbt.net> In-Reply-To: <20200724055606.27332-1-e@yhbt.net> References: <20200724055606.27332-1-e@yhbt.net> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: Another step in slowly updating our code to support SHA-256 or whatever other hash algorithms git may support in the future. --- lib/PublicInbox/V2Writable.pm | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/PublicInbox/V2Writable.pm b/lib/PublicInbox/V2Writable.pm index 4dc6880b4..50582266b 100644 --- a/lib/PublicInbox/V2Writable.pm +++ b/lib/PublicInbox/V2Writable.pm @@ -22,7 +22,7 @@ use PublicInbox::SearchIdx; use IO::Handle; # ->autoflush use File::Temp qw(tempfile); -my $x40 = qr/[a-f0-9]{40}/; +my $OID = qr/[a-f0-9]{40,}/; # an estimate of the post-packed size to the raw uncompressed size my $PACKING_FACTOR = 0.4; @@ -492,7 +492,7 @@ sub git_hash_raw ($$) { local $/ = "\n"; chomp(my $oid = <$r>); close $r or die "git hash-object failed: $?"; - $oid =~ /\A[a-f0-9]{40}\z/ or die "OID not expected: $oid"; + $oid =~ /\A$OID\z/ or die "OID not expected: $oid"; $oid; } @@ -1045,17 +1045,17 @@ sub prepare_range_stack { $range); my ($at, $ct, $stk); while (<$fh>) { - if (/\A([0-9]+)-([0-9]+)-($x40)$/o) { + if (/\A([0-9]+)-([0-9]+)-($OID)$/o) { ($at, $ct) = ($1 + 0, $2 + 0); $stk //= PublicInbox::IdxStack->new($3); - } elsif (/\A:\d{6} 100644 $x40 ($x40) [AM]\td$/o) { + } elsif (/\A:\d{6} 100644 $OID ($OID) [AM]\td$/o) { my $oid = $1; if ($D) { # reindex case $D->{pack('H*', $oid)}++; } else { # non-reindex case: $stk->push_rec('d', $at, $ct, $oid); } - } elsif (/\A:\d{6} 100644 $x40 ($x40) [AM]\tm$/o) { + } elsif (/\A:\d{6} 100644 $OID ($OID) [AM]\tm$/o) { my $oid = $1; if ($D) { my $oid_bin = pack('H*', $oid); @@ -1177,7 +1177,7 @@ sub unindex ($$$$) { --no-notes --no-color --no-abbrev --no-renames); my $fh = $self->{reindex_pipe} = $git->popen(@cmd, $unindex_range); while (<$fh>) { - /\A:\d{6} 100644 $x40 ($x40) [AM]\tm$/o or next; + /\A:\d{6} 100644 $OID ($OID) [AM]\tm$/o or next; unindex_oid($self, $git, $1, $unindexed); } delete $self->{reindex_pipe};