diff options
author | Eric Wong <e@yhbt.net> | 2020-01-11 22:35:03 +0000 |
---|---|---|
committer | Eric Wong <e@yhbt.net> | 2020-01-13 04:36:48 +0000 |
commit | c5c709dcef1b5904467ff2aea3943f00a891dade (patch) | |
tree | e02f9d1e216c3beacc51d2ca43e5333c4dbd9f4f /lib/PublicInbox/Import.pm | |
parent | a208d17ed99577faa8b52d46107fad5516b346b0 (diff) | |
download | public-inbox-c5c709dcef1b5904467ff2aea3943f00a891dade.tar.gz |
popen_rd accepts arbitrary redirects, so we can reuse its code to setup the pipe end we want to read, saving each caller a few lines of code compared to calling pipe+spawn.
Diffstat (limited to 'lib/PublicInbox/Import.pm')
-rw-r--r-- | lib/PublicInbox/Import.pm | 8 |
1 files changed, 3 insertions, 5 deletions
diff --git a/lib/PublicInbox/Import.pm b/lib/PublicInbox/Import.pm index 6ac43d37..d279fea1 100644 --- a/lib/PublicInbox/Import.pm +++ b/lib/PublicInbox/Import.pm @@ -9,7 +9,7 @@ package PublicInbox::Import; use strict; use warnings; use base qw(PublicInbox::Lock); -use PublicInbox::Spawn qw(spawn); +use PublicInbox::Spawn qw(spawn popen_rd); use PublicInbox::MID qw(mids mid2path); use PublicInbox::Address; use PublicInbox::MsgTime qw(msg_timestamp msg_datestamp); @@ -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,8 +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); + my ($in_r, $pid) = popen_rd(\@cmd, undef, { 0 => $out_r }); $out_w->autoflush(1); $self->{in} = $in_r; $self->{out} = $out_w; |