aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric Sunshine <sunshine@sunshineco.com>2015-01-13 10:57:06 +0100
committerAlberto Bertogli <albertito@blitiri.com.ar>2015-01-13 20:51:44 +0100
commit66afd72d6d49ad26f53457c4fda31d01c927e0fa (patch)
tree9ad3147077e65c6ff53a6dcba8feef3ec12d60c0
parentbb9bad89d17ed584f52015ae6db6398889d23a81 (diff)
downloadgit-arr-fork-66afd72d6d49ad26f53457c4fda31d01c927e0fa.zip
run_git: add option to return raw output stream
Currently, clients which want the raw output from a Git command must sneakily extract the raw 'fd' from the utf8-encoding wrapper returned by run_git(). This is ugly and fragile. Instead, provide a formal mechanism for requesting raw output. Signed-off-by: Eric Sunshine <sunshine@sunshineco.com> Signed-off-by: Alberto Bertogli <albertito@blitiri.com.ar>
-rw-r--r--git.py5
1 files changed, 4 insertions, 1 deletions
diff --git a/git.py b/git.py
index 9a77c7c..10cddcd 100644
--- a/git.py
+++ b/git.py
@@ -41,7 +41,7 @@ class EncodeWrapper:
return s.decode(self.encoding, errors = self.errors)
-def run_git(repo_path, params, stdin = None, silent_stderr = False):
+def run_git(repo_path, params, stdin = None, silent_stderr = False, raw = False):
"""Invokes git with the given parameters.
This function invokes git with the given parameters, and returns a
@@ -63,6 +63,9 @@ def run_git(repo_path, params, stdin = None, silent_stderr = False):
p.stdin.write(stdin)
p.stdin.close()
+ if raw:
+ return p.stdout
+
# We need to wrap stdout if we want to decode it as utf8, subprocess
# doesn't support us telling it the encoding.
if sys.version_info.major == 3: