local $/ = $rs;
while (defined($line = <$fh>)) { # perf critical with giant configs
$i = index($line, $fs);
+ # $i may be -1 if $fs not found and it's a key-only entry
+ # (meaning boolean true). Either way the -1 will drop the
+ # $rs either from $k or $v.
$k = substr($line, 0, $i);
- $v = substr($line, $i + 1, -1); # chop off $fs
+ $v = $i >= 0 ? substr($line, $i + 1, -1) : 1;
$section = substr($k, 0, rindex($k, '.'));
$seen{$section} //= push(@section_order, $section);
ok(defined(eval('$PublicInbox::VERSION')), 'VERSION defined');
use_ok 'PublicInbox::Config';
my ($tmpdir, $for_destroy) = tmpdir();
+use autodie qw(open close);
+my $validate_git_behavior = $ENV{TEST_VALIDATE_GIT_BEHAVIOR};
+
+{
+ my $f = "$tmpdir/bool_config";
+ open my $fh, '>', $f;
+ print $fh <<EOM;
+[imap]
+ debug
+ port = 2
+EOM
+ close $fh;
+ my $cfg = PublicInbox::Config->git_config_dump($f);
+ $validate_git_behavior and
+ is(xqx([qw(git config -f), $f, qw(--bool imap.debug)]),
+ "true\n", 'git handles key-only as truth');
+ ok($cfg->git_bool($cfg->{'imap.debug'}), 'key-only value handled');
+ is($cfg->{'imap.port'}, 2, 'normal k=v read after key-only');
+}
{
PublicInbox::Import::init_bare($tmpdir);