]> Sergey Matveev's repositories - public-inbox.git/commitdiff
lei_mirror: use --no-write-fetch-head on git 2.29+
authorEric Wong <e@80x24.org>
Fri, 3 Feb 2023 03:46:03 +0000 (03:46 +0000)
committerEric Wong <e@80x24.org>
Fri, 3 Feb 2023 21:54:11 +0000 (21:54 +0000)
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
lib/PublicInbox/LeiMirror.pm

index fd7a03823d7b5d2faeaa0cad3b02f525220f2275..2729b38fd9c0404295953b06486b613d1712fb4b 100644 (file)
@@ -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: $!";
index ec2b56dfeb89331c647e9ca35c4c53798d4a2d35..4c564c84f5b1db2055e66d1636a387fa299cdfb5 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);
@@ -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;
 }