From 17f5d13a7a741dcbb2a30e147bdafe929cff4697 Mon Sep 17 00:00:00 2001 From: Sebastian Thiel Date: Fri, 9 Jan 2015 12:49:03 +0100 Subject: Added test to assure blame can deal with binary patches. Fixes #74 --- git/cmd.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'git/cmd.py') diff --git a/git/cmd.py b/git/cmd.py index d0190adf..668d8f4a 100644 --- a/git/cmd.py +++ b/git/cmd.py @@ -31,7 +31,7 @@ from git.compat import ( ) execute_kwargs = ('istream', 'with_keep_cwd', 'with_extended_output', - 'with_exceptions', 'as_process', + 'with_exceptions', 'as_process', 'stdout_as_string', 'output_stream') log = logging.getLogger('git.cmd') @@ -411,6 +411,7 @@ class Git(LazyMixin): with_exceptions=True, as_process=False, output_stream=None, + stdout_as_string=True, **subprocess_kwargs ): """Handles executing the command on the shell and consumes and returns @@ -454,6 +455,11 @@ class Git(LazyMixin): output pipe to the given output stream directly. Judging from the implementation, you shouldn't use this flag ! + :param stdout_as_string: + if False, the commands standard output will be bytes. Otherwise, it will be + decoded into a string using the default encoding (usually utf-8). + The latter can fail, if the output contains binary data. + :param subprocess_kwargs: Keyword arguments to be passed to subprocess.Popen. Please note that some of the valid kwargs are already set by this method, the ones you @@ -545,7 +551,7 @@ class Git(LazyMixin): else: raise GitCommandError(command, status, stderr_value) - if isinstance(stdout_value, bytes): # could also be output_stream + if isinstance(stdout_value, bytes) and stdout_as_string: # could also be output_stream stdout_value = stdout_value.decode(defenc) # Allow access to the command's status code -- cgit v1.2.3