From 19703e2d72b045ec532f6725bea4adea5e8f3cf7 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Tue, 29 Apr 2014 03:43:20 +0000 Subject: config: use "git config --file" to avoid changing %ENV %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 | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'lib/PublicInbox/Config.pm') diff --git a/lib/PublicInbox/Config.pm b/lib/PublicInbox/Config.pm index 32bd9ab6..876e5d02 100644 --- a/lib/PublicInbox/Config.pm +++ b/lib/PublicInbox/Config.pm @@ -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}; -- cgit v1.2.3-24-ge0c7