unofficial mirror of meta@public-inbox.org
 help / color / mirror / Atom feed
* [PATCH] lei_mirror: unlink FETCH_HEAD when fetching forkgroups
@ 2023-03-08 11:02 Eric Wong
  2023-03-08 19:31 ` Konstantin Ryabitsev
  0 siblings, 1 reply; 2+ messages in thread
From: Eric Wong @ 2023-03-08 11:02 UTC (permalink / raw)
  To: meta

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")) {;

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] lei_mirror: unlink FETCH_HEAD when fetching forkgroups
  2023-03-08 11:02 [PATCH] lei_mirror: unlink FETCH_HEAD when fetching forkgroups Eric Wong
@ 2023-03-08 19:31 ` Konstantin Ryabitsev
  0 siblings, 0 replies; 2+ messages in thread
From: Konstantin Ryabitsev @ 2023-03-08 19:31 UTC (permalink / raw)
  To: Eric Wong; +Cc: meta

On Wed, Mar 08, 2023 at 11:02:58AM +0000, Eric Wong wrote:
> 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.

I'm pretty sure --no-write-fetch-head was added in response to me asking why
it's needed for bare repos in the first place. In grokmirror, we symlink it to
/dev/null, but you already know this probably.

-K

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2023-03-08 19:31 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-03-08 11:02 [PATCH] lei_mirror: unlink FETCH_HEAD when fetching forkgroups Eric Wong
2023-03-08 19:31 ` Konstantin Ryabitsev

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).