about summary refs log tree commit homepage
path: root/lib/PublicInbox/MultiGit.pm
diff options
context:
space:
mode:
Diffstat (limited to 'lib/PublicInbox/MultiGit.pm')
-rw-r--r--lib/PublicInbox/MultiGit.pm25
1 files changed, 15 insertions, 10 deletions
diff --git a/lib/PublicInbox/MultiGit.pm b/lib/PublicInbox/MultiGit.pm
index 9429a00c..b7691806 100644
--- a/lib/PublicInbox/MultiGit.pm
+++ b/lib/PublicInbox/MultiGit.pm
@@ -5,10 +5,12 @@
 package PublicInbox::MultiGit;
 use strict;
 use v5.10.1;
-use PublicInbox::Spawn qw(run_die);
+use PublicInbox::Spawn qw(run_die run_qx);
 use PublicInbox::Import;
 use File::Temp 0.19;
 use List::Util qw(max);
+use PublicInbox::IO qw(read_all);
+use autodie qw(chmod close rename);
 
 sub new {
         my ($cls, $topdir, $all, $epfx) = @_;
@@ -31,7 +33,7 @@ sub read_alternates {
                         qr!\A\Q../../$self->{epfx}\E/([0-9]+)\.git/objects\z! :
                         undef;
                 $$moderef = (stat($fh))[2] & 07777;
-                for my $rel (split(/^/m, do { local $/; <$fh> })) {
+                for my $rel (split(/^/m, read_all($fh, -s _))) {
                         chomp(my $dir = $rel);
                         my $score;
                         if (defined($is_edir) && $dir =~ $is_edir) {
@@ -67,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);
 }
 
@@ -108,8 +108,13 @@ sub fill_alternates {
 
 sub epoch_cfg_set {
         my ($self, $epoch_nr) = @_;
-        run_die([qw(git config -f), epoch_dir($self)."/$epoch_nr.git/config",
-                'include.path', "../../$self->{all}/config" ]);
+        my $f = epoch_dir($self)."/$epoch_nr.git/config";
+        my $v = "../../$self->{all}/config";
+        if (-r $f) {
+                chomp(my $x = run_qx([qw(git config -f), $f, 'include.path']));
+                return if $x eq $v;
+        }
+        run_die([qw(git config -f), $f, 'include.path', $v ]);
 }
 
 sub add_epoch {