From: Eric Wong <e@80x24.org>
To: meta@public-inbox.org
Subject: [PATCH] lei_mirror: unlink FETCH_HEAD when fetching forkgroups
Date: Wed, 8 Mar 2023 11:02:58 +0000 [thread overview]
Message-ID: <20230308110258.525501-1-e@80x24.org> (raw)
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")) {;
next reply other threads:[~2023-03-08 11:02 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-03-08 11:02 Eric Wong [this message]
2023-03-08 19:31 ` [PATCH] lei_mirror: unlink FETCH_HEAD when fetching forkgroups Konstantin Ryabitsev
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=20230308110258.525501-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).