X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=dgit;h=c315c7f1606846ae74dde955052254b3ba5b8f76;hb=fdab645ff4e8fcdde3aa2fb0127b58dfc18a4f9a;hp=42f9f457332655cae0832baec4c03c4029fcad50;hpb=0c838feda384f115a115ddd609eca9b8c6ece162;p=dgit.git diff --git a/dgit b/dgit index 42f9f457..c315c7f1 100755 --- 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 ($objid,$refobjid,$fullrefname,$tagname) = @_; - responder_send_command("supersedes $fullrefname=$objid"); - $supersedes{$fullrefname} = $objid; + 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".