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, T_SCC_BODY_TEXT_LINE 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 5418F1F51A for ; Thu, 2 Nov 2023 09:35:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=80x24.org; s=selector1; t=1698917742; bh=cK+w+lUDc+RBz/MO9Aj+RwIpnjfbhu9OQyUe9vkzkkY=; h=From:To:Subject:Date:In-Reply-To:References:From; b=5Fn0nMSIOPUPJu2FaNJPj+98sCYIaAI4frvTCx0sFnLodrRUb21Da9MFVVX1MLmKp YO8DCADSwcB7+v5FbLbkhSp6fwY2qqIJff18jQB4YwJauBpdgFYBnHMZ/EWdD3rihZ mG0jaFzDi8Qzhm0hadwviWar7ikXZWqEaCnjePXU= From: Eric Wong To: meta@public-inbox.org Subject: [PATCH 06/14] multi_git: use autodie Date: Thu, 2 Nov 2023 09:35:31 +0000 Message-Id: <20231102093539.2067470-7-e@80x24.org> In-Reply-To: <20231102093539.2067470-1-e@80x24.org> References: <20231102093539.2067470-1-e@80x24.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: Trying to move away from half my code being "or die" statements... --- lib/PublicInbox/MultiGit.pm | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/lib/PublicInbox/MultiGit.pm b/lib/PublicInbox/MultiGit.pm index 9074758a..1e8eb47a 100644 --- a/lib/PublicInbox/MultiGit.pm +++ b/lib/PublicInbox/MultiGit.pm @@ -10,6 +10,7 @@ use PublicInbox::Import; use File::Temp 0.19; use List::Util qw(max); use PublicInbox::Git qw(read_all); +use autodie qw(chmod close rename); sub new { my ($cls, $topdir, $all, $epfx) = @_; @@ -68,12 +69,10 @@ sub write_alternates { my $out = join('', sort { $alt->{$b} <=> $alt->{$a} } keys %$alt); my $info_dir = "$all_dir/objects/info"; my $fh = File::Temp->new(TEMPLATE => 'alt-XXXX', DIR => $info_dir); - my $f = $fh->filename; - print $fh $out, @new or die "print($f): $!"; - chmod($mode, $fh) or die "fchmod($f): $!"; - close $fh or die "close($f): $!"; - my $fn = "$info_dir/alternates"; - rename($f, $fn) or die "rename($f, $fn): $!"; + print $fh $out, @new; + chmod($mode, $fh); + close $fh; + rename($fh->filename, "$info_dir/alternates"); $fh->unlink_on_destroy(0); }