From: Nguyen Thai Ngoc Duy Date: Wed, 23 Mar 2011 12:18:24 GMT Subject: Re: [WIP PATCH 0/5] support --exclude for diff/log commands Message-ID: In-Reply-To: On Wed, Mar 23, 2011 at 7:10 PM, Nguyen Thai Ngoc Duy wrote: > How about ":" for root pathspecs, but reserve ':[^0-9A-Za-z]*' > for future use? > .. > +                       if (strchr(reserved, (*src)[1])) > +                               die("':%c' syntax is not supported. " > +                                   "Quote it to match literally.", (*src)[1]); Hmm.. I need a letter to become quoter. Let's take '\' for that. I also leave '.' out of reserved range because it may be used frequently (hidden files). diff --git a/setup.c b/setup.c index ef55e5d..b6294be 100644 --- a/setup.c +++ b/setup.c @@ -146,8 +146,16 @@ const char **get_pathspec(const char *prefix, const char **pathspec) while (*src) { const char *p; - if ((*src)[0] == ':') - p = prefix_path(NULL, 0, (*src)+1); + if ((*src)[0] == ':') { + const char *reserved = "~`!@#$%^&*()-_=+[{]}|;:'\",<>/?"; + const char *s = *src + 1; + if (*s == '\\') + s++; + else if (strchr(reserved, *s)) + die("':%c' syntax is not supported. " + "Quote it to match literally.", *s); + p = prefix_path(NULL, 0, s); + } else p = prefix_path(prefix, prefixlen, *src); *(dst++) = p; -- Duy