From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: X-Spam-Status: No, score=-4.1 required=3.0 tests=ALL_TRUSTED,AWL,BAYES_00, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, T_SCC_BODY_TEXT_LINE shortcircuit=no autolearn=ham autolearn_force=no version=3.4.6 Received: from localhost (dcvr.yhbt.net [127.0.0.1]) by dcvr.yhbt.net (Postfix) with ESMTP id 38AA51F452 for ; Thu, 20 Apr 2023 10:23:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=80x24.org; s=selector1; t=1681986183; bh=aCiKrlrJsUk2RyzbOHg2KFFna3edpaQEmLKgEEwco8M=; h=From:To:Subject:Date:From; b=3AaW09RxaN8j4ErvU7CUg/624IY7SKJ0fGep5GSnEdsepGcbErQatHNjqOob/dZ7f NFTzgALXivwJdAzT+GTQe2We3gNkuedvHQRsLu/BkK+eSsF5827ibKOlfJWA8JIskT 2n8B6CFK6vI6CbVDYVt6+XoWFIQLE9Z12tP6w4Bc= From: Eric Wong To: meta@public-inbox.org Subject: [PATCH] lei_mail_sync: prepare to support SHA-256 Date: Thu, 20 Apr 2023 10:23:02 +0000 Message-Id: <20230420102302.1464627-1-e@80x24.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: 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;