Re: [WIP PATCH 0/5] support --exclude for diff/log commands

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, Mar 23, 2011 at 7:10 PM, Nguyen Thai Ngoc Duy <pclouds@xxxxxxxxx> wrote:
> How about ":<path>" 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
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]