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.2 required=3.0 tests=ALL_TRUSTED,AWL,BAYES_00, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF 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 B7CDB1F4C4 for ; Tue, 26 Nov 2024 21:29:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=80x24.org; s=selector1; t=1732656563; bh=aKECBC3zrEP5O4WNFBdN9rGNcxGrFVulIgdnjnDmNgs=; h=From:To:Subject:Date:In-Reply-To:References:From; b=vC91clVZSxfJujiBPRH+9RunqUdbAxzubt7PCdX/hihr8Tr08QGbMt33biWK434eT rSmV/TfrB3Jbl3t2KhK14rrKrahlQl0dPlhLDT5kMlSin8w+bHyfXX+YAAX5Eic3np GvjsDYcT5ldadnnMKYpInsLayc++b3yo/NEZk3bE= From: Eric Wong To: meta@public-inbox.org Subject: [PATCH 1/2] import: allow $noisy toggle, simplify `lei rediff' Date: Tue, 26 Nov 2024 21:29:22 +0000 Message-ID: <20241126212923.840812-2-e@80x24.org> In-Reply-To: <20241126212923.840812-1-e@80x24.org> References: <20241126212923.840812-1-e@80x24.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: Creating an anonymous sub for $SIG{__WARN__} every time `lei rediff' is called is wasteful. Instead, provide a knob to prevent the unnecessary warning from being emitted by PublicInbox::Import in the first place so we can use the existing warn_ignore_cb. --- lib/PublicInbox/Import.pm | 5 +++-- lib/PublicInbox/LeiRediff.pm | 7 ++----- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/lib/PublicInbox/Import.pm b/lib/PublicInbox/Import.pm index ae46c5f4..e6d725fc 100644 --- a/lib/PublicInbox/Import.pm +++ b/lib/PublicInbox/Import.pm @@ -22,6 +22,7 @@ use autodie qw(socketpair); use Carp qw(croak); use Socket qw(AF_UNIX SOCK_STREAM); use PublicInbox::IO qw(read_all); +our $noisy = 1; sub default_branch () { state $default_branch = do { @@ -297,7 +298,7 @@ sub extract_cmt_info ($;$) { utf8::encode($email); } else { $email = ''; - warn "no email in From: $from or Sender: $sender\n"; + warn "no email in From: $from or Sender: $sender\n" if $noisy; } # git gets confused with: @@ -309,7 +310,7 @@ sub extract_cmt_info ($;$) { utf8::encode($name); } else { $name = ''; - warn "no name in From: $from or Sender: $sender\n"; + warn "no name in From: $from or Sender: $sender\n" if $noisy; } my $subject = delete($smsg->{Subject}) // '(no subject)'; diff --git a/lib/PublicInbox/LeiRediff.pm b/lib/PublicInbox/LeiRediff.pm index 59fee3f6..6df2a96b 100644 --- a/lib/PublicInbox/LeiRediff.pm +++ b/lib/PublicInbox/LeiRediff.pm @@ -223,11 +223,8 @@ sub dequote_add { # Eml each_part callback sub input_eml_cb { # callback for all emails my ($self, $eml) = @_; { - local $SIG{__WARN__} = sub { - return if "@_" =~ /^no email in From: .*? or Sender:/; - return if PublicInbox::Eml::warn_ignore(@_); - warn @_; - }; + local $PublicInbox::Import::noisy; + local $SIG{__WARN__} = \&PublicInbox::Eml::warn_ignore_cb; $self->{tmp_sto}->add_eml($eml); $eml->each_part(\&dequote_add, $self) if $self->{dqre}; $self->{tmp_sto}->done;