mirror of
https://github.com/git/git.git
synced 2026-01-09 17:46:37 +00:00
trace: avoid unnecessary quoting
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 <peff@peff.net>
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
committed by
Junio C Hamano
parent
e35f11c293
commit
1fbdab21bb
8
quote.h
8
quote.h
@@ -33,6 +33,14 @@ extern void sq_quote_buf(struct strbuf *, const char *src);
|
||||
extern void sq_quote_argv(struct strbuf *, const char **argv);
|
||||
extern void sq_quotef(struct strbuf *, const char *fmt, ...);
|
||||
|
||||
/*
|
||||
* These match their non-pretty variants, except that they avoid
|
||||
* quoting when there are no exotic characters. These should only be used for
|
||||
* human-readable output, as sq_dequote() is not smart enough to dequote it.
|
||||
*/
|
||||
void sq_quote_buf_pretty(struct strbuf *, const char *src);
|
||||
void sq_quote_argv_pretty(struct strbuf *, const char **argv);
|
||||
|
||||
/* This unwraps what sq_quote() produces in place, but returns
|
||||
* NULL if the input does not look like what sq_quote would have
|
||||
* produced.
|
||||
|
||||
Reference in New Issue
Block a user