Skip to content

Commit 727e6ea

Browse files
jholgitster
authored andcommitted
git-p4: don't print shell commands as python lists
Previously the git-p4 script would log commands as stringified representations of the command parameter, leading to output such as this: Reading pipe: ['git', 'config', '--bool', 'git-p4.useclientspec'] Now that all commands are list objects, this patch instead joins the elements of the list into a single string so the output now looks more readable: Reading pipe: git config --bool git-p4.useclientspec Signed-off-by: Joel Holdsworth <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 8a47059 commit 727e6ea

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

git-p4.py

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -275,14 +275,14 @@ def run_hook_command(cmd, param):
275275

276276
def write_pipe(c, stdin, *k, **kw):
277277
if verbose:
278-
sys.stderr.write('Writing pipe: %s\n' % str(c))
278+
sys.stderr.write('Writing pipe: {}\n'.format(' '.join(c)))
279279

280280
p = subprocess.Popen(c, stdin=subprocess.PIPE, *k, **kw)
281281
pipe = p.stdin
282282
val = pipe.write(stdin)
283283
pipe.close()
284284
if p.wait():
285-
die('Command failed: %s' % str(c))
285+
die('Command failed: {}'.format(' '.join(c)))
286286

287287
return val
288288

@@ -298,7 +298,7 @@ def read_pipe_full(c, *k, **kw):
298298
text.
299299
"""
300300
if verbose:
301-
sys.stderr.write('Reading pipe: %s\n' % str(c))
301+
sys.stderr.write('Reading pipe: {}\n'.format(' '.join(c)))
302302

303303
p = subprocess.Popen(
304304
c, stdout=subprocess.PIPE, stderr=subprocess.PIPE, *k, **kw)
@@ -317,7 +317,7 @@ def read_pipe(c, ignore_error=False, raw=False, *k, **kw):
317317
if ignore_error:
318318
out = ""
319319
else:
320-
die('Command failed: %s\nError: %s' % (str(c), err))
320+
die('Command failed: {}\nError: {}'.format(' '.join(c), err))
321321
if not raw:
322322
out = decode_text_stream(out)
323323
return out
@@ -338,15 +338,15 @@ def p4_read_pipe(c, ignore_error=False, raw=False, *k, **kw):
338338

339339
def read_pipe_lines(c, raw=False, *k, **kw):
340340
if verbose:
341-
sys.stderr.write('Reading pipe: %s\n' % str(c))
341+
sys.stderr.write('Reading pipe: {}\n'.format(' '.join(c)))
342342

343343
p = subprocess.Popen(c, stdout=subprocess.PIPE, *k, **kw)
344344
pipe = p.stdout
345345
lines = pipe.readlines()
346346
if not raw:
347347
lines = [decode_text_stream(line) for line in lines]
348348
if pipe.close() or p.wait():
349-
die('Command failed: %s' % str(c))
349+
die('Command failed: {}'.format(' '.join(c)))
350350
return lines
351351

352352
def p4_read_pipe_lines(c, *k, **kw):
@@ -385,7 +385,8 @@ def p4_has_move_command():
385385

386386
def system(cmd, ignore_error=False, *k, **kw):
387387
if verbose:
388-
sys.stderr.write("executing %s\n" % str(cmd))
388+
sys.stderr.write("executing {}\n".format(
389+
' '.join(cmd) if isinstance(cmd, list) else cmd))
389390
retcode = subprocess.call(cmd, *k, **kw)
390391
if retcode and not ignore_error:
391392
raise CalledProcessError(retcode, cmd)
@@ -720,7 +721,7 @@ def p4CmdList(cmd, stdin=None, stdin_mode='w+b', cb=None, skip_info=False,
720721

721722
cmd = p4_build_cmd(["-G"] + cmd)
722723
if verbose:
723-
sys.stderr.write("Opening pipe: %s\n" % str(cmd))
724+
sys.stderr.write("Opening pipe: {}\n".format(' '.join(cmd)))
724725

725726
# Use a temporary file to avoid deadlocks without
726727
# subprocess.communicate(), which would put another copy

0 commit comments

Comments
 (0)