about summary refs log tree commit homepage
path: root/lib/PublicInbox/Git.pm
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2023-10-01 09:54:20 +0000
committerEric Wong <e@80x24.org>2023-10-01 22:41:43 +0000
commit822924ebe83c16d7107068e900abc440fb0b18de (patch)
treec5988861aff0499fe964ae40a76e7eed14ddbfb3 /lib/PublicInbox/Git.pm
parent8aa6e36fbd5955db5ee80059729feed1ec6ddaa0 (diff)
downloadpublic-inbox-822924ebe83c16d7107068e900abc440fb0b18de.tar.gz
We can use autodie for socketpair to handle errors for us,
but we need Time::HiRes::stat so we must write the error message
ourselves if stat-ing the git executable fails.
Diffstat (limited to 'lib/PublicInbox/Git.pm')
-rw-r--r--lib/PublicInbox/Git.pm6
1 files changed, 3 insertions, 3 deletions
diff --git a/lib/PublicInbox/Git.pm b/lib/PublicInbox/Git.pm
index 5003be53..1dbd10b7 100644
--- a/lib/PublicInbox/Git.pm
+++ b/lib/PublicInbox/Git.pm
@@ -10,6 +10,7 @@ package PublicInbox::Git;
 use strict;
 use v5.10.1;
 use parent qw(Exporter PublicInbox::DS);
+use autodie qw(socketpair);
 use POSIX ();
 use IO::Handle; # ->blocking
 use Socket qw(AF_UNIX SOCK_STREAM);
@@ -57,7 +58,7 @@ my ($GIT_EXE, $GIT_VER);
 
 sub check_git_exe () {
         $GIT_EXE = which('git') // die "git not found in $ENV{PATH}";
-        my @st = stat($GIT_EXE) or die "stat: $!";
+        my @st = stat($GIT_EXE) or die "stat($GIT_EXE): $!";
         my $st = pack('dd', $st[10], $st[7]);
         if ($st ne $EXE_ST) {
                 my $rd = popen_rd([ $GIT_EXE, '--version' ]);
@@ -144,8 +145,7 @@ sub last_check_err {
 sub _sock_cmd {
         my ($self, $batch, $err_c) = @_;
         $self->{sock} and Carp::confess('BUG: {sock} exists');
-        my ($s1, $s2);
-        socketpair($s1, $s2, AF_UNIX, SOCK_STREAM, 0) or die "socketpair $!";
+        socketpair(my $s1, my $s2, AF_UNIX, SOCK_STREAM, 0);
         $s1->blocking(0);
         my $opt = { pgid => 0, 0 => $s2, 1 => $s2 };
         my $gd = $self->{git_dir};