]> Sergey Matveev's repositories - public-inbox.git/blobdiff - lib/PublicInbox/Config.pm
lei: fix handling of broken lei.saved-search config files
[public-inbox.git] / lib / PublicInbox / Config.pm
index 3f0f5a0195d76e1d77e03f3e33f87342d59e92c9..74a1a6f5a776fd388bed0b9a16b53263f914e03e 100644 (file)
@@ -97,6 +97,11 @@ sub lookup_ei {
        $self->{-ei_by_name}->{$name} //= _fill_ei($self, $name);
 }
 
+sub lookup_eidx_key {
+       my ($self, $eidx_key) = @_;
+       _lookup_fill($self, '-by_eidx_key', $eidx_key);
+}
+
 # special case for [extindex "all"]
 sub ALL { lookup_ei($_[0], 'all') }
 
@@ -159,12 +164,12 @@ sub config_fh_parse ($$$) {
 }
 
 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;
 }
 
@@ -379,7 +384,7 @@ sub rel2abs_collapsed {
        Cwd::abs_path($p);
 }
 
-sub _one_val {
+sub get_1 {
        my ($self, $pfx, $k) = @_;
        my $v = $self->{"$pfx.$k"} // return;
        return $v if !ref($v);
@@ -424,8 +429,8 @@ sub _fill_ibx {
                $ibx->{$k} = $v if defined $v;
        }
        for my $k (qw(filter inboxdir newsgroup replyto httpbackendmax feedmax
-                       indexlevel indexsequentialshard)) {
-               my $v = _one_val($self, $pfx, $k) // next;
+                       indexlevel indexsequentialshard boost)) {
+               my $v = get_1($self, $pfx, $k) // next;
                $ibx->{$k} = $v;
        }
 
@@ -517,10 +522,10 @@ sub _fill_ei ($$) {
        }
        my $es = PublicInbox::ExtSearch->new($d);
        for my $k (qw(indexlevel indexsequentialshard)) {
-               my $v = _one_val($self, $pfx, $k) // next;
+               my $v = get_1($self, $pfx, $k) // next;
                $es->{$k} = $v;
        }
-       for my $k (qw(altid coderepo hide url infourl)) {
+       for my $k (qw(coderepo hide url infourl)) {
                my $v = $self->{"$pfx.$k"} // next;
                $es->{$k} = _array($v);
        }