X-Git-Url: http://www.git.stargrave.org/?a=blobdiff_plain;f=lib%2FPublicInbox%2FImport.pm;h=68dc0c7e83c1b223796ee171200d879065e1add2;hb=03255d56a53d390a7f7bb069e0f1c6ea5d34756c;hp=34f7d122af67526306dc6feebce30f2c0d9e1d9b;hpb=267371b1273b518215939e817e53733584b68af7;p=public-inbox.git
diff --git a/lib/PublicInbox/Import.pm b/lib/PublicInbox/Import.pm
index 34f7d122..68dc0c7e 100644
--- a/lib/PublicInbox/Import.pm
+++ b/lib/PublicInbox/Import.pm
@@ -1,4 +1,4 @@
-# Copyright (C) 2016-2019 all contributors
+# Copyright (C) 2016-2020 all contributors
# License: AGPL-3.0+
#
# git fast-import-based ssoma-mda MDA replacement
@@ -9,8 +9,8 @@ package PublicInbox::Import;
use strict;
use warnings;
use base qw(PublicInbox::Lock);
-use PublicInbox::Spawn qw(spawn);
-use PublicInbox::MID qw(mids mid_mime mid2path);
+use PublicInbox::Spawn qw(spawn popen_rd);
+use PublicInbox::MID qw(mids mid2path);
use PublicInbox::Address;
use PublicInbox::MsgTime qw(msg_timestamp msg_datestamp);
use PublicInbox::ContentId qw(content_digest);
@@ -46,8 +46,7 @@ sub gfi_start {
return ($self->{in}, $self->{out}) if $self->{pid};
- my ($in_r, $in_w, $out_r, $out_w);
- pipe($in_r, $in_w) or die "pipe failed: $!";
+ my ($out_r, $out_w);
pipe($out_r, $out_w) or die "pipe failed: $!";
my $git = $self->{git};
@@ -66,9 +65,7 @@ sub gfi_start {
my $git_dir = $git->{git_dir};
my @cmd = ('git', "--git-dir=$git_dir", qw(fast-import
--quiet --done --date-format=raw));
- my $rdr = { 0 => $out_r, 1 => $in_w };
- my $pid = spawn(\@cmd, undef, $rdr);
- die "spawn fast-import failed: $!" unless defined $pid;
+ my ($in_r, $pid) = popen_rd(\@cmd, undef, { 0 => $out_r });
$out_w->autoflush(1);
$self->{in} = $in_r;
$self->{out} = $out_w;
@@ -296,6 +293,10 @@ sub extract_cmt_info ($) {
}
}
if (defined $email) {
+ # Email::Address::XS may leave quoted '<' in addresses,
+ # which git-fast-import doesn't like
+ $email =~ tr/<>//d;
+
# quiet down wide character warnings with utf8::encode
utf8::encode($email);
} else {
@@ -430,7 +431,6 @@ sub add {
sub run_die ($;$$) {
my ($cmd, $env, $rdr) = @_;
my $pid = spawn($cmd, $env, $rdr);
- defined $pid or die "spawning ".join(' ', @$cmd)." failed: $!";
waitpid($pid, 0) == $pid or die join(' ', @$cmd) .' did not finish';
$? == 0 or die join(' ', @$cmd) . " failed: $?\n";
}
@@ -623,7 +623,7 @@ PublicInbox::Import - message importer for public-inbox v1 inboxes
version 1.0
-=head1 SYNOPSYS
+=head1 SYNOPSIS
use Email::MIME;
use PublicInbox::Git;