From: Eric Wong Date: Mon, 28 Nov 2022 05:32:10 +0000 (+0000) Subject: clone|fetch: support passing --prune(-tags) to `git fetch' X-Git-Url: http://www.git.stargrave.org/?p=public-inbox.git;a=commitdiff_plain;h=37131af8eb12f6b0d715fd291c885cafec8be577 clone|fetch: support passing --prune(-tags) to `git fetch' We need to be able to get rid of removed branches and tags on the remote. --prune-tags is implied for non-objstore repos, and incompatible with objstore repos. --- diff --git a/Documentation/public-inbox-clone.pod b/Documentation/public-inbox-clone.pod index 9288b175..bcf7dcc1 100644 --- a/Documentation/public-inbox-clone.pod +++ b/Documentation/public-inbox-clone.pod @@ -104,6 +104,13 @@ C directory. If only C<--manifest => is specified where C is an empty string (C<"">), then C (C<$DESTINATION/manifest.js.gz>) is the implied value of C. +=item -p + +=item --prune + +Pass the C<--prune> and C<--prune-tags> flags to L +calls on incremental clones. + =item -n =item --dry-run diff --git a/Documentation/public-inbox-fetch.pod b/Documentation/public-inbox-fetch.pod index c78ffc0b..c5e73d38 100644 --- a/Documentation/public-inbox-fetch.pod +++ b/Documentation/public-inbox-fetch.pod @@ -61,6 +61,12 @@ there are no updates: public-inbox-fetch -q --exit-code && public-inbox-index test $? -eq 0 || exit $? +=item -p + +=item --prune + +Pass the C<--prune> and C<--prune-tags> flags to L calls. + =item -v =item --verbose diff --git a/lib/PublicInbox/LeiMirror.pm b/lib/PublicInbox/LeiMirror.pm index 0e8689ca..2473c74b 100644 --- a/lib/PublicInbox/LeiMirror.pm +++ b/lib/PublicInbox/LeiMirror.pm @@ -275,6 +275,7 @@ sub fetch_args ($$) { push @cmd, '-q' if $lei->{opt}->{quiet} || ($lei->{opt}->{jobs} // 1) > 1; push @cmd, '-v' if $lei->{opt}->{verbose}; + push(@cmd, '-p') if $lei->{opt}->{prune}; @cmd; } @@ -527,6 +528,7 @@ sub resume_fetch { } my $cmd = [ @{$self->{-torsocks}}, @git, fetch_args($self->{lei}, $opt), $rn ]; + push @$cmd, '-P' if $self->{lei}->{prune}; # --prune-tags implied start_cmd($self, $cmd, $opt, $fini); } diff --git a/script/public-inbox-clone b/script/public-inbox-clone index 9a22fa21..df9ddd37 100755 --- a/script/public-inbox-clone +++ b/script/public-inbox-clone @@ -24,6 +24,7 @@ options: EOF GetOptions($opt, qw(help|h quiet|q verbose|v+ C=s@ c=s@ include|I=s@ exclude=s@ inbox-config=s inbox-version=i objstore=s manifest=s + prune|p dry-run|n jobs|j=i no-torsocks torsocks=s epoch=s)) or die $help; if ($opt->{help}) { print $help; exit }; require PublicInbox::Admin; # loads Config diff --git a/script/public-inbox-fetch b/script/public-inbox-fetch index 4b991a90..6fd15328 100755 --- a/script/public-inbox-fetch +++ b/script/public-inbox-fetch @@ -23,6 +23,7 @@ options: -C DIR chdir to specified directory EOF GetOptions($opt, qw(help|h quiet|q verbose|v+ C=s@ c=s@ try-remote|T=s@ + prune|p no-torsocks torsocks=s exit-code)) or die $help; if ($opt->{help}) { print $help; exit }; require PublicInbox::Fetch; # loads Admin