]> Sergey Matveev's repositories - public-inbox.git/commitdiff
lei_mirror: reduce `git config' usage
authorEric Wong <e@80x24.org>
Mon, 6 Feb 2023 05:56:35 +0000 (05:56 +0000)
committerEric Wong <e@80x24.org>
Mon, 6 Feb 2023 06:41:51 +0000 (06:41 +0000)
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

index 4c564c84f5b1db2055e66d1636a387fa299cdfb5..f718424026ac11b747d45554628e3feb9c05dc52 100644 (file)
@@ -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 ];