about summary refs log tree commit homepage
path: root/lib
diff options
context:
space:
mode:
authorEric Wong <e@yhbt.net>2020-07-24 05:55:52 +0000
committerEric Wong <e@yhbt.net>2020-07-25 20:48:18 +0000
commit0cae91a6011ae745ff57869e2e5bc2c7b13f6743 (patch)
treed51fc9694cce45173852b3334cd477662c1ebf6e /lib
parent08e8e9522405e40985935b13e9eaaf409e33da75 (diff)
downloadpublic-inbox-0cae91a6011ae745ff57869e2e5bc2c7b13f6743.tar.gz
v2writable: allow >= 40 byte git object IDs
Another step in slowly updating our code to support SHA-256 or
whatever other hash algorithms git may support in the future.
Diffstat (limited to 'lib')
-rw-r--r--lib/PublicInbox/V2Writable.pm12
1 files changed, 6 insertions, 6 deletions
diff --git a/lib/PublicInbox/V2Writable.pm b/lib/PublicInbox/V2Writable.pm
index 4dc6880b..50582266 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};