summaryrefslogtreecommitdiff
path: root/quote.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2019-10-15 04:48:02 (GMT)
committerJunio C Hamano <gitster@pobox.com>2019-10-15 04:48:02 (GMT)
commit77458870a5b1ab4d7c8f2c4825e888571a32979b (patch)
treedeb8b573ff7f62d6a4b7cec3c61b40d700dbf0d5 /quote.c
parent5efabc7ed9e57bb73159d1ad7739c508167ef24a (diff)
parentce2d7ed2fd454d60a0957508141438f26c4100c7 (diff)
downloadgit-77458870a5b1ab4d7c8f2c4825e888571a32979b.zip
git-77458870a5b1ab4d7c8f2c4825e888571a32979b.tar.gz
git-77458870a5b1ab4d7c8f2c4825e888571a32979b.tar.bz2
Merge branch 'gs/sq-quote-buf-pretty'
Pretty-printed command line formatter (used in e.g. reporting the command being run by the tracing API) had a bug that lost an argument that is an empty string, which has been corrected. * gs/sq-quote-buf-pretty: sq_quote_buf_pretty: don't drop empty arguments
Diffstat (limited to 'quote.c')
-rw-r--r--quote.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/quote.c b/quote.c
index c8ba6b3..24a58ba 100644
--- a/quote.c
+++ b/quote.c
@@ -48,6 +48,12 @@ void sq_quote_buf_pretty(struct strbuf *dst, const char *src)
static const char ok_punct[] = "+,-./:=@_^";
const char *p;
+ /* Avoid losing a zero-length string by adding '' */
+ if (!*src) {
+ strbuf_addstr(dst, "''");
+ return;
+ }
+
for (p = src; *p; p++) {
if (!isalpha(*p) && !isdigit(*p) && !strchr(ok_punct, *p)) {
sq_quote_buf(dst, src);