]> git.ipfire.org Git - thirdparty/git.git/blobdiff - quote.c
ref-filter: --format=%(raw) support --perl
[thirdparty/git.git] / quote.c
diff --git a/quote.c b/quote.c
index 8a3a5e39eb12adff643d8bd2d90d1e625203a2ce..26719d21d1e7555d92289b26402a73030e330606 100644 (file)
--- a/quote.c
+++ b/quote.c
@@ -471,6 +471,23 @@ void perl_quote_buf(struct strbuf *sb, const char *src)
        strbuf_addch(sb, sq);
 }
 
+void perl_quote_buf_with_len(struct strbuf *sb, const char *src, size_t len)
+{
+       const char sq = '\'';
+       const char bq = '\\';
+       const char *c = src;
+       const char *end = src + len;
+
+       strbuf_addch(sb, sq);
+       while (c != end) {
+               if (*c == sq || *c == bq)
+                       strbuf_addch(sb, bq);
+               strbuf_addch(sb, *c);
+               c++;
+       }
+       strbuf_addch(sb, sq);
+}
+
 void python_quote_buf(struct strbuf *sb, const char *src)
 {
        const char sq = '\'';