-# Copyright (C) 2014-2021 all contributors <meta@public-inbox.org>
+# Copyright (C) all contributors <meta@public-inbox.org>
# License: AGPL-3.0+ <https://www.gnu.org/licenses/agpl-3.0.txt>
#
# Used throughout the project for reading configuration
use PublicInbox::Inbox;
use PublicInbox::Spawn qw(popen_rd);
our $LD_PRELOAD = $ENV{LD_PRELOAD}; # only valid at startup
+our $DEDUPE; # set to {} to dedupe or clear cache
sub _array ($) { ref($_[0]) eq 'ARRAY' ? $_[0] : [ $_[0] ] }
my ($class, $file, $errfh) = @_;
$file //= default_file();
my $self;
+ my $set_dedupe;
if (ref($file) eq 'SCALAR') { # used by some tests
open my $fh, '<', $file or die; # PerlIO::scalar
$self = config_fh_parse($fh, "\n", '=');
bless $self, $class;
} else {
+ if (-f $file && $DEDUPE) {
+ $file = rel2abs_collapsed($file);
+ $self = $DEDUPE->{$file} and return $self;
+ $set_dedupe = 1;
+ }
$self = git_config_dump($class, $file, $errfh);
$self->{'-f'} = $file;
}
if (my $css = delete $self->{'publicinbox.css'}) {
$self->{css} = _array($css);
}
-
+ $DEDUPE->{$file} = $self if $set_dedupe;
$self;
}
$git->{cgit_url} = $cgits = _array($cgits);
$self->{"$pfx.cgiturl"} = $cgits;
}
-
+ $git->{nick} = $nick;
$git;
}
push @repo_objs, $repo if $repo;
}
if (scalar @repo_objs) {
- $ibxish ->{-repo_objs} = \@repo_objs;
+ $ibxish->{-repo_objs} = \@repo_objs;
} else {
delete $ibxish->{coderepo};
}
# more things to encourage decentralization
for my $k (qw(address altid nntpmirror imapmirror
coderepo hide listid url
- infourl watchheader nntpserver imapserver)) {
+ infourl watchheader
+ nntpserver imapserver pop3server)) {
my $v = $self->{"$pfx.$k"} // next;
$ibx->{$k} = _array($v);
}