From 9378c16135100fb65ad575cd35074af166de1cab Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Sun, 24 Jun 2007 15:11:24 -0700 Subject: Add core.quotepath configuration variable. We always quote "unusual" byte values in a pathname using C-string style, to make it safer for parsing scripts that do not handle NUL separated records well (or just too lazy to bother). The absolute minimum bytes that need to be quoted for this purpose are TAB, LF (and other control characters), double quote and backslash. However, we have also always quoted the bytes in high 8-bit range; this was partly because we were lazy and partly because we were being cautious. This introduces an internal "quote_path_fully" variable, and core.quotepath configuration variable to control it. When set to false, it does not quote bytes in high 8-bit range anymore but passes them intact. The variable defaults to "true" to retain the traditional behaviour for now. Signed-off-by: Junio C Hamano --- quote.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'quote.c') diff --git a/quote.c b/quote.c index aa440098e..d88bf7515 100644 --- a/quote.c +++ b/quote.c @@ -188,7 +188,8 @@ static int quote_c_style_counted(const char *name, int namelen, #define EMITQ() EMIT('\\') const char *sp; - int ch, count = 0, needquote = 0; + unsigned char ch; + int count = 0, needquote = 0; if (!no_dq) EMIT('"'); @@ -197,7 +198,7 @@ static int quote_c_style_counted(const char *name, int namelen, if (!ch) break; if ((ch < ' ') || (ch == '"') || (ch == '\\') || - (ch >= 0177)) { + (quote_path_fully && (ch >= 0177))) { needquote = 1; switch (ch) { case '\a': EMITQ(); ch = 'a'; break; -- cgit v1.2.1