# returns key-value pairs of config directives in a hash
# if keys may be multi-value, the value is an array ref containing all values
sub new {
- my ($class, $file) = @_;
+ my ($class, $file, $errfh) = @_;
$file //= default_file();
my $self;
if (ref($file) eq 'SCALAR') { # used by some tests
$self = config_fh_parse($fh, "\n", '=');
bless $self, $class;
} else {
- $self = git_config_dump($class, $file);
+ $self = git_config_dump($class, $file, $errfh);
$self->{'-f'} = $file;
}
# caches
}
sub git_config_dump {
- my ($class, $file) = @_;
+ my ($class, $file, $errfh) = @_;
return bless {}, $class unless -e $file;
my $cmd = [ qw(git config -z -l --includes), "--file=$file" ];
- my $fh = popen_rd($cmd);
+ my $fh = popen_rd($cmd, undef, { 2 => $errfh // 2 });
my $rv = config_fh_parse($fh, "\0", "\n");
- close $fh or die "failed to close (@$cmd) pipe: $?";
+ close $fh or die "@$cmd failed: \$?=$?\n";
bless $rv, $class;
}
my ($self, $name) = @_;
my $pfx = "publicinbox.$name";
my $ibx = {};
- for my $k (qw(watch nntpserver)) {
+ for my $k (qw(watch)) {
my $v = $self->{"$pfx.$k"};
$ibx->{$k} = $v if defined $v;
}
# TODO: more arrays, we should support multi-value for
# more things to encourage decentralization
for my $k (qw(address altid nntpmirror coderepo hide listid url
- infourl watchheader)) {
+ infourl watchheader nntpserver)) {
my $v = $self->{"$pfx.$k"} // next;
$ibx->{$k} = _array($v);
}