unofficial mirror of meta@public-inbox.org
 help / color / mirror / Atom feed
From: Eric Wong <e@80x24.org>
To: meta@public-inbox.org
Subject: [PATCH] lei_mail_sync: prepare to support SHA-256
Date: Thu, 20 Apr 2023 10:23:02 +0000	[thread overview]
Message-ID: <20230420102302.1464627-1-e@80x24.org> (raw)

I'm not sure how combining SHA-1 and SHA-256 in a single git
repo will work, eventually.   But this is an obvious place to do
the right thing if we ever see a 64-byte hex string (unless git
adds support for another hash which uses 64-byte hex string
representations, which would break many assumptions elsewhere,
too...).
---
 lib/PublicInbox/LeiMailSync.pm | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/lib/PublicInbox/LeiMailSync.pm b/lib/PublicInbox/LeiMailSync.pm
index ea4d48c1..308b1695 100644
--- a/lib/PublicInbox/LeiMailSync.pm
+++ b/lib/PublicInbox/LeiMailSync.pm
@@ -9,6 +9,7 @@ use parent qw(PublicInbox::Lock);
 use DBI qw(:sql_types); # SQL_BLOB
 use PublicInbox::ContentHash qw(git_sha);
 use Carp ();
+use PublicInbox::Git qw(%HEXLEN2SHA);
 
 sub dbh_new {
 	my ($self) = @_;
@@ -457,7 +458,8 @@ WHERE b.oidbin = ?
 			local $/;
 			my $raw = <$fh>;
 			if ($vrfy) {
-				my $got = git_sha(1, \$raw)->hexdigest;
+				my $sha = $HEXLEN2SHA{length($oidhex)};
+				my $got = git_sha($sha, \$raw)->hexdigest;
 				if ($got ne $oidhex) {
 					warn "$f changed $oidhex => $got\n";
 					next;

                 reply	other threads:[~2023-04-20 10:23 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20230420102302.1464627-1-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
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).