about summary refs log tree commit homepage
path: root/lib/PublicInbox/Config.pm
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2023-09-24 05:42:14 +0000
committerEric Wong <e@80x24.org>2023-09-24 18:56:18 +0000
commit21146412fdc32f8e6707b4e290ad715b35f20845 (patch)
tree53f4f32d1858ccae2ad8d24694da02cdc16ad9b4 /lib/PublicInbox/Config.pm
parentf170d220f8765e952c9a102dd35eb694810739df (diff)
downloadpublic-inbox-21146412fdc32f8e6707b4e290ad715b35f20845.tar.gz
It's a needless branch to maintain exclusively for our tests.
The `git config -l' output isn't pleasant to write in tests,
anyways.  So just use heredocs to write git configs in their
native format rather than emulate the output of `git config -l'.

This does make the test suite do more work with temporary files
and process invocations, but it doesn't seem very measurable
when testing on tmpfs (TMPDIR=/dev/shm).

We'll make a minor improvement to TestCommon::tmpdir by allowing
it to return a single value (which I suspect we can rely on in
more places since File::Temp::Dir overloads stringification).
Diffstat (limited to 'lib/PublicInbox/Config.pm')
-rw-r--r--lib/PublicInbox/Config.pm23
1 files changed, 8 insertions, 15 deletions
diff --git a/lib/PublicInbox/Config.pm b/lib/PublicInbox/Config.pm
index 533f4a52..9f764c32 100644
--- a/lib/PublicInbox/Config.pm
+++ b/lib/PublicInbox/Config.pm
@@ -24,21 +24,14 @@ sub _array ($) { ref($_[0]) eq 'ARRAY' ? $_[0] : [ $_[0] ] }
 sub new {
         my ($class, $file, $lei) = @_;
         $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, $lei);
-                $self->{'-f'} = $file;
-        }
+        my ($self, $set_dedupe);
+        if (-f $file && $DEDUPE) {
+                $file = rel2abs_collapsed($file);
+                $self = $DEDUPE->{$file} and return $self;
+                $set_dedupe = 1;
+        }
+        $self = git_config_dump($class, $file, $lei);
+        $self->{-f} = $file;
         # caches
         $self->{-by_addr} = {};
         $self->{-by_list_id} = {};