-sub onwardpush () {
- my @cmd = (qw(git send-pack), $destrepo,
- "$commit:refs/dgit/$suite",
- "$tagval:refs/tags/$tagname");
- debugcmd @cmd;
- $!=0;
- my $r = system @cmd;
- !$r or die "onward push failed: $r $!";
-}
+ if ($policy & FRESHREPO) {
+ # This is troublesome. We have been asked by the policy hook
+ # to receive the push into a fresh repo. But of course we
+ # have actually already mostly received the push into the working
+ # repo. (This is unavoidable because the instruction to use a new
+ # repo comes ultimately from the signed tag for the dgit push,
+ # which has to have been received into some repo.)
+ #
+ # So what we do is generate a fresh working repo right now and
+ # push the head and tag into it. The presence of this fresh
+ # working repo is detected by the parent, which responds by
+ # making a fresh master repo from the template.
+
+ $destrepo = "${workrepo}_fresh"; # workrepo lock covers
+ mkrepo_fromtemplate $destrepo;
+ }
+}