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.
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 {
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:
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)';
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;