about summary refs log tree commit homepage
path: root/lib/PublicInbox/NetReader.pm
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2023-10-03 06:43:47 +0000
committerEric Wong <e@80x24.org>2023-10-03 10:16:05 +0000
commitd0a8dd236f768965aa9c034975412d526dab8a01 (patch)
tree2812b2965b48a919457c51edaa174869d623747b /lib/PublicInbox/NetReader.pm
parentf751ae24b9a4595f2feb493a21d2b18c27210688 (diff)
downloadpublic-inbox-d0a8dd236f768965aa9c034975412d526dab8a01.tar.gz
When using --get-urlmatch, we need a way to distinguish between
between key-only or a `key=val' pair even if the `val' is empty.
In other words, git interprets `-c imap.debug' as true and
`-c imap.debug=' as false, but an untyped --get-urlmatch
invocation has no way to distinguish between them.

So we must specify we want `--bool' (we're avoiding `--type=bool'
since that only appears in git 2.18+)

Fixes: f170d220f876 (lei: fix `-c NAME=VALUE' config support)
Diffstat (limited to 'lib/PublicInbox/NetReader.pm')
-rw-r--r--lib/PublicInbox/NetReader.pm18
1 files changed, 5 insertions, 13 deletions
diff --git a/lib/PublicInbox/NetReader.pm b/lib/PublicInbox/NetReader.pm
index e14b5805..5819f210 100644
--- a/lib/PublicInbox/NetReader.pm
+++ b/lib/PublicInbox/NetReader.pm
@@ -319,14 +319,6 @@ sub cfg_intvl ($$$) {
         }
 }
 
-sub cfg_bool ($$$) {
-        my ($cfg, $key, $url) = @_;
-        my $orig = $cfg->urlmatch($key, $url) // return;
-        my $bool = $cfg->git_bool($orig);
-        warn "W: $key=$orig for $url is not boolean\n" unless defined($bool);
-        $bool;
-}
-
 # flesh out common IMAP-specific data structures
 sub imap_common_init ($;$) {
         my ($self, $lei) = @_;
@@ -344,8 +336,8 @@ sub imap_common_init ($;$) {
 
                 # knobs directly for Mail::IMAPClient->new
                 for my $k (qw(Starttls Debug Compress)) {
-                        my $bool = cfg_bool($cfg, "imap.$k", $$uri) // next;
-                        $mic_common->{$sec}->{$k} = $bool;
+                        my $v = $cfg->urlmatch('--bool', "imap.$k", $$uri);
+                        $mic_common->{$sec}->{$k} = $v if defined $v;
                 }
                 my $to = cfg_intvl($cfg, 'imap.timeout', $$uri);
                 $mic_common->{$sec}->{Timeout} = $to if $to;
@@ -398,7 +390,7 @@ sub nntp_common_init ($;$) {
                 my $args = $nn_common->{$sec} //= {};
 
                 # Debug and Timeout are passed to Net::NNTP->new
-                my $v = cfg_bool($cfg, 'nntp.Debug', $$uri);
+                my $v = $cfg->urlmatch(qw(--bool nntp.Debug), $$uri);
                 $args->{Debug} = $v if defined $v;
                 my $to = cfg_intvl($cfg, 'nntp.Timeout', $$uri);
                 $args->{Timeout} = $to if $to;
@@ -407,8 +399,8 @@ sub nntp_common_init ($;$) {
 
                 # Net::NNTP post-connect commands
                 for my $k (qw(starttls compress)) {
-                        $v = cfg_bool($cfg, "nntp.$k", $$uri) // next;
-                        $self->{cfg_opt}->{$sec}->{$k} = $v;
+                        $v = $cfg->urlmatch('--bool', "nntp.$k", $$uri);
+                        $self->{cfg_opt}->{$sec}->{$k} = $v if defined $v;
                 }
 
                 # -watch internal option