Skip to content

Commit ac78d85

Browse files
committed
1 parent 0b820e6 commit ac78d85

File tree

1 file changed

+21
-9
lines changed

1 file changed

+21
-9
lines changed

git/cmd.py

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
# the BSD License: http://www.opensource.org/licenses/bsd-license.php
66

77
import os, sys
8+
import tempfile
89
from util import (
910
LazyMixin,
1011
stream_copy
@@ -328,19 +329,30 @@ def execute(self, command,
328329
cwd = os.getcwd()
329330
else:
330331
cwd=self._working_dir
331-
332+
333+
if as_process:
334+
temp_file_err = tempfile.TemporaryFile()
335+
temp_file_out = tempfile.TemporaryFile()
336+
stderr_pipe=temp_file_err.fileno()
337+
stdout_pipe=temp_file_out.fileno()
338+
else:
339+
stderr_pipe=PIPE
340+
stdout_pipe=PIPE
341+
332342
# Start the process
333343
proc = Popen(command,
334-
cwd=cwd,
335-
stdin=istream,
336-
stderr=PIPE,
337-
stdout=PIPE,
338-
close_fds=(os.name=='posix'),# unsupported on linux
339-
**subprocess_kwargs
340-
)
344+
cwd=cwd,
345+
stdin=istream,
346+
stderr=stderr_pipe,
347+
stdout=stdout_pipe,
348+
close_fds=(os.name=='posix'),# unsupported on linux
349+
**subprocess_kwargs
350+
)
341351
if as_process:
352+
proc.stderr = temp_file_err
353+
proc.stdout = temp_file_out
342354
return self.AutoInterrupt(proc, command)
343-
355+
344356
# Wait for the process to return
345357
status = 0
346358
stdout_value = ''

0 commit comments

Comments
 (0)