From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: X-Spam-Status: No, score=-4.2 required=3.0 tests=ALL_TRUSTED,BAYES_00, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF shortcircuit=no autolearn=ham autolearn_force=no version=3.4.6 Received: from localhost (dcvr.yhbt.net [127.0.0.1]) by dcvr.yhbt.net (Postfix) with ESMTP id 679141F567 for ; Sun, 1 Oct 2023 09:54:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=80x24.org; s=selector1; t=1696154070; bh=wCJE4xe0P3bO1k9TZP+1VVNBnx1GG5CKftwjsvWkSBg=; h=From:To:Subject:Date:In-Reply-To:References:From; b=R82r67qknlptyUnmEvtxodj1HRtINx19uullr8i0aGMuZFZ3lcaS517YEVstOKky0 Ch4OwHyc7T2M8vxMECpfgy65QdYVEwUKqV6BMXIA5kLtl4l4HZ9Y4iDLg+1KHssSjU gMbu6M9Xh8YN87MXSmjzZ4YyKe2TC5PfnPrZUD4s= From: Eric Wong To: meta@public-inbox.org Subject: [PATCH 04/13] git: improve error reporting Date: Sun, 1 Oct 2023 09:54:20 +0000 Message-ID: <20231001095429.2092610-5-e@80x24.org> In-Reply-To: <20231001095429.2092610-1-e@80x24.org> References: <20231001095429.2092610-1-e@80x24.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: 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. --- lib/PublicInbox/Git.pm | 6 +++--- 1 file 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};