+ $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;
+ }
+ if (my $symlinks = $self->{-ent}->{symlinks}) {
+ my $top = File::Spec->rel2abs($self->{dst});
+ push @{$self->{-new_symlinks}}, @$symlinks;
+ for my $p (@$symlinks) {
+ my $ln = "$top/$p";
+ $ln =~ tr!/!/!s;
+ my (undef, $dn, $bn) = File::Spec->splitpath($ln);
+ File::Path::mkpath($dn);
+ my $tgt = "$top/$key";
+ $tgt = File::Spec->abs2rel($tgt, $dn);
+ if (lstat($ln)) {
+ if (-l _) {
+ next if readlink($ln) eq $tgt;
+ unlink($ln) or die "unlink($ln): $!";
+ } else {
+ push @{$self->{chg}->{badlink}}, $p;
+ }
+ }
+ symlink($tgt, $ln) or die "symlink($tgt, $ln): $!";
+ ++$self->{chg}->{nr_chg};
+ }
+ }
+ if (defined(my $t = $self->{-ent}->{modified})) {
+ my ($dn, $bn) = ("$dst/info/web", 'last-modified');
+ my $orig = PublicInbox::Git::try_cat("$dn/$bn");
+ $t = strftime('%F %T', gmtime($t))." +0000\n";
+ File::Path::mkpath($dn);
+ atomic_write($dn, $bn, $t) if $orig ne $t;
+ }
+