]> Sergey Matveev's repositories - public-inbox.git/commitdiff
treewide: relax allow >=40 chars for git OID
authorEric Wong <e@80x24.org>
Tue, 15 Sep 2020 19:51:37 +0000 (19:51 +0000)
committerEric Wong <e@80x24.org>
Wed, 16 Sep 2020 04:06:10 +0000 (04:06 +0000)
This will help with eventual git SHA-256 transitions.

lib/PublicInbox/Feed.pm
lib/PublicInbox/Git.pm
lib/PublicInbox/Import.pm
lib/PublicInbox/ViewDiff.pm
lib/PublicInbox/WWW.pm
t/edit.t
t/plack.t
t/replace.t
t/v2writable.t

index cbdf5db99f8b8486e8a14caff84259c63e560fd9..805076f0e1294cb577108aea449850958922a20e 100644 (file)
@@ -88,7 +88,7 @@ sub recent_msgs {
        my $hex = '[a-f0-9]';
        my $addmsg = qr!^:000000 100644 \S+ (\S+) A\t${hex}{2}/${hex}{38}$!;
        my $delmsg = qr!^:100644 000000 (\S+) \S+ D\t(${hex}{2}/${hex}{38})$!;
-       my $refhex = qr/(?:HEAD|${hex}{4,40})(?:~[0-9]+)?/;
+       my $refhex = qr/(?:HEAD|${hex}{4,})(?:~[0-9]+)?/;
 
        # revision ranges may be specified
        my $range = 'HEAD';
@@ -126,7 +126,7 @@ sub recent_msgs {
        if ($last) {
                local $/ = "\n";
                while (my $line = <$log>) {
-                       if ($line =~ /^(${hex}{7,40})/) {
+                       if ($line =~ /^(${hex}{7,})/) {
                                $last_commit = $1;
                                last;
                        }
index 181026c7bc1b726ff562e1b488f3256a0bf98c87..a7ba57f94fa2f9d4bfc270fe774ab50679b05286 100644 (file)
@@ -185,7 +185,7 @@ sub cat_async_step ($$) {
        my $rbuf = delete($self->{cat_rbuf}) // \(my $new = '');
        my ($bref, $oid, $type, $size);
        my $head = my_readline($self->{in}, $rbuf);
-       if ($head =~ /^([0-9a-f]{40}) (\S+) ([0-9]+)$/) {
+       if ($head =~ /^([0-9a-f]{40,}) (\S+) ([0-9]+)$/) {
                ($oid, $type, $size) = ($1, $2, $3 + 0);
                $bref = my_read($self->{in}, $rbuf, $size + 1) or
                        fail($self, defined($bref) ? 'read EOF' : "read: $!");
index ee5ca2ea11b4f383e514ecdf117ac1dabe2c14c1..1a226cc78dd4e45a429c8f026137251373ff5a8c 100644 (file)
@@ -106,7 +106,7 @@ sub _cat_blob ($$$) {
        local $/ = "\n";
        my $info = <$r>;
        defined $info or die "EOF from fast-import / cat-blob: $!";
-       $info =~ /\A[a-f0-9]{40} blob ([0-9]+)\n\z/ or return;
+       $info =~ /\A[a-f0-9]{40,} blob ([0-9]+)\n\z/ or return;
        my $left = $1;
        my $offset = 0;
        my $buf = '';
@@ -137,7 +137,7 @@ sub check_remove_v1 {
        my ($r, $w, $tip, $path, $mime) = @_;
 
        my $info = _check_path($r, $w, $tip, $path) or return ('MISSING',undef);
-       $info =~ m!\A100644 blob ([a-f0-9]{40})\t!s or die "not blob: $info";
+       $info =~ m!\A100644 blob ([a-f0-9]{40,})\t!s or die "not blob: $info";
        my $oid = $1;
        my $msg = _cat_blob($r, $w, $oid) or die "BUG: cat-blob $1 failed";
        my $cur = PublicInbox::Eml->new($msg);
index 536bb9e3c99e458e486e96f0abdb2fa9eca83637..7ec57d8d5fddc4f8ccbc2e8cb5b8f7ff4b608d7a 100644 (file)
@@ -18,8 +18,8 @@ use PublicInbox::Git qw(git_unquote);
 
 sub UNSAFE () { "^A-Za-z0-9\-\._~/" }
 
-my $OID_NULL = '0{7,40}';
-my $OID_BLOB = '[a-f0-9]{7,40}';
+my $OID_NULL = '0{7,}';
+my $OID_BLOB = '[a-f0-9]{7,}';
 my $LF = qr!\n!;
 my $ANY = qr![^\n]!;
 my $FN = qr!(?:"?[^/\n]+/[^\n]+|/dev/null)!;
index 85abf327de884140aac246c5407229b135817433..e3b589cb78d4475c39eba9d8ca6c6f8e89e9610d 100644 (file)
@@ -29,7 +29,7 @@ our $INBOX_RE = qr!\A/([\w\-][\w\.\-]*)!;
 our $MID_RE = qr!([^/]+)!;
 our $END_RE = qr!(T/|t/|t\.mbox(?:\.gz)?|t\.atom|raw|)!;
 our $ATTACH_RE = qr!([0-9][0-9\.]*)-($PublicInbox::Hval::FN)!;
-our $OID_RE = qr![a-f0-9]{7,40}!;
+our $OID_RE = qr![a-f0-9]{7,}!;
 
 sub new {
        my ($class, $pi_config) = @_;
index 4b004c1c2b622f58b5f7b8a2ff3579a59c40a3db..dbdda394d3344549a6fe229a151e3cf42b536432 100644 (file)
--- a/t/edit.t
+++ b/t/edit.t
@@ -41,7 +41,7 @@ $t = '-F FILE'; {
        ok(run_script($cmd, undef, $opt), "$t edit OK");
        $cur = PublicInbox::Eml->new($ibx->msg_by_mid($mid));
        like($cur->header('Subject'), qr/bool pfx/, "$t message edited");
-       like($out, qr/[a-f0-9]{40}/, "$t shows commit on success");
+       like($out, qr/[a-f0-9]{40,}/, "$t shows commit on success");
 }
 
 $t = '-m MESSAGE_ID'; {
@@ -51,7 +51,7 @@ $t = '-m MESSAGE_ID'; {
        ok(run_script($cmd, undef, $opt), "$t edit OK");
        $cur = PublicInbox::Eml->new($ibx->msg_by_mid($mid));
        like($cur->header('Subject'), qr/boolean prefix/, "$t message edited");
-       like($out, qr/[a-f0-9]{40}/, "$t shows commit on success");
+       like($out, qr/[a-f0-9]{40,}/, "$t shows commit on success");
 }
 
 $t = 'no-op -m MESSAGE_ID'; {
index 4b830a21e35c72b3bf1712d0150ae73b8483a144..1fedf426dead7a2449b212acc41dbcc4773bb655 100644 (file)
--- a/t/plack.t
+++ b/t/plack.t
@@ -45,7 +45,7 @@ EOF
        $im->add($mime);
        $im->done;
        my $rev = $git->qx(qw(rev-list HEAD));
-       like($rev, qr/\A[a-f0-9]{40}/, "good revision committed");
+       like($rev, qr/\A[a-f0-9]{40,}/, "good revision committed");
        @ls = $git->qx(qw(ls-tree -r --name-only HEAD));
        chomp @ls;
 
index 95241adf6842282eae8b4ce805d42b79ec8c5c02..fd8ce2c64a0e8b682ae7feb3aa207167a9604556 100644 (file)
@@ -74,7 +74,7 @@ EOF
        for my $tip (@$cmts) {
                next if !defined $tip;
                $changed_epochs++;
-               like($tip, qr/\A[a-f0-9]{40}\z/,
+               like($tip, qr/\A[a-f0-9]{40,}\z/,
                        'replace returned current commit');
        }
        is($changed_epochs, 1, 'only one epoch changed');
index 1de8c032da14d199f11efdac601ce57e67984ed8..2f71fafaab60b9c0bcaf2b4bfa1af5ddff7eef92 100644 (file)
@@ -255,8 +255,8 @@ EOF
 {
        ok($im->add($mime), 'add message to be purged');
        local $SIG{__WARN__} = sub {};
-       ok(my $cmts = $im->purge($mime), 'purged message');
-       like($cmts->[0], qr/\A[a-f0-9]{40}\z/, 'purge returned current commit');
+       ok(my $cmt = $im->purge($mime), 'purged message');
+       like($cmt->[0], qr/\A[a-f0-9]{40,}\z/, 'purge returned current commit');
        $im->done;
 
        # again