From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: X-Spam-Status: No, score=-4.1 required=3.0 tests=ALL_TRUSTED,AWL,BAYES_00, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from localhost (dcvr.yhbt.net [127.0.0.1]) by dcvr.yhbt.net (Postfix) with ESMTP id E6283203BD for ; Mon, 28 Nov 2022 05:32:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=80x24.org; s=selector1; t=1669613571; bh=ln+SFLaAE417fm1aTyoeyetG/ollf53e88SrdFo8f34=; h=From:To:Subject:Date:In-Reply-To:References:From; b=hDdlj/bXwskjegEDPuZ6uovFQmN0abRn/m8C7Lh9v8eF/x52vIZGw7P3e9n2n3lXk 4wuIpKFPRZnPCYwg5Xuop3vxcP2qRBw4rGOsIqM7QToRLQz0eTd9rwVrqtCoMjO8hz R+aFxdDHpXze3CY5U3QYeifagZ6OZHbPlXHWT7xA= From: Eric Wong To: meta@public-inbox.org Subject: [PATCH 85/95] lei_mirror: set {head} from manifest Date: Mon, 28 Nov 2022 05:32:22 +0000 Message-Id: <20221128053232.291618-86-e@80x24.org> In-Reply-To: <20221128053232.291618-1-e@80x24.org> References: <20221128053232.291618-1-e@80x24.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: We handle symbolic refs properly, at least. It's also possible for $GIT_DIR/HEAD to contain a full SHA-1/SHA-256, and we'll support that by using update-ref --no-deref --- lib/PublicInbox/LeiMirror.pm | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/lib/PublicInbox/LeiMirror.pm b/lib/PublicInbox/LeiMirror.pm index f7db5a49..fc5bc88d 100644 --- a/lib/PublicInbox/LeiMirror.pm +++ b/lib/PublicInbox/LeiMirror.pm @@ -678,6 +678,23 @@ sub update_ent { my $done = PublicInbox::OnDestroy->new($$, \&up_fp_done, $self); start_cmd($self, $cmd, $opt, $done); } + + $new = $self->{-ent}->{head}; + $cur = $self->{-local_manifest}->{$key}->{head} // "\0"; + if (defined($new) && $new ne $cur) { + # n.b. grokmirror writes raw contents to $dst/HEAD w/o locking + my $cmd = [ 'git', "--git-dir=$dst" ]; + if ($new =~ s/\Aref: //) { + push @$cmd, qw(symbolic-ref HEAD), $new; + } elsif ($new =~ /\A[a-f0-9]{40,}\z/) { + push @$cmd, qw(update-ref --no-deref HEAD), $new; + } else { + undef $cmd; + warn "W: $key: {head} => `$new' not understood\n"; + } + start_cmd($self, $cmd, { 2 => $self->{lei}->{2} }) if $cmd; + } + $new = $self->{-ent}->{owner} // return; $cur = $self->{-local_manifest}->{$key}->{owner} // "\0"; return if $cur eq $new;