diff --git a/git/cmd.py b/git/cmd.py index 54537a41d..300284874 100644 --- a/git/cmd.py +++ b/git/cmd.py @@ -794,7 +794,7 @@ def _kill_process(pid): else: max_chunk_size = max_chunk_size if max_chunk_size and max_chunk_size > 0 else io.DEFAULT_BUFFER_SIZE stream_copy(proc.stdout, output_stream, max_chunk_size) - stdout_value = output_stream + stdout_value = proc.stdout.read() stderr_value = proc.stderr.read() # strip trailing "\n" if stderr_value.endswith(b"\n"): diff --git a/git/test/test_git.py b/git/test/test_git.py index c6180f7c9..cc931239f 100644 --- a/git/test/test_git.py +++ b/git/test/test_git.py @@ -7,6 +7,7 @@ import os import subprocess import sys +from tempfile import TemporaryFile from git import ( Git, @@ -108,6 +109,11 @@ def test_it_ignores_false_kwargs(self, git): self.git.version(pass_this_kwarg=False) assert_true("pass_this_kwarg" not in git.call_args[1]) + @raises(GitCommandError) + def test_it_raises_proper_exception_with_output_stream(self): + tmp_file = TemporaryFile() + self.git.checkout('non-existent-branch', output_stream=tmp_file) + def test_it_accepts_environment_variables(self): filename = fixture_path("ls_tree_empty") with open(filename, 'r') as fh: