diff options
author | Eric Sunshine <sunshine@sunshineco.com> | 2015-01-13 10:57:07 +0100 |
---|---|---|
committer | Alberto Bertogli <albertito@blitiri.com.ar> | 2015-01-13 20:51:44 +0100 |
commit | 43f4132bf1e7855f17187f3f496b62a0a8192424 (patch) | |
tree | 772031492d9985700d60423365a90de3e8383d89 | |
parent | 66afd72d6d49ad26f53457c4fda31d01c927e0fa (diff) | |
download | git-arr-fork-43f4132bf1e7855f17187f3f496b62a0a8192424.zip |
GitCommand: teach run() how 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 GitCommand.run(). 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.py | 9 |
1 files changed, 8 insertions, 1 deletions
@@ -84,6 +84,7 @@ class GitCommand (object): self._args = list(args) self._kwargs = {} self._stdin_buf = None + self._raw = False self._override = False for k, v in kwargs: self.__setattr__(k, v) @@ -99,6 +100,12 @@ class GitCommand (object): """Adds an argument.""" self._args.append(a) + def raw(self, b): + """Request raw rather than utf8-encoded command output.""" + self._override = True + self._raw = b + self._override = False + def stdin(self, s): """Sets the contents we will send in stdin.""" self._override = True @@ -118,7 +125,7 @@ class GitCommand (object): params.extend(self._args) - return run_git(self._path, params, self._stdin_buf) + return run_git(self._path, params, self._stdin_buf, raw = self._raw) class SimpleNamespace (object): |