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 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 306C51F626 for ; Mon, 20 Feb 2023 05:32:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=80x24.org; s=selector1; t=1676871123; bh=kKGSnfDqcQvFLQkkcpjRHz458ow69CSpF5n7oxhd9QU=; h=From:To:Subject:Date:From; b=o/bv0NCgwsFZTcggB61xL0b5x2HaM/JuMS66ncXtFO9P5x837jq0vyp/5eUxPIC37 JxclKj28jChkNk2FcncJ8rn2cauvzA8o/DAdA0pqJsXK2y/lNYchpGc0GqxoNT2rJ5 sWla70iBDukG7Aoc7vQhMbRBvI88MxFEc2CJx2eg= From: Eric Wong To: meta@public-inbox.org Subject: [PATCH] multi_git: do not set include.path if already set Date: Mon, 20 Feb 2023 05:32:02 +0000 Message-Id: <20230220053202.264027-1-e@80x24.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: 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. --- lib/PublicInbox/MultiGit.pm | 12 +++++++++--- 1 file 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 {