Code

merge-recursive: handle file mode changes
[git.git] / quote.c
diff --git a/quote.c b/quote.c
index 6986b4420f66e1f01cd4517d35ce9adc300eaa8b..40702f6b725efade3e1fd61339421940f9fdb47d 100644 (file)
--- a/quote.c
+++ b/quote.c
@@ -213,6 +213,22 @@ size_t quote_c_style(const char *name, struct strbuf *sb, FILE *fp, int nodq)
        return quote_c_style_counted(name, -1, sb, fp, nodq);
 }
 
+void quote_two_c_style(struct strbuf *sb, const char *prefix, const char *path, int nodq)
+{
+       if (quote_c_style(prefix, NULL, NULL, 0) ||
+           quote_c_style(path, NULL, NULL, 0)) {
+               if (!nodq)
+                       strbuf_addch(sb, '"');
+               quote_c_style(prefix, sb, NULL, 1);
+               quote_c_style(path, sb, NULL, 1);
+               if (!nodq)
+                       strbuf_addch(sb, '"');
+       } else {
+               strbuf_addstr(sb, prefix);
+               strbuf_addstr(sb, path);
+       }
+}
+
 void write_name_quoted(const char *name, FILE *fp, int terminator)
 {
        if (terminator) {
@@ -272,7 +288,7 @@ int unquote_c_style(struct strbuf *sb, const char *quoted, const char **endp)
                switch (*quoted++) {
                  case '"':
                        if (endp)
-                               *endp = quoted + 1;
+                               *endp = quoted;
                        return 0;
                  case '\\':
                        break;