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,AWL,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 EED811F569 for ; Sun, 1 Oct 2023 02:43:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=80x24.org; s=selector1; t=1696128205; bh=wCJE4xe0P3bO1k9TZP+1VVNBnx1GG5CKftwjsvWkSBg=; h=From:To:Subject:Date:In-Reply-To:References:From; b=47TS4BfBxp/z94OhaskWiFGDzdL2mowJul25D7HNu0yer0jrWEPsFXLlTK2WsJJK7 7nTkB4ZtZDEeA0uNwUNwKV9pM9JGL6RVF6cW2loJhGwFmoj+A2kkAqK56smaIQEWlC xX2rlvWqLHwAW55bSUsREkk0EliSs6ZLipvL3OhM= From: Eric Wong To: spew@80x24.org Subject: [PATCH 07/16] git: improve error reporting Date: Sun, 1 Oct 2023 02:43:14 +0000 Message-ID: <20231001024323.1960491-7-e@80x24.org> In-Reply-To: <20231001024323.1960491-1-e@80x24.org> References: <20231001024323.1960491-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};