chiark / gitweb /
Test suite: move t-commit and break out t-policy (nfc)
[dgit.git] / dgit
diff --git a/dgit b/dgit
index 759df20e5df761a58e05418538283e48003ebb07..c315c7f1606846ae74dde955052254b3ba5b8f76 100755 (executable)
--- a/dgit
+++ b/dgit
@@ -111,6 +111,8 @@ sub lref () { return "refs/heads/".lbranch(); }
 sub lrref () { return "refs/remotes/$remotename/".server_branch($csuite); }
 sub rrref () { return server_ref($csuite); }
 
+sub lrfetchrefs () { return "refs/dgit-fetch/$isuite"; }
+
 sub stripepoch ($) {
     my ($vsn) = @_;
     $vsn =~ s/^\d+\://;
@@ -162,6 +164,11 @@ sub deliberately ($) {
     return !!grep { $_ eq "--deliberately-$enquiry" } @deliberatelies;
 }
 
+sub deliberately_not_fast_forward () {
+    deliberately('not-fast-forward') ||
+       deliberately('TEST-not-fast-forward-dgit-only');
+}
+
 #---------- remote protocol support, common ----------
 
 # remote push initiator/responder protocol:
@@ -1256,6 +1263,11 @@ sub ensure_we_have_orig () {
 
 sub git_fetch_us () {
     runcmd_ordryrun_local @git, qw(fetch),access_giturl(),fetchspec();
+    if (deliberately_not_fast_forward) {
+       runcmd_ordryrun_local @git, qw(fetch -p), access_giturl(),
+           map { "+refs/$_/*:".lrfetchrefs."/$_/*" }
+           qw(tags heads);
+    }
 }
 
 sub fetch_from_archive () {
@@ -1648,11 +1660,12 @@ sub dopush ($) {
     responder_send_command("param head $head");
     responder_send_command("param csuite $csuite");
 
-    if ($forceflag && defined $lastpush_hash) {
-       git_for_each_tag_referring($lastpush_hash, sub {
-           my ($tagobjid,$refobjid,$fullrefname,$tagname) = @_;
-           responder_send_command("supersedes $fullrefname=$tagobjid");
-           $supersedes{$fullrefname} = $tagobjid;
+    if ($forceflag) {
+       git_for_each_ref(lrfetchrefs, sub {
+           my ($objid,$objtype,$lrfetchrefname,$reftail) = @_;
+           my $rrefname= substr($lrfetchrefname, length(lrfetchrefs) + 1);
+           responder_send_command("supersedes $rrefname=$objid");
+           $supersedes{$rrefname} = $objid;
        });
     }
 
@@ -1816,8 +1829,7 @@ sub cmd_push {
     if (fetch_from_archive()) {
        if (is_fast_fwd(lrref(), 'HEAD')) {
            # ok
-       } elsif (deliberately('not-fast-forward') ||
-                deliberately('TEST-not-fast-forward-dgit-only')) {
+       } elsif (deliberately_not_fast_forward) {
            $forceflag = '+';
        } else {
            fail "dgit push: HEAD is not a descendant".