X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?p=dgit.git;a=blobdiff_plain;f=dgit;h=cd1bbad3600dfe423759df3a3434cb0b6320d57f;hp=5fecf290fca31e8cde479562369beed1f1f647ae;hb=1589309dc4be0896692c0ab294a9953baea5ff33;hpb=226518037ab030a717936762712a0d9431c04a6f diff --git a/dgit b/dgit index 5fecf290..cd1bbad3 100755 --- a/dgit +++ b/dgit @@ -222,7 +222,7 @@ sub no_such_package () { sub changedir ($) { my ($newdir) = @_; printdebug "CD $newdir\n"; - chdir $newdir or die "chdir: $newdir: $!"; + chdir $newdir or confess "chdir: $newdir: $!"; } sub deliberately ($) { @@ -1802,9 +1802,11 @@ sub mergeinfo_version ($) { } sub fetch_from_archive () { - # Ensures that lrref() is what is actually in the archive, - # one way or another. If there is nothing in the archive, - # leaves lrref alone and returns 0. + # Ensures that lrref() is what is actually in the archive, one way + # 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. git_fetch_us must have already been called. get_archive_dsc(); if ($dsc) { @@ -1922,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 $!; @@ -1998,7 +2000,7 @@ But we were not able to obtain any version from the archive or git. END } unshift @end, $del_lrfetchrefs; - return 0; + return undef; } if ($lastfetch_hash && @@ -2149,7 +2151,7 @@ END lrfetchref_used lrfetchref(); unshift @end, $del_lrfetchrefs; - return 1; + return $hash; } sub set_local_git_config ($$) { @@ -2504,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"; @@ -2584,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 --),