chiark / gitweb /
dgit: $isuite handling: Defer calls to access_* until first `want'
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Mon, 9 Jan 2017 16:07:15 +0000 (16:07 +0000)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Mon, 9 Jan 2017 16:07:15 +0000 (16:07 +0000)
pushing, rpush_handle_protovsn_bothends, and quiltmode, all depend on
access_*.  For that we need $isuite, but we only get that (in the form
of $csuite) from the build host.

We can move all of these calls into i_resp_want, which is called the
first time the build host actually wants something from us.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
dgit

diff --git a/dgit b/dgit
index 11f473ca8bf7c56096316094382db3f45f150a6e..f677562d3741190feabd702f957e1729130ccc76 100755 (executable)
--- a/dgit
+++ b/dgit
@@ -4440,7 +4440,6 @@ sub i_method {
 }
 
 sub cmd_rpush {
-    pushing();
     my $host = nextarg;
     my $dir;
     if ($host =~ m/^((?:[^][]|\[[^][]*\])*)\:/) {
@@ -4475,11 +4474,6 @@ sub cmd_rpush {
     die "$protovsn ?" unless grep { $_ eq $protovsn } @rpushprotovsn_support;
     $supplementary_message = '' unless $protovsn >= 3;
 
-    fail "rpush negotiated protocol version $protovsn".
-       " which does not support quilt mode $quilt_mode"
-       if quiltmode_splitbrain;
-
-    rpush_handle_protovsn_bothends();
     for (;;) {
        my ($icmd,$iargs) = initiator_expect {
            m/^(\S+)(?: (.*))?$/;
@@ -4543,6 +4537,17 @@ our %i_wanted;
 sub i_resp_want ($) {
     my ($keyword) = @_;
     die "$keyword ?" if $i_wanted{$keyword}++;
+    
+    defined $i_param{'csuite'} or badproto \*RO, "premature desire, no csuite";
+    $isuite = $i_param{'csuite'};
+
+    pushing();
+    rpush_handle_protovsn_bothends();
+
+    fail "rpush negotiated protocol version $protovsn".
+       " which does not support quilt mode $quilt_mode"
+       if quiltmode_splitbrain;
+
     my @localpaths = i_method "i_want", $keyword;
     printdebug "[[  $keyword @localpaths\n";
     foreach my $localpath (@localpaths) {