user/dev discussion of public-inbox itself
 help / color / mirror / Atom feed
From: Eric Wong <e@80x24.org>
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> (raw)
In-Reply-To: <20200915195137.13476-1-e@80x24.org>

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

      parent reply	other threads:[~2020-09-15 19:51 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-09-15 19:51 [PATCH 0/2] remove more 40 char limits Eric Wong
2020-09-15 19:51 ` [PATCH 1/2] mid: rename MID_MAX to ID_MAX Eric Wong
2020-09-15 19:51 ` Eric Wong [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://public-inbox.org/README

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200915195137.13476-3-e@80x24.org \
    --to=e@80x24.org \
    --cc=meta@public-inbox.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

user/dev discussion of public-inbox itself

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://public-inbox.org/meta
	git clone --mirror http://czquwvybam4bgbro.onion/meta
	git clone --mirror http://hjrcffqmbrq6wope.onion/meta
	git clone --mirror http://ou63pmih66umazou.onion/meta

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V1 meta meta/ https://public-inbox.org/meta \
		meta@public-inbox.org
	public-inbox-index meta

Example config snippet for mirrors.
Newsgroups are available over NNTP:
	nntp://news.public-inbox.org/inbox.comp.mail.public-inbox.meta
	nntp://ou63pmih66umazou.onion/inbox.comp.mail.public-inbox.meta
	nntp://czquwvybam4bgbro.onion/inbox.comp.mail.public-inbox.meta
	nntp://hjrcffqmbrq6wope.onion/inbox.comp.mail.public-inbox.meta
	nntp://news.gmane.io/gmane.mail.public-inbox.general
 note: .onion URLs require Tor: https://www.torproject.org/

code repositories for the project(s) associated with this inbox:

	https://80x24.org/public-inbox.git

AGPL code for this site: git clone https://public-inbox.org/public-inbox.git