chiark / gitweb /
dgit: Break out access_cfg_tagformats_can_splitbrain
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Thu, 15 Dec 2016 00:52:34 +0000 (00:52 +0000)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Mon, 19 Dec 2016 16:58:57 +0000 (16:58 +0000)
While we're at it, use a hash %y rather than repeatedly grepping.

No overall functional change.

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

diff --git a/dgit b/dgit
index c280016..1a23d1a 100755 (executable)
--- a/dgit
+++ b/dgit
@@ -1519,6 +1519,15 @@ sub access_cfg_tagformats () {
     split /\,/, access_cfg('dgit-tag-format');
 }
 
+sub access_cfg_tagformats_can_splitbrain () {
+    my %y = map { $_ => 1 } access_cfg_tagformats;
+    foreach my $needtf (qw(new maint)) {
+       next if $y{$needtf};
+       return 0;
+    }
+    return 1;
+}
+
 sub need_tagformat ($$) {
     my ($fmt, $why) = @_;
     fail "need to use tag format $fmt ($why) but also need".
@@ -4912,13 +4921,10 @@ sub build_maybe_quilt_fixup () {
     check_for_vendor_patches();
 
     if (quiltmode_splitbrain) {
-       foreach my $needtf (qw(new maint)) {
-           next if grep { $_ eq $needtf } access_cfg_tagformats;
-           fail <<END
+       fail <<END unless access_cfg_tagformats_can_splitbrain;
 quilt mode $quilt_mode requires split view so server needs to support
  both "new" and "maint" tag formats, but config says it doesn't.
 END
-       }
     }
 
     my $clogp = parsechangelog();