return ($self->{in}, $self->{out}) if $self->{pid};
- my (@ret, $out_r, $out_w);
+ my ($in_r, $pid, $out_r, $out_w);
pipe($out_r, $out_w) or die "pipe failed: $!";
$self->lock_acquire;
my ($git, $ref) = @$self{qw(git ref)};
local $/ = "\n";
chomp($self->{tip} = $git->qx(qw(rev-parse --revs-only), $ref));
+ die "fatal: rev-parse --revs-only $ref: \$?=$?" if $?;
if ($self->{path_type} ne '2/38' && $self->{tip}) {
local $/ = "\0";
my @t = $git->qx(qw(ls-tree -r -z --name-only), $ref);
+ die "fatal: ls-tree -r -z --name-only $ref: \$?=$?" if $?;
chomp @t;
$self->{-tree} = { map { $_ => 1 } @t };
}
my @cmd = ('git', "--git-dir=$git->{git_dir}",
qw(fast-import --quiet --done --date-format=raw));
- my ($in_r, $pid) = popen_rd(\@cmd, undef, { 0 => $out_r });
+ ($in_r, $pid) = popen_rd(\@cmd, undef, { 0 => $out_r });
$out_w->autoflush(1);
$self->{in} = $in_r;
$self->{out} = $out_w;
$self->{pid} = $pid;
$self->{nchg} = 0;
- @ret = ($in_r, $out_w);
};
if ($@) {
$self->lock_release;
die $@;
}
- @ret;
+ ($in_r, $out_w);
}
sub wfail () { die "write to fast-import failed: $!" }
local $/ = "\n";
my $info = <$r>;
defined $info or die "EOF from fast-import / cat-blob: $!";
- $info =~ /\A[a-f0-9]{40} blob ([0-9]+)\n\z/ or return;
+ $info =~ /\A[a-f0-9]{40,} blob ([0-9]+)\n\z/ or return;
my $left = $1;
my $offset = 0;
my $buf = '';
my ($r, $w, $tip, $path, $mime) = @_;
my $info = _check_path($r, $w, $tip, $path) or return ('MISSING',undef);
- $info =~ m!\A100644 blob ([a-f0-9]{40})\t!s or die "not blob: $info";
+ $info =~ m!\A100644 blob ([a-f0-9]{40,})\t!s or die "not blob: $info";
my $oid = $1;
my $msg = _cat_blob($r, $w, $oid) or die "BUG: cat-blob $1 failed";
my $cur = PublicInbox::Eml->new($msg);
}
# kill potentially confusing/misleading headers
+our @UNWANTED_HEADERS = (qw(Bytes Lines Content-Length),
+ qw(Status X-Status));
sub drop_unwanted_headers ($) {
- my ($mime) = @_;
-
- $mime->header_set($_) for qw(Bytes Lines Content-Length Status);
- $mime->header_set($_) for @PublicInbox::MDA::BAD_HEADERS;
+ my ($eml) = @_;
+ for (@UNWANTED_HEADERS, @PublicInbox::MDA::BAD_HEADERS) {
+ $eml->header_set($_);
+ }
}
# used by V2Writable, too
}
}
+# true if locked and active
+sub active { !!$_[0]->{out} }
+
sub done {
my ($self) = @_;
my $w = delete $self->{out} or return;