From d56250911f4ec074048f4edb34551eaf384172cc Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Wed, 26 Dec 2007 17:13:36 -0800 Subject: 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 --- quote.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'quote.c') diff --git a/quote.c b/quote.c index 6986b4420..d061626c3 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) { -- cgit v1.2.3