Skip to content

Commit 9732e22

Browse files
jholgitster
authored andcommitted
git-p4: add raw option to read_pipelines
Previously the read_lines function always decoded the result lines. In order to improve support for non-decoded binary processing of data in git-p4.py, this patch adds a raw option to the function that allows decoding to be disabled. Signed-off-by: Joel Holdsworth <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent e665e98 commit 9732e22

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

git-p4.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -340,17 +340,19 @@ def p4_read_pipe(c, ignore_error=False, raw=False):
340340
real_cmd = p4_build_cmd(c)
341341
return read_pipe(real_cmd, ignore_error, raw=raw)
342342

343-
def read_pipe_lines(c):
343+
def read_pipe_lines(c, raw=False):
344344
if verbose:
345345
sys.stderr.write('Reading pipe: %s\n' % str(c))
346346

347347
expand = not isinstance(c, list)
348348
p = subprocess.Popen(c, stdout=subprocess.PIPE, shell=expand)
349349
pipe = p.stdout
350-
val = [decode_text_stream(line) for line in pipe.readlines()]
350+
lines = pipe.readlines()
351+
if not raw:
352+
lines = [decode_text_stream(line) for line in lines]
351353
if pipe.close() or p.wait():
352354
die('Command failed: %s' % str(c))
353-
return val
355+
return lines
354356

355357
def p4_read_pipe_lines(c):
356358
"""Specifically invoke p4 on the command supplied. """

0 commit comments

Comments
 (0)