summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIan Jackson <ijackson@chiark.greenend.org.uk>2015-07-24 00:30:38 +0100
committerIan Jackson <ijackson@chiark.greenend.org.uk>2015-07-26 19:54:45 +0100
commit78ec9b7b05edf606cd489b1f091a20446f7a335f (patch)
treec331f239ba0c68b3ecab96bc4919b657f859045c
parentec22348eada556dc5f326186806890f34d5b6cc3 (diff)
rpush: Introduce more sophisticated protocol negotiation.
-rwxr-xr-xdgit26
1 files changed, 18 insertions, 8 deletions
diff --git a/dgit b/dgit
index 324a65f..8a54610 100755
--- a/dgit
+++ b/dgit
@@ -39,7 +39,8 @@ use Debian::Dgit;
our $our_version = 'UNRELEASED'; ###substituted###
-our $rpushprotovsn = 2;
+our @rpushprotovsn_support = qw(2);
+our $protovsn;
our $isuite = 'unstable';
our $idistro;
@@ -175,7 +176,9 @@ sub deliberately_not_fast_forward () {
#---------- remote protocol support, common ----------
# remote push initiator/responder protocol:
-# < dgit-remote-push-ready [optional extra info ignored by old initiators]
+# $ dgit remote-push-build-host <n-rargs> <rargs>... <push-args>...
+# where <rargs> is <push-host-dir> <supported-proto-vsn>,... ...
+# < dgit-remote-push-ready <actual-proto-vsn>
#
# > file parsed-changelog
# [indicates that output of dpkg-parsechangelog follows]
@@ -2104,11 +2107,16 @@ sub cmd_remote_push_build_host {
autoflush STDOUT 1;
$vsnwant //= 1;
- fail "build host has dgit rpush protocol version".
- " $rpushprotovsn but invocation host has $vsnwant"
- unless grep { $rpushprotovsn eq $_ } split /,/, $vsnwant;
+ ($protovsn) = grep {
+ $vsnwant =~ m{^(?:.*,)?$_(?:,.*)?$}
+ } @rpushprotovsn_support;
- responder_send_command("dgit-remote-push-ready $rpushprotovsn");
+ fail "build host has dgit rpush protocol versions ".
+ (join ",", @rpushprotovsn_support).
+ " but invocation host has $vsnwant"
+ unless defined $protovsn;
+
+ responder_send_command("dgit-remote-push-ready $protovsn");
changedir $dir;
&cmd_push;
@@ -2154,7 +2162,8 @@ sub cmd_rpush {
$dir = nextarg;
}
$dir =~ s{^-}{./-};
- my @rargs = ($dir,$rpushprotovsn);
+ my @rargs = ($dir);
+ push @rargs, join ",", @rpushprotovsn_support;
my @rdgit;
push @rdgit, @dgit;
push @rdgit, @ropts;
@@ -2172,7 +2181,8 @@ sub cmd_rpush {
}
$i_child_pid = open2(\*RO, \*RI, @cmd);
changedir $i_tmp;
- initiator_expect { m/^dgit-remote-push-ready/ };
+ ($protovsn) = initiator_expect { m/^dgit-remote-push-ready (\S+)/ };
+ die "$protovsn ?" unless grep { $_ eq $protovsn } @rpushprotovsn_support;
for (;;) {
my ($icmd,$iargs) = initiator_expect {
m/^(\S+)(?: (.*))?$/;