From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: X-Spam-Status: No, score=-4.0 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.2 Received: from localhost (dcvr.yhbt.net [127.0.0.1]) by dcvr.yhbt.net (Postfix) with ESMTP id C980D203BB for ; Mon, 28 Nov 2022 05:32:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=80x24.org; s=selector1; t=1669613567; bh=nOpwOwaz3JwNqaw1hbKjzv8seV8LrE7eNsHzocwaPhk=; h=From:To:Subject:Date:In-Reply-To:References:From; b=o07fBkBlKb63dQGbiJvvG+hhn7yR4vS6mupeIzRwQR/gkeDNFPzwFTAExLayC/uyE 6PAaUto4hE339dRVtXLm5nLXtJiq/Dh531e5CN+Trea5Gjlayt74VbZ1mvfsKlMfuu 32ZlyICqY1lhDSKvzimCmOajxOat1IAHvjPpcEEA= From: Eric Wong To: meta@public-inbox.org Subject: [PATCH 71/95] lei_mirror: delay configuring forkgroups Date: Mon, 28 Nov 2022 05:32:08 +0000 Message-Id: <20221128053232.291618-72-e@80x24.org> In-Reply-To: <20221128053232.291618-1-e@80x24.org> References: <20221128053232.291618-1-e@80x24.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: When relying on `public-inbox-clone --manifest=', idempotent `git config' invocations can take a considerable amount of time. We still configure inboxes idempotently since it allows quickly changing URLs to mirrors, but we just defer it until an update is actually needed. --- lib/PublicInbox/LeiMirror.pm | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/lib/PublicInbox/LeiMirror.pm b/lib/PublicInbox/LeiMirror.pm index 51cc6d05..0e8689ca 100644 --- a/lib/PublicInbox/LeiMirror.pm +++ b/lib/PublicInbox/LeiMirror.pm @@ -434,10 +434,10 @@ sub forkgroup_prep { my $os = $self->{-objstore} // return; my $fg = $self->{-ent}->{forkgroup} // return; my $dir = "$os/$fg.git"; - my @cmd = ('git', "--git-dir=$dir", 'config'); - my $opt = +{ map { $_ => $self->{lei}->{$_} } (0..2) }; if (!-d $dir && !$self->{dry_run}) { PublicInbox::Import::init_bare($dir); + my @cmd = ('git', "--git-dir=$dir", 'config'); + my $opt = { 2 => $self->{lei}->{2} }; for ('repack.useDeltaIslands=true', 'pack.island=refs/remotes/([^/]+)/') { run_die([@cmd, split(/=/, $_, 2)], undef, $opt); @@ -445,15 +445,6 @@ sub forkgroup_prep { } my $key = $self->{-key} // die 'BUG: no -key'; my $rn = substr(sha256_hex($key), 0, 16); - unless ($self->{dry_run}) { - # --no-tags is required to avoid conflicts - for ("url=$uri", "fetch=+refs/*:refs/remotes/$rn/*", - 'tagopt=--no-tags') { - my @kv = split(/=/, $_, 2); - $kv[0] = "remote.$rn.$kv[0]"; - run_die([@cmd, @kv], undef, $opt); - } - } if (!-d $self->{cur_dst} && !$self->{dry_run}) { my $alt = File::Spec->rel2abs("$dir/objects"); PublicInbox::Import::init_bare($self->{cur_dst}); @@ -480,7 +471,9 @@ sub forkgroup_prep { EOM close $fh or die "close($f): $!"; } - bless { %$self, -osdir => $dir, -remote => $rn }, __PACKAGE__; + bless { + %$self, -osdir => $dir, -remote => $rn, -uri => $uri + }, __PACKAGE__; } sub fp_done { @@ -547,6 +540,17 @@ sub fgrp_enqueue_maybe { sub fgrp_enqueue { my ($self, $fgrp) = @_; + my $opt = { 2 => $self->{lei}->{2} }; + # --no-tags is required to avoid conflicts + my $u = $fgrp->{-uri} // die 'BUG: no {-uri}'; + my $rn = $fgrp->{-remote} // die 'BUG: no {-remote}'; + my @cmd = ('git', "--git-dir=$fgrp->{-osdir}", 'config'); + for ("url=$u", "fetch=+refs/*:refs/remotes/$rn/*", 'tagopt=--no-tags') { + my @kv = split(/=/, $_, 2); + $kv[0] = "remote.$rn.$kv[0]"; + $self->{dry_run} ? $self->{lei}->qerr("# @cmd @kv") : + run_die([@cmd, @kv], undef, $opt); + } push @{$self->{fgrp_todo}->{$fgrp->{-osdir}}}, $fgrp; }