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 8B4321F670 for ; Tue, 15 Sep 2020 19:51:37 +0000 (UTC) From: Eric Wong To: meta@public-inbox.org Subject: [PATCH 2/2] treewide: relax allow >=40 chars for git OID Date: Tue, 15 Sep 2020 19:51:37 +0000 Message-Id: <20200915195137.13476-3-e@80x24.org> In-Reply-To: <20200915195137.13476-1-e@80x24.org> References: <20200915195137.13476-1-e@80x24.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: This will help with eventual git SHA-256 transitions. --- lib/PublicInbox/Feed.pm | 4 ++-- lib/PublicInbox/Git.pm | 2 +- lib/PublicInbox/Import.pm | 4 ++-- lib/PublicInbox/ViewDiff.pm | 4 ++-- lib/PublicInbox/WWW.pm | 2 +- t/edit.t | 4 ++-- t/plack.t | 2 +- t/replace.t | 2 +- t/v2writable.t | 4 ++-- 9 files changed, 14 insertions(+), 14 deletions(-) diff --git a/lib/PublicInbox/Feed.pm b/lib/PublicInbox/Feed.pm index cbdf5db9..805076f0 100644 --- a/lib/PublicInbox/Feed.pm +++ b/lib/PublicInbox/Feed.pm @@ -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; } diff --git a/lib/PublicInbox/Git.pm b/lib/PublicInbox/Git.pm index 181026c7..a7ba57f9 100644 --- a/lib/PublicInbox/Git.pm +++ b/lib/PublicInbox/Git.pm @@ -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: $!"); diff --git a/lib/PublicInbox/Import.pm b/lib/PublicInbox/Import.pm index ee5ca2ea..1a226cc7 100644 --- a/lib/PublicInbox/Import.pm +++ b/lib/PublicInbox/Import.pm @@ -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); diff --git a/lib/PublicInbox/ViewDiff.pm b/lib/PublicInbox/ViewDiff.pm index 536bb9e3..7ec57d8d 100644 --- a/lib/PublicInbox/ViewDiff.pm +++ b/lib/PublicInbox/ViewDiff.pm @@ -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)!; diff --git a/lib/PublicInbox/WWW.pm b/lib/PublicInbox/WWW.pm index 85abf327..e3b589cb 100644 --- a/lib/PublicInbox/WWW.pm +++ b/lib/PublicInbox/WWW.pm @@ -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) = @_; diff --git a/t/edit.t b/t/edit.t index 4b004c1c..dbdda394 100644 --- 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'; { diff --git a/t/plack.t b/t/plack.t index 4b830a21..1fedf426 100644 --- 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; diff --git a/t/replace.t b/t/replace.t index 95241adf..fd8ce2c6 100644 --- a/t/replace.t +++ b/t/replace.t @@ -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'); diff --git a/t/v2writable.t b/t/v2writable.t index 1de8c032..2f71fafa 100644 --- a/t/v2writable.t +++ b/t/v2writable.t @@ -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