- 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);
+ my @cmd = (qw/git config/, "--file=$file", '-l');
+ my $cmd = join(' ', @cmd);
+ my $pid = open(my $fh, '-|', @cmd);
+ defined $pid or die "$cmd failed: $!\n";