chiark / gitweb /
dgit: Declare a "supersedes" in the signed tag for all previous refs/heads and refs...
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Wed, 27 May 2015 20:36:15 +0000 (21:36 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Sun, 31 May 2015 11:58:15 +0000 (12:58 +0100)
dgit

diff --git a/dgit b/dgit
index 6e9c304..c315c7f 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+\://;
@@ -1261,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 () {
@@ -1653,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;
        });
     }