From: Eric Wong Date: Sun, 28 Feb 2016 04:23:53 +0000 (+0000) Subject: git: support arbitrary redirects and env settings on popen X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=38f685ef4c78788324089f9d1365c7676aa5a5aa;p=thirdparty%2Fpublic-inbox.git git: support arbitrary redirects and env settings on popen We want to be able to redirect stderr to a temporary file while using the normal popen interface in our Git.pm. --- diff --git a/lib/PublicInbox/Git.pm b/lib/PublicInbox/Git.pm index 23a3e6c7b..bd945007f 100644 --- a/lib/PublicInbox/Git.pm +++ b/lib/PublicInbox/Git.pm @@ -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 {