From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: X-Spam-Status: No, score=-4.2 required=3.0 tests=ALL_TRUSTED,BAYES_00, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF shortcircuit=no autolearn=ham autolearn_force=no version=3.4.6 Received: from localhost (dcvr.yhbt.net [127.0.0.1]) by dcvr.yhbt.net (Postfix) with ESMTP id 555F81F47D for ; Wed, 8 Mar 2023 11:02:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=80x24.org; s=selector1; t=1678273378; bh=fCTpBd51J9fi/gDbxVJ03aDnmzH5DF77h3D8cBQD30w=; h=From:To:Subject:Date:From; b=egsGHeRInhkgMS1NIAyPEf5XUm6oyqXSOoqWUMchNn859G8wsEP/lfw5CLkf8hiFz BeSvZkRjoBYvgwVvxxdRtrDGvUoVjNn5lndouc6o8QtfCDJiji2GIBvNQSn2Z4SPYm IVhgjcFbzAPhf3YIWu2f5b36e92gT9DCOsTyRxTg= From: Eric Wong To: meta@public-inbox.org Subject: [PATCH] lei_mirror: unlink FETCH_HEAD when fetching forkgroups Date: Wed, 8 Mar 2023 11:02:58 +0000 Message-Id: <20230308110258.525501-1-e@80x24.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: 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 87311198..c148ebfd 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")) {;