about summary refs log tree commit homepage
path: root/lib/PublicInbox/Import.pm
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2020-12-27 02:53:04 +0000
committerEric Wong <e@80x24.org>2020-12-28 23:19:48 +0000
commit0f545dd95ca88e69f011aa56d07494887e7df822 (patch)
tree396472716c7ce389a14a04876a42b127fd9593e0 /lib/PublicInbox/Import.pm
parent645ec505c03c86ed4500151737bcf3d636d9b18b (diff)
downloadpublic-inbox-0f545dd95ca88e69f011aa56d07494887e7df822.tar.gz
import: check for git->qx errors, clearer return values
Those git commands can fail and git->qx will set $? when it
fails.  There's no need for the extra indirection of the @ret
array, either.

Improve git->qx coverage to check for $? while we're at it.
Diffstat (limited to 'lib/PublicInbox/Import.pm')
-rw-r--r--lib/PublicInbox/Import.pm9
1 files changed, 5 insertions, 4 deletions
diff --git a/lib/PublicInbox/Import.pm b/lib/PublicInbox/Import.pm
index 2cb4896a..e0a84bfd 100644
--- a/lib/PublicInbox/Import.pm
+++ b/lib/PublicInbox/Import.pm
@@ -48,7 +48,7 @@ sub gfi_start {
 
         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;
@@ -56,27 +56,28 @@ sub gfi_start {
                 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: $!" }