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.1 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 844A620196 for ; Mon, 28 Nov 2022 05:32:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=80x24.org; s=selector1; t=1669613562; bh=oKd1N4aT1nL9/iGUwumNXhz7m4KQx2lpWDogSDWxkXw=; h=From:To:Subject:Date:In-Reply-To:References:From; b=3PxV5oDWJRnTJRQSBjhT7CEqkL/RWLiPK4GApAUq7Y8KfKsdadnQW5yPPlk11ylOO m+ZS7eFGukxMXS37Cj6xchcnqp+WmJJ6HK00rjUglsNAC+WLq2QK2t1p9jhB642yUf FWkd+rZ65KAMlwuNaxzaf0uAevFgL+JCrcVK4mCc= From: Eric Wong To: meta@public-inbox.org Subject: [PATCH 47/95] lei_mirror: ensure git <1.8.5 fallback can use torsocks Date: Mon, 28 Nov 2022 05:31:44 +0000 Message-Id: <20221128053232.291618-48-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: Since we fall back to `git fetch' on versions of git without `git update-ref --stdin' support, we must also support torsocks use on Tor .onion URLs --- lib/PublicInbox/LeiMirror.pm | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/lib/PublicInbox/LeiMirror.pm b/lib/PublicInbox/LeiMirror.pm index 163f45ee..6efe23fa 100644 --- a/lib/PublicInbox/LeiMirror.pm +++ b/lib/PublicInbox/LeiMirror.pm @@ -283,7 +283,7 @@ sub fetch_args ($$) { sub fgrp_update_old ($) { # for git <1.8.5 my ($fgrp) = @_; - my $cmd = [ 'git', "--git-dir=$fgrp->{cur_dst}", + my $cmd = [ @{$fgrp->{-torsocks}}, 'git', "--git-dir=$fgrp->{cur_dst}", fetch_args($fgrp->{lei}, my $opt = {}) ]; $fgrp->{lei}->qerr("# @$cmd"); do_reap($fgrp); @@ -370,8 +370,8 @@ sub fgrp_fetched { } sub fgrp_fetch { - my ($fgrp, $pfx, $fini) = @_; - my $cmd = [ @$pfx, 'git', "--git-dir=$fgrp->{-osdir}", + my ($fgrp, $fini) = @_; + my $cmd = [ @{$fgrp->{-torsocks}}, 'git', "--git-dir=$fgrp->{-osdir}", fetch_args($fgrp->{lei}, my $opt = {}), $fgrp->{-remote} ]; $fgrp->{-fini} = $fini; @@ -436,10 +436,11 @@ sub clone_v1 { my $uri = URI->new($self->{cur_src} // $self->{src}); defined($lei->{opt}->{epoch}) and die "$uri is a v1 inbox, --epoch is not supported\n"; - my $pfx = $curl->torsocks($lei, $uri) or return; + $self->{-torsocks} //= $curl->torsocks($lei, $uri) or return; my $dst = $self->{cur_dst} // $self->{dst}; my $fini = PublicInbox::OnDestroy->new($$, \&v1_done, $self); - my $cmd = [ @$pfx, clone_cmd($lei, my $opt = {}), "$uri", $dst ]; + my $cmd = [ @{$self->{-torsocks}}, clone_cmd($lei, my $opt = {}), + "$uri", $dst ]; my $fgrp = forkgroup_prep($self, $uri); if (!defined($fgrp) && defined($self->{-ent})) { if (defined(my $ref = $self->{-ent}->{reference})) { @@ -447,7 +448,7 @@ sub clone_v1 { push @$cmd, '--reference', "$self->{dst}$ref"; } } - $fgrp ? fgrp_fetch($fgrp, $pfx, $fini) : + $fgrp ? fgrp_fetch($fgrp, $fini) : start_clone($self, $cmd, $opt, $fini); if (!$self->{-is_epoch} && $lei->{opt}->{'inbox-config'} =~ @@ -604,7 +605,7 @@ sub clone_v2_prep ($$;$) { my $lei = $self->{lei}; my $curl = $self->{curl} //= PublicInbox::LeiCurl->new($lei) or return; my $first_uri = (map { $_->[0] } values %$v2_epochs)[0]; - my $pfx = $curl->torsocks($lei, $first_uri) or return; + $self->{-torsocks} //= $curl->torsocks($lei, $first_uri) or return; my $dst = $self->{cur_dst} // $self->{dst}; my $want = parse_epochs($lei->{opt}->{epoch}, $v2_epochs); my $task = $m ? bless { %$self }, __PACKAGE__ : $self;