From b34cdf2c58754bf620badbaf30f5cecb0c11905c Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Wed, 8 Mar 2023 11:02:58 +0000 Subject: [PATCH] lei_mirror: unlink FETCH_HEAD when fetching forkgroups Apparently, --no-write-fetch-head is broken in current git[1]. It also wasn't in older git, at all. So just unlink FETCH_HEAD as we see it, but keep using --no-write-fetch-head to avoid the syscall and I/O overhead when we can. [1] https://yhbt.net/lore/git/20230308100438.908471-1-e@80x24.org/ --- lib/PublicInbox/LeiMirror.pm | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/lib/PublicInbox/LeiMirror.pm b/lib/PublicInbox/LeiMirror.pm index 873111987..c148ebfd6 100644 --- a/lib/PublicInbox/LeiMirror.pm +++ b/lib/PublicInbox/LeiMirror.pm @@ -358,11 +358,18 @@ sub pack_refs { start_cmd($self, $cmd, { 2 => $self->{lei}->{2} }); } +sub unlink_fetch_head ($) { + my ($git_dir) = @_; + return if unlink("$git_dir/FETCH_HEAD") || $!{ENOENT}; + warn "W: unlink($git_dir/FETCH_HEAD): $!"; +} + sub fgrpv_done { my ($fgrpv) = @_; return if !$LIVE; my $first = $fgrpv->[0] // die 'BUG: no fgrpv->[0]'; return if !keep_going($first); + unlink_fetch_head($first->{-osdir}) if !$first->{dry_run}; pack_refs($first, $first->{-osdir}); # objstore refs always packed for my $fgrp (@$fgrpv) { my $rn = $fgrp->{-remote}; @@ -817,6 +824,7 @@ sub v1_done { # called via OnDestroy return if $self->{dry_run} || !keep_going($self); _write_inbox_config($self); my $dst = $self->{cur_dst} // $self->{dst}; + unlink_fetch_head($dst); update_ent($self) if $self->{-ent}; my $o = "$dst/objects"; if (open(my $fh, '<', my $fn = "$o/info/alternates")) {; -- 2.47.2