chiark / gitweb /
Split tags: Preparation: Break out (and fix) need_tagformat
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Sun, 31 Jul 2016 16:47:44 +0000 (17:47 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Mon, 5 Sep 2016 12:41:47 +0000 (13:41 +0100)
No major functional change.

However, we do preserve the previous override value, so that
need_tagformat's caller is happy, we still override the access
configuration.

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

diff --git a/dgit b/dgit
index 7306d7d1214abfa0fa8216c21387fd962e164260..3137627d243a563013b0854a849a6575505a1755 100755 (executable)
--- a/dgit
+++ b/dgit
@@ -1138,6 +1138,15 @@ sub access_cfg_tagformats () {
     split /\,/, access_cfg('dgit-tag-format');
 }
 
+sub need_tagformat ($$) {
+    my ($fmt, $why) = @_;
+    fail "need to use tag format $fmt ($why) but also need".
+       " to use tag format $tagformat_want->[0] ($tagformat_want->[1])".
+       " - no way to proceed"
+       if $tagformat_want && $tagformat_want->[0] ne $fmt;
+    $tagformat_want = [$fmt, $why, $tagformat_want->[2] // 0];
+}
+
 sub select_tagformat () {
     # sets $tagformatfn
     return if $tagformatfn && !$tagformat_want;
@@ -2398,11 +2407,7 @@ sub cmd_remote_push_responder { cmd_remote_push_build_host(); }
 
 sub rpush_handle_protovsn_bothends () {
     if ($protovsn < 4) {
-       fail "rpush negotiated protocol version $protovsn".
-           " which supports old tag format only".
-           " but trying to use new format (".$tagformat_want->[1].")"
-           if $tagformat_want && $tagformat_want->[0] ne 'old';
-       $tagformat_want = ['old', "rpush negotiated protocol $protovsn", 0];
+       need_tagformat 'old', "rpush negotiated protocol $protovsn";
     }
     select_tagformat();
 }