+ config_dir() . '/config';
+}
+
+sub git_config_dump {
+ my ($file) = @_;
+ my ($in, $out);
+ my @cmd = (qw/git config/, "--file=$file", '-l');
+ my $cmd = join(' ', @cmd);
+ my $fh = popen_rd(\@cmd) or die "popen_rd failed for $file: $!\n";
+ my %rv;
+ local $/ = "\n";
+ while (defined(my $line = <$fh>)) {
+ chomp $line;
+ my ($k, $v) = split(/=/, $line, 2);
+ my $cur = $rv{$k};
+
+ if (defined $cur) {
+ if (ref($cur) eq "ARRAY") {
+ push @$cur, $v;
+ } else {
+ $rv{$k} = [ $cur, $v ];
+ }
+ } else {
+ $rv{$k} = $v;
+ }
+ }
+ close $fh or die "failed to close ($cmd) pipe: $?";
+
+ \%rv;
+}
+
+sub _fill {
+ my ($self, $pfx) = @_;
+ my $rv = {};
+
+ foreach my $k (qw(mainrepo filter url newsgroup
+ infourl watch watchheader httpbackendmax
+ replyto feedmax nntpserver)) {
+ my $v = $self->{"$pfx.$k"};
+ $rv->{$k} = $v if defined $v;
+ }
+ foreach my $k (qw(obfuscate)) {
+ my $v = $self->{"$pfx.$k"};
+ defined $v or next;
+ if ($v =~ /\A(?:false|no|off|0)\z/) {
+ $rv->{$k} = 0;
+ } elsif ($v =~ /\A(?:true|yes|on|1)\z/) {
+ $rv->{$k} = 1;
+ } else {
+ warn "Ignoring $pfx.$k=$v in config, not boolean\n";
+ }
+ }
+ # TODO: more arrays, we should support multi-value for
+ # more things to encourage decentralization
+ foreach my $k (qw(address altid nntpmirror)) {
+ if (defined(my $v = $self->{"$pfx.$k"})) {
+ $rv->{$k} = ref($v) eq 'ARRAY' ? $v : [ $v ];
+ }
+ }
+
+ return unless $rv->{mainrepo};
+ my $name = $pfx;
+ $name =~ s/\Apublicinbox\.//;
+ $rv->{name} = $name;
+ $rv->{-pi_config} = $self;
+ $rv = PublicInbox::Inbox->new($rv);
+ foreach (@{$rv->{address}}) {
+ my $lc_addr = lc($_);
+ $self->{-by_addr}->{$lc_addr} = $rv;
+ $self->{-no_obfuscate}->{$lc_addr} = 1;
+ }
+ if (my $ng = $rv->{newsgroup}) {
+ $self->{-by_newsgroup}->{$ng} = $rv;
+ }
+ $self->{-by_name}->{$name} = $rv;
+ if ($rv->{obfuscate}) {
+ $rv->{-no_obfuscate} = $self->{-no_obfuscate};
+ $rv->{-no_obfuscate_re} = $self->{-no_obfuscate_re};
+ each_inbox($self, sub {}); # noop to populate -no_obfuscate
+ }
+ $rv