chiark / gitweb /
Tests: Introduce t-set-using-tmp and use it in lib and adhoc
[dgit.git] / dgit
diff --git a/dgit b/dgit
index 9a63e6540050f694227d30c2ea98fe0ef98ccaf8..3d3628093e0d42e4ae8d9ac4ed22b05c429611d6 100755 (executable)
--- a/dgit
+++ b/dgit
@@ -183,7 +183,8 @@ sub changedir ($) {
 }
 
 sub deliberately ($) {
-    return !!grep { $_[0] eq $_ } @deliberatelies;
+    my ($enquiry) = @_;
+    return !!grep { $_ eq "--deliberately-$enquiry" } @deliberatelies;
 }
 
 #---------- remote protocol support, common ----------
@@ -1657,7 +1658,8 @@ sub sign_changes ($) {
     }
 }
 
-sub dopush () {
+sub dopush ($) {
+    my ($forceflag) = @_;
     printdebug "actually entering push\n";
     prep_ud();
 
@@ -1736,7 +1738,6 @@ sub dopush () {
     responder_send_command("param head $head");
     responder_send_command("param csuite $csuite");
 
-    my $forceflag = deliberately('not-fast-forward') ? '+' : '';
     if ($forceflag && defined $lastpush_hash) {
        git_for_each_tag_referring($lastpush_hash, sub {
            my ($objid,$fullrefname,$tagname) = @_;
@@ -1901,17 +1902,27 @@ sub cmd_push {
     if (check_for_git()) {
        git_fetch_us();
     }
+    my $forceflag = '';
     if (fetch_from_archive()) {
-       is_fast_fwd(lrref(), 'HEAD') or
+       if (is_fast_fwd(lrref(), 'HEAD')) {
+           # ok
+       } elsif (deliberately('not-fast-forward') ||
+                deliberately('TEST-not-fast-forward-dgit-only')) {
+           $forceflag = '+';
+       } else {
            fail "dgit push: HEAD is not a descendant".
                " of the archive's version.\n".
-               "$us: To overwrite it, use git merge -s ours ".lrref().".";
+               "$us: To overwrite its contents,".
+               " use git merge -s ours ".lrref().".\n".
+               "$us: To rewind history, if permitted by the archive,".
+               " use --deliberately-not-fast-forward";
+       }
     } else {
        $new_package or
            fail "package appears to be new in this suite;".
                " if this is intentional, use --new";
     }
-    dopush();
+    dopush($forceflag);
 }
 
 #---------- remote commands' implementation ----------
@@ -2697,6 +2708,7 @@ sub cmd_archive_api_query {
     badusage "need only 1 subpath argument" unless @ARGV==1;
     my ($subpath) = @ARGV;
     my @cmd = archive_api_query_cmd($subpath);
+    debugcmd ">",@cmd;
     exec @cmd or fail "exec curl: $!\n";
 }
 
@@ -2783,7 +2795,7 @@ sub parseopts () {
            } elsif (m/^--no-rm-on-error$/s) {
                push @ropts, $_;
                $rmonerror = 0;
-           } elsif (m/^--deliberately-($suite_re)$/s) {
+           } elsif (m/^--deliberately-($deliberately_re)$/s) {
                push @ropts, $_;
                push @deliberatelies, $&;
            } else {