$workrepo = "$dgitrepos/_tmp/${package}_incoming$$";
acquiretree($workrepo, 1);
runcmd qw(git clone -l -q --mirror), $destrepo, $workrepo;
+ rmtree "${workrepo}_fresh";
}
sub setupstunthook () {
debug " stunt hook set up $prerecv";
}
+sub dealwithfreshrepo () {
+ my $freshrepo = "${workrepo}_fresh";
+ if (!stat $freshrepo) {
+ $!==ENOENT or die "$freshrepo $!";
+ return;
+ }
+ $destrepo = $freshrepo;
+}
+
sub maybeinstallprospective () {
return if $destrepo eq $realdestrepo;
die Dumper(\%got)." -- missing refs in new repo"
if grep { !$_ } values %got;
+ movetogarbage; # in case of FRESHREPO
+
debug "install $destrepo => $realdestrepo";
rename $destrepo, $realdestrepo or die $!;
remove "$destrepo.lock" or die $!;
makeworkingclone();
setupstunthook();
runcmd qw(git receive-pack), $workrepo;
+ dealwithfreshrepo();
maybeinstallprospective();
}
chomp $mb;
$mb eq $oldcommit or reject "not fast forward on dgit branch";
}
+
+ 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;
+ }
}
sub stunthook () {