From: Eric Wong <e@80x24.org>
To: meta@public-inbox.org
Subject: [PATCH] lei_mirror: use --no-write-fetch-head on git 2.29+
Date: Fri, 3 Feb 2023 03:46:03 +0000 [thread overview]
Message-ID: <20230203034603.3958259-1-e@80x24.org> (raw)
This avoids unnecessary writes to the FETCH_HEAD file, which is
worthless in multi-remote mirrors. Actually, I haven't found
FETCH_HEAD useful anywhere since the `/remotes/' namespace
became popular...
---
lib/PublicInbox/Git.pm | 5 +++++
lib/PublicInbox/LeiMirror.pm | 3 +++
2 files changed, 8 insertions(+)
diff --git a/lib/PublicInbox/Git.pm b/lib/PublicInbox/Git.pm
index fd7a0382..2729b38f 100644
--- a/lib/PublicInbox/Git.pm
+++ b/lib/PublicInbox/Git.pm
@@ -52,6 +52,11 @@ my %ESC_GIT = map { $GIT_ESC{$_} => $_ } keys %GIT_ESC;
my $EXE_ST = ''; # pack('dd', st_ctime, st_size);
my ($GIT_EXE, $GIT_VER);
+sub version {
+ check_git_exe();
+ $GIT_VER;
+}
+
sub check_git_exe () {
$GIT_EXE = which('git') // die "git not found in $ENV{PATH}";
my @st = stat($GIT_EXE) or die "stat: $!";
diff --git a/lib/PublicInbox/LeiMirror.pm b/lib/PublicInbox/LeiMirror.pm
index ec2b56df..4c564c84 100644
--- a/lib/PublicInbox/LeiMirror.pm
+++ b/lib/PublicInbox/LeiMirror.pm
@@ -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);
@@ -275,6 +276,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;
}
reply other threads:[~2023-02-03 3:46 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://public-inbox.org/README
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230203034603.3958259-1-e@80x24.org \
--to=e@80x24.org \
--cc=meta@public-inbox.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).