user/dev discussion of public-inbox itself
 help / color / mirror / Atom feed
* [PATCH 0/2] remove more 40 char limits
@ 2020-09-15 19:51 Eric Wong
  2020-09-15 19:51 ` [PATCH 1/2] mid: rename MID_MAX to ID_MAX Eric Wong
  2020-09-15 19:51 ` [PATCH 2/2] treewide: relax allow >=40 chars for git OID Eric Wong
  0 siblings, 2 replies; 3+ messages in thread
From: Eric Wong @ 2020-09-15 19:51 UTC (permalink / raw)
  To: meta

SHA-256 support is coming in git

Eric Wong (2):
  mid: rename MID_MAX to ID_MAX
  treewide: relax allow >=40 chars for git OID

 lib/PublicInbox/Feed.pm     | 4 ++--
 lib/PublicInbox/Git.pm      | 2 +-
 lib/PublicInbox/Import.pm   | 4 ++--
 lib/PublicInbox/MID.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 ++--
 10 files changed, 16 insertions(+), 16 deletions(-)

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH 1/2] mid: rename MID_MAX to ID_MAX
  2020-09-15 19:51 [PATCH 0/2] remove more 40 char limits Eric Wong
@ 2020-09-15 19:51 ` Eric Wong
  2020-09-15 19:51 ` [PATCH 2/2] treewide: relax allow >=40 chars for git OID Eric Wong
  1 sibling, 0 replies; 3+ messages in thread
From: Eric Wong @ 2020-09-15 19:51 UTC (permalink / raw)
  To: meta

It's only used for HTML anchors which we will need indefinitely.
---
 lib/PublicInbox/MID.pm | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/lib/PublicInbox/MID.pm b/lib/PublicInbox/MID.pm
index e9a3b0c0..369bb034 100644
--- a/lib/PublicInbox/MID.pm
+++ b/lib/PublicInbox/MID.pm
@@ -12,7 +12,7 @@ use URI::Escape qw(uri_escape_utf8);
 use Digest::SHA qw/sha1_hex/;
 require PublicInbox::Address;
 use constant {
-	MID_MAX => 40, # SHA-1 hex length # TODO: get rid of this
+	ID_MAX => 40, # SHA-1 hex length for HTML id anchors
 	MAX_MID_SIZE => 244, # max term size (Xapian limitation) - length('Q')
 };
 
@@ -32,7 +32,7 @@ sub mid_clean {
 sub id_compress {
 	my ($id, $force) = @_;
 
-	if ($force || $id =~ /[^a-zA-Z0-9_\-]/ || length($id) > MID_MAX) {
+	if ($force || $id =~ /[^a-zA-Z0-9_\-]/ || length($id) > ID_MAX) {
 		utf8::encode($id);
 		return sha1_hex($id);
 	}

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH 2/2] treewide: relax allow >=40 chars for git OID
  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
  1 sibling, 0 replies; 3+ messages in thread
From: Eric Wong @ 2020-09-15 19:51 UTC (permalink / raw)
  To: meta

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

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2020-09-15 19:51 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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 ` [PATCH 2/2] treewide: relax allow >=40 chars for git OID Eric Wong

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