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 {
- $self = git_config_dump($file);
+ $self = git_config_dump($class, $file);
$self->{'-f'} = $file;
}
- bless $self, $class;
# caches
$self->{-by_addr} = {};
$self->{-by_list_id} = {};
}
sub git_config_dump {
- my ($file) = @_;
- return {} unless -e $file;
+ my ($class, $file) = @_;
+ return bless {}, $class unless -e $file;
my $cmd = [ qw(git config -z -l --includes), "--file=$file" ];
my $fh = popen_rd($cmd);
my $rv = config_fh_parse($fh, "\0", "\n");
close $fh or die "failed to close (@$cmd) pipe: $?";
- $rv;
+ bless $rv, $class;
}
sub valid_foo_name ($;$) {
$cur_st = pack('dd', $st[10], $st[7]);
qerr($self, "# $f created") if $self->{cmd} ne 'config';
}
- my $cfg = PublicInbox::Config::git_config_dump($f);
- bless $cfg, 'PublicInbox::Config';
+ my $cfg = PublicInbox::Config->git_config_dump($f);
$cfg->{-st} = $cur_st;
$cfg->{'-f'} = $f;
if ($sto && File::Spec->canonpath($sto_dir // store_path($self))
}
return $lei->err("# @$cmd failed (non-fatal)") if $cerr;
rename($f, $ce) or return $lei->err("link($f, $ce): $! (non-fatal)");
- my $cfg = PublicInbox::Config::git_config_dump($f);
+ my $cfg = PublicInbox::Config->git_config_dump($f);
my $ibx = $self->{ibx} = {};
for my $sec (grep(/\Apublicinbox\./, @{$cfg->{-section_order}})) {
for (qw(address newsgroup nntpmirror)) {
print $fh "\tpath = ", cquote_val($p), "\n";
}
close $fh or die "close $f: $!";
- my $cfg = PublicInbox::Config::git_config_dump($f);
+ my $cfg = PublicInbox::Config->git_config_dump($f);
unlink($f);
- bless $cfg, 'PublicInbox::Config';
my $out = $cfg->get_all('lei.q.output') or return ();
map {;
s!\A(?:maildir|mh|mbox.+|mmdf):!!i;
output2lssdir($self, $lei, \$dir, \$f) or
return $lei->fail("--save was not used with $dst cwd=".
$lei->rel2abs('.'));
- $self->{-cfg} //= PublicInbox::Config::git_config_dump($f);
$self->{'-f'} = $f;
} else { # new saved search "lei q --save"
$dst = $lei->{ovv}->{dst};
}
close($fh) or return $lei->fail("close $f: $!");
}
- bless $self->{-cfg}, 'PublicInbox::Config';
$self->{lock_path} = "$self->{-f}.flock";
$self->{-ovf} = "$dir/over.sqlite3";
$self;
my $dir = lss_dir_for($lei, \$dst);
my $f = "$dir/lei.saved-search";
if (-f $f && -r _) {
- $self->{-cfg} = PublicInbox::Config::git_config_dump($f);
+ $self->{-cfg} = PublicInbox::Config->git_config_dump($f);
$$dir_ref = $dir;
$$fn_ref = $f;
return 1;