about summary refs log tree commit homepage
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2023-02-20 05:32:02 +0000
committerEric Wong <e@80x24.org>2023-02-20 17:20:56 +0000
commit2e80069c1de234be0ee569b4edb498f27a909c42 (patch)
treed8b1b1eed1ebac2c2f9f4ce1391fd9af7e18057f
parent0209a6a96c44fbecd4a13325a7cd109da86a147f (diff)
downloadpublic-inbox-2e80069c1de234be0ee569b4edb498f27a909c42.tar.gz
The epoch may already be read-only, and we don't need to cause
more I/O traffic and disk wear for no-op stuff.  This fixes
idempotent use of public-inbox-clone to update multi-epoch
inboxes.
-rw-r--r--lib/PublicInbox/MultiGit.pm12
1 files changed, 9 insertions, 3 deletions
diff --git a/lib/PublicInbox/MultiGit.pm b/lib/PublicInbox/MultiGit.pm
index 9429a00c..74a9e1df 100644
--- a/lib/PublicInbox/MultiGit.pm
+++ b/lib/PublicInbox/MultiGit.pm
@@ -5,7 +5,7 @@
 package PublicInbox::MultiGit;
 use strict;
 use v5.10.1;
-use PublicInbox::Spawn qw(run_die);
+use PublicInbox::Spawn qw(run_die popen_rd);
 use PublicInbox::Import;
 use File::Temp 0.19;
 use List::Util qw(max);
@@ -108,8 +108,14 @@ 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) {
+                my $rd = popen_rd([qw(git config -f), $f, 'include.path']);
+                chomp(my $have = <$rd> // '');
+                return if $have eq $v;
+        }
+        run_die([qw(git config -f), $f, 'include.path', $v ]);
 }
 
 sub add_epoch {