X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=dgit;h=9e2e66e4841b4adb690225fab1def69b6229df6d;hb=5cbfd93057610740cf7954ce3d29a2d14bacd603;hp=886e42b7a4fb1253e219740d288e6c02b67bf9bb;hpb=42dcfbc1690396c14a54b51050dd22bcdcdded76;p=dgit.git diff --git a/dgit b/dgit index 886e42b7..9e2e66e4 100755 --- a/dgit +++ b/dgit @@ -547,10 +547,29 @@ sub access_quirk () { return ('none',undef); } -our $access_pushing = 0; +our $access_forpush; + +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 () { - $access_pushing = 1; + 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 () { @@ -568,7 +587,7 @@ sub access_distros () { unshift @l, $instead_distro; @l = grep { defined } @l; - if ($access_pushing) { + if (access_forpush()) { @l = map { ("$_/push", $_) } @l; } @l; @@ -645,7 +664,7 @@ sub access_giturl (;$) { my ($optional) = @_; my $url = access_cfg('git-url','RETURN-UNDEF'); my $suffix; - if (!defined $url) { + if (!length $url) { my $proto = access_cfg('git-proto', 'RETURN-UNDEF'); return undef unless defined $proto; $url = @@ -3037,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';