From ce2d7ed2fd454d60a0957508141438f26c4100c7 Mon Sep 17 00:00:00 2001 From: Garima Singh Date: Mon, 7 Oct 2019 12:38:56 -0700 Subject: 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 Signed-off-by: Junio C Hamano --- quote.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'quote.c') diff --git a/quote.c b/quote.c index 7f2aa6faa4..6deef8712b 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); -- cgit v1.2.3