From 1fbdab21bb452ca4732bf088539247047465b99d Mon Sep 17 00:00:00 2001 From: Jeff King Date: Mon, 15 Jan 2018 17:59:44 +0700 Subject: trace: avoid unnecessary quoting MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Trace output which contains arbitrary strings (e.g., the arguments to commands which we are running) is always passed through sq_quote_buf(). That function always adds single-quotes, even if the output consists of vanilla characters. This can make the output a bit hard to read. Let's avoid the quoting if there are no characters which a shell would interpret. Trace output doesn't necessarily need to be shell-compatible, but: - the shell language is a good ballpark for what humans consider readable (well, humans versed in command line tools) - the run_command bits can be cut-and-pasted to a shell, and we'll keep that property - it covers any cases which would make the output visually ambiguous (e.g., embedded whitespace or quotes) Signed-off-by: Jeff King Signed-off-by: Nguyễn Thái Ngọc Duy Signed-off-by: Junio C Hamano --- trace.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'trace.c') diff --git a/trace.c b/trace.c index fa9174fc4b..9784915be1 100644 --- a/trace.c +++ b/trace.c @@ -157,7 +157,7 @@ static void trace_argv_vprintf_fl(const char *file, int line, strbuf_vaddf(&buf, format, ap); - sq_quote_argv(&buf, argv); + sq_quote_argv_pretty(&buf, argv); print_trace_line(&trace_default_key, &buf); } @@ -426,6 +426,6 @@ void trace_command_performance(const char **argv) atexit(print_command_performance_atexit); strbuf_reset(&command_line); - sq_quote_argv(&command_line, argv); + sq_quote_argv_pretty(&command_line, argv); command_start_time = getnanotime(); } -- cgit v1.2.3