]> git.ipfire.org Git - thirdparty/git.git/blobdiff - quote.c
Merge branch 'gs/sq-quote-buf-pretty'
[thirdparty/git.git] / quote.c
diff --git a/quote.c b/quote.c
index c8ba6b397a00036104278a8e55e154079018bb19..24a58ba454fdfd04dd441d787ea8202ea772c02f 100644 (file)
--- 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);