chiark / gitweb /
Check for rpush protocol version incompatibility and crash early if incompatible.
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Sun, 10 Aug 2014 20:26:39 +0000 (21:26 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Sun, 10 Aug 2014 20:31:20 +0000 (21:31 +0100)
debian/changelog
dgit

index 3dd38e4c434a847ed870b49444856465317e6609..d89b41ee7ab0fd38e21454d921c1430e7c5f82c4 100644 (file)
@@ -20,6 +20,8 @@ dgit (0.22~experimental1) experimental; urgency=low
   Minor improvements:
   * Include canonicalised suite name in signed tag message.
   * Mention cross-version dgit rpush incompatibility in manpage.
+  * Check for rpush protocol version incompatibility and crash early
+    if incompatible.
   * New script tests/using-intree for running tests on the source tree.
   * Do not spew diff output to terminal (by default).  Print sensible
     message instead.  Closes:#736526.
diff --git a/dgit b/dgit
index 40953871a6724b8c3015a4889e47aa275daac419..53ca56c0bc014a5d89fca5180524db39e5ab8fa6 100755 (executable)
--- a/dgit
+++ b/dgit
@@ -34,6 +34,8 @@ use Config;
 
 our $our_version = 'UNRELEASED'; ###substituted###
 
+our $rpushprotovsn = 2;
+
 our $isuite = 'unstable';
 our $idistro;
 our $package;
@@ -1727,12 +1729,15 @@ sub cmd_push {
 
 #---------- remote commands' implementation ----------
 
-sub cmd_remote_push_responder {
+sub cmd_remote_push_build_host {
     my ($nrargs) = shift @ARGV;
     my (@rargs) = @ARGV[0..$nrargs-1];
     @ARGV = @ARGV[$nrargs..$#ARGV];
     die unless @rargs;
-    my ($dir) = @rargs;
+    my ($dir,$vsnwant) = @rargs;
+    # vsnwant is a comma-separated list; we report which we have
+    # chosen in our ready response (so other end can tell if they
+    # offered several)
     $debugprefix = ' ';
     $we_are_responder = 1;
 
@@ -1743,12 +1748,21 @@ sub cmd_remote_push_responder {
     open STDOUT, ">&STDERR" or die $!;
     autoflush STDOUT 1;
 
-    responder_send_command("dgit-remote-push-ready");
+    $vsnwant //= 1;
+    fail "build host has dgit rpush protocol version".
+       " $rpushprotovsn but invocation host has $vsnwant"
+       unless grep { $rpushprotovsn eq $_ } split /,/, $vsnwant;
+
+    responder_send_command("dgit-remote-push-ready $rpushprotovsn");
 
     changedir $dir;
     &cmd_push;
 }
 
+sub cmd_remote_push_responder { cmd_remote_push_build_host(); }
+# ... for compatibility with proto vsn.1 dgit (just so that user gets
+#     a good error message)
+
 our $i_tmp;
 
 sub i_cleanup {
@@ -1784,11 +1798,11 @@ sub cmd_rpush {
        $dir = nextarg;
     }
     $dir =~ s{^-}{./-};
-    my @rargs = ($dir);
+    my @rargs = ($dir,$rpushprotovsn);
     my @rdgit;
     push @rdgit, @dgit;
     push @rdgit, @ropts;
-    push @rdgit, qw(remote-push-responder), (scalar @rargs), @rargs;
+    push @rdgit, qw(remote-push-build-host), (scalar @rargs), @rargs;
     push @rdgit, @ARGV;
     my @cmd = (@ssh, $host, shellquote @rdgit);
     printcmd \*DEBUG,$debugprefix."+",@cmd;