[PATCH 12/16] narrow spec: put '+' before a spec will change semantic of '*'
- From
Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
- Date
- Sep 14, 2008, 13:08 UTC
- Message-ID
- <1221397685-27715-13-git-send-email-pclouds@gmail.com>
- In-Reply-To
- <1221397685-27715-12-git-send-email-pclouds@gmail.com>
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@gmail.com> --- 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