X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?p=dgit.git;a=blobdiff_plain;f=dgit;h=cd1bbad3600dfe423759df3a3434cb0b6320d57f;hp=a78e2fbc6d7e3ecc0011b397335dda90fcfc2b44;hb=1589309dc4be0896692c0ab294a9953baea5ff33;hpb=ffa77109e724cac602efcb292afd5e5be0f82881 diff --git a/dgit b/dgit index a78e2fbc..cd1bbad3 100755 --- a/dgit +++ b/dgit @@ -1806,7 +1806,7 @@ sub fetch_from_archive () { # or another, according to us - ie this client's # appropritaely-updated archive view. Also returns the commit id. # If there is nothing in the archive, leaves lrref alone and - # returns undef. + # returns undef. git_fetch_us must have already been called. get_archive_dsc(); if ($dsc) { @@ -1924,10 +1924,10 @@ sub fetch_from_archive () { my $del_lrfetchrefs = sub { changedir $cwd; my $gur; - printdebug "del_lrfetchrefs\n"; + printdebug "del_lrfetchrefs...\n"; foreach my $fullrefname (sort keys %lrfetchrefs_d) { my $objid = $lrfetchrefs_d{$fullrefname}; - printdebug "del_lrfetchrefs: $fullrefname=$objid.\n"; + printdebug "del_lrfetchrefs: $objid $fullrefname\n"; if (!$gur) { $gur ||= new IO::Handle; open $gur, "|-", qw(git update-ref --stdin) or die $!; @@ -2506,21 +2506,8 @@ END if (check_for_git()) { git_fetch_us(); } - my $forceflag = ''; - if (fetch_from_archive()) { - if (is_fast_fwd(lrref(), 'HEAD')) { - # ok - } elsif (deliberately_not_fast_forward) { - $forceflag = '+'; - } else { - fail "dgit push: HEAD is not a descendant". - " of the archive's version.\n". - "dgit: To overwrite its contents,". - " use git merge -s ours ".lrref().".\n". - "dgit: To rewind history, if permitted by the archive,". - " use --deliberately-not-fast-forward"; - } - } else { + my $archive_hash = fetch_from_archive(); + if (!$archive_hash) { $new_package or fail "package appears to be new in this suite;". " if this is intentional, use --new"; @@ -2586,6 +2573,23 @@ END } check_not_dirty(); + + my $forceflag = ''; + if ($archive_hash) { + if (is_fast_fwd($archive_hash, 'HEAD')) { + # ok + } elsif (deliberately_not_fast_forward) { + $forceflag = '+'; + } else { + fail "dgit push: HEAD is not a descendant". + " of the archive's version.\n". + "dgit: To overwrite its contents,". + " use git merge -s ours ".lrref().".\n". + "dgit: To rewind history, if permitted by the archive,". + " use --deliberately-not-fast-forward"; + } + } + changedir $ud; progress "checking that $dscfn corresponds to HEAD"; runcmd qw(dpkg-source -x --),