diff options
author | Eric Wong <e@80x24.org> | 2021-03-21 15:50:46 +0600 |
---|---|---|
committer | Eric Wong <e@80x24.org> | 2021-03-21 10:35:11 +0000 |
commit | 26f6047fff20159085e28bd1e8a6e83a1e952fe0 (patch) | |
tree | 2f80f7218f27dbc5cf737e32f6de7a61d6d93e5b /lib/PublicInbox/ContentHash.pm | |
parent | 47d21e78be57a8f4615be5872e08ec4539423d1f (diff) | |
download | public-inbox-26f6047fff20159085e28bd1e8a6e83a1e952fe0.tar.gz |
This will let us tie keywords from remote externals to those which only exist in local externals.
Diffstat (limited to 'lib/PublicInbox/ContentHash.pm')
-rw-r--r-- | lib/PublicInbox/ContentHash.pm | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/lib/PublicInbox/ContentHash.pm b/lib/PublicInbox/ContentHash.pm index 4dbe7b50..112b1ea6 100644 --- a/lib/PublicInbox/ContentHash.pm +++ b/lib/PublicInbox/ContentHash.pm @@ -8,9 +8,9 @@ # See L<public-inbox-v2-format(5)> manpage for more details. package PublicInbox::ContentHash; use strict; -use warnings; -use base qw/Exporter/; -our @EXPORT_OK = qw/content_hash content_digest/; +use v5.10.1; +use parent qw(Exporter); +our @EXPORT_OK = qw(content_hash content_digest git_sha); use PublicInbox::MID qw(mids references); use PublicInbox::MsgIter; @@ -94,4 +94,13 @@ sub content_hash ($) { content_digest($_[0])->digest; } +sub git_sha ($$) { + my ($n, $eml) = @_; + my $dig = Digest::SHA->new($n); + my $buf = $eml->as_string; + $dig->add('blob '.length($buf)."\0"); + $dig->add($buf); + $dig; +} + 1; |