diff options
author | Eric Wong <e@80x24.org> | 2022-11-28 05:32:22 +0000 |
---|---|---|
committer | Eric Wong <e@80x24.org> | 2022-11-28 23:38:59 +0000 |
commit | 3f36a5060302417a24a1fbacd8860a620298485c (patch) | |
tree | 872d299a57844dcf331a270d13f223315c1a64f0 /lib/PublicInbox | |
parent | 5cb15eabbd8df11656081f4ff504fc6c9a82a37a (diff) | |
download | public-inbox-3f36a5060302417a24a1fbacd8860a620298485c.tar.gz |
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
Diffstat (limited to 'lib/PublicInbox')
-rw-r--r-- | lib/PublicInbox/LeiMirror.pm | 17 |
1 files changed, 17 insertions, 0 deletions
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; |