summaryrefslogtreecommitdiff
path: root/test-wildmatch.c
diff options
context:
space:
mode:
authorNguyễn Thái Ngọc Duy <pclouds@gmail.com>2013-01-01 09:44:07 +0700
committerJunio C Hamano <gitster@pobox.com>2013-01-01 15:32:37 -0800
commitc41244e702fd4fc1039f39a3915ae1e5f165bbf3 (patch)
tree2556fe7cadc647a95290472a832e32a784985090 /test-wildmatch.c
parent0c528168dadd4209de0213a16ff811a89ee3f206 (diff)
downloadgit-c41244e702fd4fc1039f39a3915ae1e5f165bbf3.tar.gz
wildmatch: support "no FNM_PATHNAME" mode
So far, wildmatch() has always honoured directory boundary and there was no way to turn it off. Make it behave more like fnmatch() by requiring all callers that want the FNM_PATHNAME behaviour to pass that in the equivalent flag WM_PATHNAME. Callers that do not specify WM_PATHNAME will get wildcards like ? and * in their patterns matched against '/', just like not passing FNM_PATHNAME to fnmatch(). Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'test-wildmatch.c')
-rw-r--r--test-wildmatch.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/test-wildmatch.c b/test-wildmatch.c
index 4bb23b4c92..a5f4833770 100644
--- a/test-wildmatch.c
+++ b/test-wildmatch.c
@@ -12,9 +12,11 @@ int main(int argc, char **argv)
argv[i] += 3;
}
if (!strcmp(argv[1], "wildmatch"))
- return !!wildmatch(argv[3], argv[2], 0, NULL);
+ return !!wildmatch(argv[3], argv[2], WM_PATHNAME, NULL);
else if (!strcmp(argv[1], "iwildmatch"))
- return !!wildmatch(argv[3], argv[2], WM_CASEFOLD, NULL);
+ return !!wildmatch(argv[3], argv[2], WM_PATHNAME | WM_CASEFOLD, NULL);
+ else if (!strcmp(argv[1], "pathmatch"))
+ return !!wildmatch(argv[3], argv[2], 0, NULL);
else if (!strcmp(argv[1], "fnmatch"))
return !!fnmatch(argv[3], argv[2], FNM_PATHNAME);
else