From: Eric Wong Date: Thu, 2 Nov 2023 09:35:31 +0000 (+0000) Subject: multi_git: use autodie X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0ca758006938f6f5569f196b0080c22b33aada31;p=thirdparty%2Fpublic-inbox.git multi_git: use autodie Trying to move away from half my code being "or die" statements... --- 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); }