]> Sergey Matveev's repositories - public-inbox.git/commitdiff
config: use "git config --file" to avoid changing %ENV
authorEric Wong <e@80x24.org>
Tue, 29 Apr 2014 03:43:20 +0000 (03:43 +0000)
committerEric Wong <e@80x24.org>
Tue, 29 Apr 2014 03:43:20 +0000 (03:43 +0000)
%ENV changes do not propagate by default under a mod_perl2
environment, and we might as well work towards being thread-safe.

lib/PublicInbox/Config.pm

index 32bd9ab6211e43e272ed0c6d43b274f6fb7dbb73..876e5d0239d2797c8e600f783a6cdadcc6bba690 100644 (file)
@@ -4,19 +4,19 @@ package PublicInbox::Config;
 use strict;
 use warnings;
 use File::Path::Expand qw/expand_filename/;
+use IPC::Run;
 
 # 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 ($in, $out);
 
-       local $ENV{GIT_CONFIG} = defined $file ? $file : default_file();
-
-       my @cfg = `git config -l`;
-       $? == 0 or die "git config -l failed: $?\n";
-       chomp @cfg;
+       $file = default_file() unless defined($file);
+       IPC::Run::run([qw/git config --file/, $file, '-l'], \$in, \$out);
+       $? == 0 or die "git config --file $file -l failed: $?\n";
        my %rv;
-       foreach my $line (@cfg) {
+       foreach my $line (split(/\n/, $out)) {
                my ($k, $v) = split(/=/, $line, 2);
                my $cur = $rv{$k};