* [PATCH] lei_mirror: use --no-write-fetch-head on git 2.29+
@ 2023-02-03 3:46 Eric Wong
0 siblings, 0 replies; only message in thread
From: Eric Wong @ 2023-02-03 3:46 UTC (permalink / raw)
To: meta
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;
}
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2023-02-03 3:46 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-02-03 3:46 [PATCH] lei_mirror: use --no-write-fetch-head on git 2.29+ Eric Wong
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).