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 <jholdsworth@nvidia.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Joel Holdsworth committed Jan 6, 2022 at 21:40 UTC 727e6ea3506c36c3dd871bd8ef259bcbf7ba6be4
1 file changed +9 -8
git-p4.py
+9 -8
@@ -275,14 +275,14 @@ def run_hook_command(cmd, param):
275
276 def write_pipe(c, stdin, *k, **kw):
277 if verbose:
278 - sys.stderr.write('Writing pipe: %s\n' % str(c))
278 + sys.stderr.write('Writing pipe: {}\n'.format(' '.join(c)))
279
280 p = subprocess.Popen(c, stdin=subprocess.PIPE, *k, **kw)
281 pipe = p.stdin
282 val = pipe.write(stdin)
283 pipe.close()
284 if p.wait():
285 - die('Command failed: %s' % str(c))
285 + die('Command failed: {}'.format(' '.join(c)))
286
287 return val
288
@@ -298,7 +298,7 @@ def read_pipe_full(c, *k, **kw):
298 text.
299 """
300 if verbose:
301 - sys.stderr.write('Reading pipe: %s\n' % str(c))
301 + sys.stderr.write('Reading pipe: {}\n'.format(' '.join(c)))
302
303 p = subprocess.Popen(
304 c, stdout=subprocess.PIPE, stderr=subprocess.PIPE, *k, **kw)
@@ -317,7 +317,7 @@ def read_pipe(c, ignore_error=False, raw=False, *k, **kw):
317 if ignore_error:
318 out = ""
319 else:
320 - die('Command failed: %s\nError: %s' % (str(c), err))
320 + die('Command failed: {}\nError: {}'.format(' '.join(c), err))
321 if not raw:
322 out = decode_text_stream(out)
323 return out
@@ -338,7 +338,7 @@ def p4_read_pipe(c, ignore_error=False, raw=False, *k, **kw):
338
339 def read_pipe_lines(c, raw=False, *k, **kw):
340 if verbose:
341 - sys.stderr.write('Reading pipe: %s\n' % str(c))
341 + sys.stderr.write('Reading pipe: {}\n'.format(' '.join(c)))
342
343 p = subprocess.Popen(c, stdout=subprocess.PIPE, *k, **kw)
344 pipe = p.stdout
@@ -346,7 +346,7 @@ def read_pipe_lines(c, raw=False, *k, **kw):
346 if not raw:
347 lines = [decode_text_stream(line) for line in lines]
348 if pipe.close() or p.wait():
349 - die('Command failed: %s' % str(c))
349 + die('Command failed: {}'.format(' '.join(c)))
350 return lines
351
352 def p4_read_pipe_lines(c, *k, **kw):
@@ -385,7 +385,8 @@ def p4_has_move_command():
385
386 def system(cmd, ignore_error=False, *k, **kw):
387 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))
390 retcode = subprocess.call(cmd, *k, **kw)
391 if retcode and not ignore_error:
392 raise CalledProcessError(retcode, cmd)
@@ -720,7 +721,7 @@ def p4CmdList(cmd, stdin=None, stdin_mode='w+b', cb=None, skip_info=False,
721
722 cmd = p4_build_cmd(["-G"] + cmd)
723 if verbose:
723 - sys.stderr.write("Opening pipe: %s\n" % str(cmd))
724 + sys.stderr.write("Opening pipe: {}\n".format(' '.join(cmd)))
725
726 # Use a temporary file to avoid deadlocks without
727 # subprocess.communicate(), which would put another copy