]> Sergey Matveev's repositories - public-inbox.git/blobdiff - lib/PublicInbox/LeiMirror.pm
lei_mirror: show non-ASCII owner properly w/ --verbose
[public-inbox.git] / lib / PublicInbox / LeiMirror.pm
index ec2b56dfeb89331c647e9ca35c4c53798d4a2d35..afe12bb30dd719e545224b348575ff52b82b3f92 100644 (file)
@@ -16,6 +16,7 @@ use Carp qw(croak);
 use URI;
 use PublicInbox::Config;
 use PublicInbox::Inbox;
+use PublicInbox::Git;
 use PublicInbox::LeiCurl;
 use PublicInbox::OnDestroy;
 use PublicInbox::SHA qw(sha256_hex sha1_hex);
@@ -258,7 +259,8 @@ sub run_reap {
 sub start_cmd {
        my ($self, $cmd, $opt, $fini) = @_;
        do_reap($self);
-       $self->{lei}->qerr("# @$cmd");
+       utf8::decode(my $msg = "# @$cmd");
+       $self->{lei}->qerr($msg);
        return if $self->{dry_run};
        $LIVE->{spawn($cmd, undef, $opt)} = [ \&reap_cmd, $self, $cmd, $fini ]
 }
@@ -275,6 +277,8 @@ sub fetch_args ($$) {
                        ($lei->{opt}->{jobs} // 1) > 1;
        push @cmd, '-v' if $lei->{opt}->{verbose};
        push(@cmd, '-p') if $lei->{opt}->{prune};
+       PublicInbox::Git::version() >= ((2 << 24) | (29 << 16)) and
+               push(@cmd, '--no-write-fetch-head');
        @cmd;
 }
 
@@ -504,12 +508,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 ];