chiark / gitweb /
Make readonly vs push configurable
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Sun, 19 Jul 2015 14:50:57 +0000 (15:50 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Sun, 19 Jul 2015 18:37:08 +0000 (19:37 +0100)
dgit
dgit.1

diff --git a/dgit b/dgit
index 247b2432c2d7ab95ad07b86a498639f2bbbc61fa..9e2e66e4841b4adb690225fab1def69b6229df6d 100755 (executable)
--- a/dgit
+++ b/dgit
@@ -547,16 +547,31 @@ sub access_quirk () {
     return ('none',undef);
 }
 
-our $access_forpush = 0;
+our $access_forpush;
 
-sub pushing () {
-    $access_forpush = 1;
+sub access_forpush_config () {
+    my $d = access_basedistro();
+    my $v = cfg("dgit-distro.$d.readonly", 'RETURN-UNDEF');
+    $v //= 'a';
+    return
+       $v =~ m/^[ty1]/ ? 0 : # force readonly,    forpush = 0
+       $v =~ m/^[fn0]/ ? 1 : # force nonreadonly, forpush = 1
+       $v =~ m/^[a]/  ? '' : # auto,              forpush = ''
+       badcfg "readonly needs t (true, y, 1) or f (false, n, 0) or a (auto)";
 }
 
 sub access_forpush () {
+    $access_forpush //= access_forpush_config();
     return $access_forpush;
 }
 
+sub pushing () {
+    die "$access_forpush ?" if ($access_forpush // 1) ne 1;
+    badcfg "pushing but distro is configured readonly"
+       if access_forpush_config() eq '0';
+    $access_forpush = 1;
+}
+
 sub access_distros () {
     # Returns list of distros to try, in order
     #
@@ -3041,6 +3056,7 @@ my $cmd = shift @ARGV;
 $cmd =~ y/-/_/;
 
 if (!defined $quilt_mode) {
+    local $access_forpush;
     $quilt_mode = cfg('dgit.force.quilt-mode', 'RETURN-UNDEF')
        // access_cfg('quilt-mode', 'RETURN-UNDEF')
        // 'linear';
diff --git a/dgit.1 b/dgit.1
index 3e402e19022a4edd0435dad81da9857a76f6520c..dd083ac5eb2e84a70f5c775f30c887aff6d58ef4 100644 (file)
--- a/dgit.1
+++ b/dgit.1
@@ -597,6 +597,14 @@ on the dgit command line.
 .TP
 .BI dgit.default.distro
 .TP
+.BR dgit-distro. \fIdistro\fR .readonly " " auto | true | false
+.TP
+.BR dgit-distro. \fIdistro\fR /push. *
+If set, overrides corresponding non \fB/push\fR config when
+.BR readonly=false ,
+or when pushing and
+.BR readonly=auto .
+.TP
 .BI dgit-distro. distro .username
 .TP
 .BI dgit-distro. distro .git-url