summaryrefslogtreecommitdiff
path: root/quote.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2007-12-26 17:13:36 -0800
committerJunio C Hamano <gitster@pobox.com>2007-12-26 17:13:36 -0800
commitd56250911f4ec074048f4edb34551eaf384172cc (patch)
tree8978a2314f00add8f84a9164ba69da2fb70c9aeb /quote.c
parent462a15bc82e6adbcb8db5fcc4791ec70a026aa4b (diff)
downloadgit-d56250911f4ec074048f4edb34551eaf384172cc.tar.gz
Fix rewrite_diff() name quoting.
This moves the logic to quote two paths (prefix + path) in C-style introduced in the previous commit from the dump_quoted_path() in combine-diff.c to quote.c, and uses it to fix rewrite_diff() that never C-quoted the pathnames correctly. Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'quote.c')
-rw-r--r--quote.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/quote.c b/quote.c
index 6986b4420f..d061626c34 100644
--- 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) {