[PATCH 12/16] narrow spec: put '+' before a spec will change semantic of '*'

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

 



Previously '*' in narrow spec means 'match everything, even slashes'.
With this change, '*' is now 'match everything except slashes' so it is
more like shell wildcard one. Putting '+' before a spec will make
'*' as powerful as before.

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@xxxxxxxxx>
---
 unpack-trees.c |    7 ++++++-
 1 files changed, 6 insertions(+), 1 deletions(-)

diff --git a/unpack-trees.c b/unpack-trees.c
index 968cc98..3782de6 100644
--- a/unpack-trees.c
+++ b/unpack-trees.c
@@ -812,10 +812,15 @@ int match_narrow_spec(const char *spec_, const char *path, const char *prefix)
 
 	while (!match) {
 		char *next_spec = strchr(cur_spec, ':');
+		int flag = 0;
 		if (next_spec)
 			*next_spec = '\0';
 
-		if (!fnmatch(cur_spec, path+prefix_len, 0))
+		if (*cur_spec == '+')
+			cur_spec++;
+		else
+			flag = FNM_PATHNAME;
+		if (!fnmatch(cur_spec, path+prefix_len, flag))
 			match = 1;
 
 		if (!next_spec)
-- 
1.6.0.96.g2fad1.dirty

--
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]

  Powered by Linux