From: Junio C Hamano Date: Tue, 20 Aug 2019 20:32:05 GMT Subject: Re: [PATCH 1/1] quote: handle null and empty strings in sq_quote_buf_pretty() Message-ID: In-Reply-To: <9d2685bdb2e193986bec8cad88795963977d41fe.1566329700.git.gitgitgadget@gmail.com> "Garima Singh via GitGitGadget" writes: > + /* > + * In case of null or empty tokens, add a '' to ensure we > + * don't inadvertently drop those tokens > + */ A good comment. > + if (!src || !*src) { I think a caller that passes src==NULL deserves a BUG, or just a normal segfault. The condition here should just be "if (!*src)" instead. > + strbuf_addstr(dst, "''"); > + return; > + } Otherwise, the fix itself is good. Thanks. > for (p = src; *p; p++) { > if (!isalpha(*p) && !isdigit(*p) && !strchr(ok_punct, *p)) { > sq_quote_buf(dst, src);