diff options
author | Garima Singh <garima.singh@microsoft.com> | 2019-10-07 22:38:56 +0300 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2019-10-08 06:59:29 +0300 |
commit | ce2d7ed2fd454d60a0957508141438f26c4100c7 (patch) | |
tree | f9931ce203516b16c591299cb3a1dc7e6268a036 /quote.c | |
parent | 5fa0f5238b0cd46cfe7f6fa76c3f526ea98148d9 (diff) |
sq_quote_buf_pretty: don't drop empty arguments
Empty arguments passed on the command line can be represented by
a '', however sq_quote_buf_pretty was incorrectly dropping these
arguments altogether. Fix this problem by ensuring that such
arguments are emitted as '' instead.
Signed-off-by: Garima Singh <garima.singh@microsoft.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'quote.c')
-rw-r--r-- | quote.c | 6 |
1 files changed, 6 insertions, 0 deletions
@@ -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); |