From 385a9f395604b0ec99190df2f1a0fb26c896f585 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Mon, 6 Feb 2023 05:56:35 +0000 Subject: [PATCH] lei_mirror: reduce `git config' usage We can use `git -c $KEY=$VAL fetch' with a random remote name that never makes it to a config file. --- lib/PublicInbox/LeiMirror.pm | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/lib/PublicInbox/LeiMirror.pm b/lib/PublicInbox/LeiMirror.pm index 4c564c84..f7184240 100644 --- a/lib/PublicInbox/LeiMirror.pm +++ b/lib/PublicInbox/LeiMirror.pm @@ -507,12 +507,9 @@ sub resume_fetch { my $dst = $self->{cur_dst} // $self->{dst}; my @git = ('git', "--git-dir=$dst"); my $opt = { 2 => $self->{lei}->{2} }; - my $rn = 'origin'; # configurable? + my $rn = 'random'.int(rand(1 << 30)); for ("url=$uri", "fetch=+refs/*:refs/*", 'mirror=true') { - my @kv = split(/=/, $_, 2); - $kv[0] = "remote.$rn.$kv[0]"; - next if $self->{dry_run}; - run_die([@git, 'config', @kv], undef, $opt); + push @git, '-c', "remote.$rn.$_"; } my $cmd = [ @{$self->{-torsocks}}, @git, fetch_args($self->{lei}, $opt), $rn ]; -- 2.44.0