]> git.ipfire.org Git - thirdparty/public-inbox.git/commitdiff
git: support arbitrary redirects and env settings on popen
authorEric Wong <e@80x24.org>
Sun, 28 Feb 2016 04:23:53 +0000 (04:23 +0000)
committerEric Wong <e@80x24.org>
Tue, 5 Apr 2016 18:58:27 +0000 (18:58 +0000)
We want to be able to redirect stderr to a temporary file
while using the normal popen interface in our Git.pm.

lib/PublicInbox/Git.pm

index 23a3e6c7bdf36fba1f908613eadd03e4fb56940b..bd945007fdad4ae7efdc4d746b144226641c42b2 100644 (file)
@@ -132,8 +132,16 @@ sub fail {
 
 sub popen {
        my ($self, @cmd) = @_;
-       @cmd = ('git', "--git-dir=$self->{git_dir}", @cmd);
-       popen_rd(\@cmd);
+       my $cmd = [ 'git', "--git-dir=$self->{git_dir}" ];
+       my ($env, $opt);
+       if (ref $cmd[0]) {
+               push @$cmd, @{$cmd[0]};
+               $env = $cmd[1];
+               $opt = $cmd[2];
+       } else {
+               push @$cmd, @cmd;
+       }
+       popen_rd($cmd, $env, $opt);
 }
 
 sub qx {