From 0ca758006938f6f5569f196b0080c22b33aada31 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Thu, 2 Nov 2023 09:35:31 +0000 Subject: [PATCH] multi_git: use autodie 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 9074758a7..1e8eb47a5 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); } -- 2.47.2