Skip to contentSkip to conversation

Wildmatch v4

PATCH Superseded Nguyễn Thái Ngọc Duy 5 participants 28 messages Jun 15, 2016

Subsystems (2)

v4 of 5 Superseded Latest is v5 →

lore
Share & tools
lore
#0 lore raw

v4 cover Wildmatch v4

Really small updates. I did not want to resend it this soon but this may fix the compile errors for Junio. Changes are

- cleanup in wildmatch.c so #include "cache.h" is at the top of the file.

- wildmatch() returns no match if it encounters "**" without surrounding slashes. It returns a special code so we can actually show a warning at higher level. I don't want to do that now because I want to mark the pattern "broken" in attr.c/dir.c so the pattern will never be used again, and the message shown only once. That needs nd/attr-match-optim-more, but I don't want to tie this series to that just yet.

Nguyễn Thái Ngọc Duy (12):
ctype: make sane_ctype[] const array
ctype: support iscntrl, ispunct, isxdigit and isprint Import wildmatch from rsync
wildmatch: remove unnecessary functions
Integrate wildmatch to git
wildmatch: make wildmatch's return value compatible with fnmatch
wildmatch: remove static variable force_lower_case
wildmatch: fix case-insensitive matching
wildmatch: adjust "**" behavior
wildmatch: make /**/ match zero or more directories Support "**" wildcard in .gitignore and .gitattributes
t3070: disable two fnmatch tests that have different results on
different libc

 .gitignore                         |   1 +
 Documentation/gitattributes.txt    |   6 +
 Documentation/gitignore.txt        |  19 +++
 Makefile                           |   3 +
 attr.c                             |   4 +-
 ctype.c                            |  20 +++-
 dir.c                              |   4 +-
 git-compat-util.h                  |  15 ++-
 t/t0003-attributes.sh              |  38 ++++++
 t/t3001-ls-files-others-exclude.sh |  19 +++
 t/t3070-wildmatch.sh               | 187 +++++++++++++++++++++++++++++
 test-wildmatch.c                   |  14 +++
 wildmatch.c                        | 240 +++++++++++++++++++++++++++++++++++++
 wildmatch.h                        |   9 ++
 14 files changed, 575 insertions(+), 4 deletions(-)
 create mode 100755 t/t3070-wildmatch.sh
 create mode 100644 test-wildmatch.c
 create mode 100644 wildmatch.c
 create mode 100644 wildmatch.h
Signature · 1 line
1.7.12.1.406.g6ab07c4
#1 lore raw

PATCH v4 1/12 ctype: make sane_ctype[] const array

---
 ctype.c           | 2 +-
 git-compat-util.h | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
ctype.c +1 -1
index 9353271..faeaf34 100644
@@ -14,7 +14,7 @@ enum {
 	P = GIT_PATHSPEC_MAGIC  /* other non-alnum, except for ] and } */
 };
 
-unsigned char sane_ctype[256] = {
+const unsigned char sane_ctype[256] = {
 	0, 0, 0, 0, 0, 0, 0, 0, 0, S, S, 0, 0, S, 0, 0,		/*   0.. 15 */
 	0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,		/*  16.. 31 */
 	S, P, P, P, R, P, P, P, R, R, G, R, P, P, R, P,		/*  32.. 47 */
git-compat-util.h +1 -1
index 2fbf1fd..f8b859c 100644
@@ -510,7 +510,7 @@ extern const char tolower_trans_tbl[256];
 #undef isupper
 #undef tolower
 #undef toupper
-extern unsigned char sane_ctype[256];
+extern const unsigned char sane_ctype[256];
 #define GIT_SPACE 0x01
 #define GIT_DIGIT 0x02
 #define GIT_ALPHA 0x04
Signature · 1 line
1.7.12.1.406.g6ab07c4
#2 lore raw

PATCH v4 2/12 ctype: support iscntrl, ispunct, isxdigit and isprint

In reply to Nguyễn Thái Ngọc Duy

A new table sane_ctype2[] is added, otherwise we'll need to OR with current bits in sane_ctype[] and that looks ugly.

---
 ctype.c           | 18 ++++++++++++++++++
 git-compat-util.h | 13 +++++++++++++
 2 files changed, 31 insertions(+)
ctype.c +18 -0
index faeaf34..b4bf48a 100644
@@ -26,6 +26,24 @@ const unsigned char sane_ctype[256] = {
 	/* Nothing in the 128.. range */
 };
 
+enum {
+	CN = GIT_CNTRL,
+	PU = GIT_PUNCT,
+	XD = GIT_XDIGIT,
+};
+
+const unsigned char sane_ctype2[256] = {
+	CN, CN, CN, CN, CN, CN, CN, CN, CN, CN, CN, CN, CN, CN, CN, CN, /*    0..15 */
+	CN, CN, CN, CN, CN, CN, CN, CN, CN, CN, CN, CN, CN, CN, CN, CN, /*   16..31 */
+	0,  PU, PU, PU, PU, PU, PU, PU, PU, PU, PU, PU, PU, PU, PU, PU, /*   32..47 */
+	XD, XD, XD, XD, XD, XD, XD, XD, XD, XD, PU, PU, PU, PU, PU, PU, /*   48..63 */
+	PU, 0,	XD, 0,	XD, 0,	XD, 0,	0,  0,	0,  0,	0,  0,	0,  0,	/*   64..79 */
+	0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  PU, PU, PU, PU, PU, /*   80..95 */
+	PU, 0,	XD, 0,	XD, 0,	XD, 0,	0,  0,	0,  0,	0,  0,	0,  0,	/*  96..111 */
+	0,  0,	0,  0,	0,  0,	0,  0,	0,  0,	0,  PU, PU, PU, PU, CN, /* 112..127 */
+	/* Nothing in the 128.. range */
+};
+
 /* For case-insensitive kwset */
 const char tolower_trans_tbl[256] = {
 	0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
git-compat-util.h +13 -0
index f8b859c..ea11694 100644
@@ -510,14 +510,23 @@ extern const char tolower_trans_tbl[256];
 #undef isupper
 #undef tolower
 #undef toupper
+#undef iscntrl
+#undef ispunct
+#undef isxdigit
+#undef isprint
 extern const unsigned char sane_ctype[256];
+extern const unsigned char sane_ctype2[256];
 #define GIT_SPACE 0x01
 #define GIT_DIGIT 0x02
 #define GIT_ALPHA 0x04
 #define GIT_GLOB_SPECIAL 0x08
 #define GIT_REGEX_SPECIAL 0x10
 #define GIT_PATHSPEC_MAGIC 0x20
+#define GIT_CNTRL 0x01
+#define GIT_PUNCT 0x02
+#define GIT_XDIGIT 0x04
 #define sane_istest(x,mask) ((sane_ctype[(unsigned char)(x)] & (mask)) != 0)
+#define sane_istest2(x,mask) ((sane_ctype2[(unsigned char)(x)] & (mask)) != 0)
 #define isascii(x) (((x) & ~0x7f) == 0)
 #define isspace(x) sane_istest(x,GIT_SPACE)
 #define isdigit(x) sane_istest(x,GIT_DIGIT)
@@ -527,6 +536,10 @@ extern const unsigned char sane_ctype[256];
 #define isupper(x) sane_iscase(x, 0)
 #define is_glob_special(x) sane_istest(x,GIT_GLOB_SPECIAL)
 #define is_regex_special(x) sane_istest(x,GIT_GLOB_SPECIAL | GIT_REGEX_SPECIAL)
+#define iscntrl(x) sane_istest2(x, GIT_CNTRL)
+#define ispunct(x) sane_istest2(x, GIT_PUNCT)
+#define isxdigit(x) sane_istest2(x, GIT_XDIGIT)
+#define isprint(x) (isalnum(x) || isspace(x) || ispunct(x))
 #define tolower(x) sane_case((unsigned char)(x), 0x20)
 #define toupper(x) sane_case((unsigned char)(x), 0)
 #define is_pathspec_magic(x) sane_istest(x,GIT_PATHSPEC_MAGIC)
Signature · 1 line
1.7.12.1.406.g6ab07c4
#3 lore raw

PATCH v4 3/12 Import wildmatch from rsync

In reply to Nguyễn Thái Ngọc Duy

These files are from rsync.git commit f92f5b166e3019db42bc7fe1aa2f1a9178cd215d, which was the last commit before rsync turned GPL-3. All files are imported as-is and no-op. Adaptation is done in a separate patch.

rsync.git           ->  git.git
lib/wildmatch.[ch]      wildmatch.[ch]
wildtest.txt            t/t3070/wildtest.txt
---
 t/t3070/wildtest.txt | 165 +++++++++++++++++++++++
 wildmatch.c          | 368 +++++++++++++++++++++++++++++++++++++++++++++++++++
 wildmatch.h          |   6 +
 3 files changed, 539 insertions(+)
 create mode 100644 t/t3070/wildtest.txt
 create mode 100644 wildmatch.c
 create mode 100644 wildmatch.h
t/t3070/wildtest.txt new file +165 -0
new file mode 100644
index 0000000..42c1678
@@ -0,0 +1,165 @@
+# Input is in the following format (all items white-space separated):
+#
+# The first two items are 1 or 0 indicating if the wildmat call is expected to
+# succeed and if fnmatch works the same way as wildmat, respectively.  After
+# that is a text string for the match, and a pattern string.  Strings can be
+# quoted (if desired) in either double or single quotes, as well as backticks.
+#
+# MATCH FNMATCH_SAME "text to match" 'pattern to use'
+
+# Basic wildmat features
+1 1 foo			foo
+0 1 foo			bar
+1 1 ''			""
+1 1 foo			???
+0 1 foo			??
+1 1 foo			*
+1 1 foo			f*
+0 1 foo			*f
+1 1 foo			*foo*
+1 1 foobar		*ob*a*r*
+1 1 aaaaaaabababab	*ab
+1 1 foo*		foo\*
+0 1 foobar		foo\*bar
+1 1 f\oo		f\\oo
+1 1 ball		*[al]?
+0 1 ten			[ten]
+1 1 ten			**[!te]
+0 1 ten			**[!ten]
+1 1 ten			t[a-g]n
+0 1 ten			t[!a-g]n
+1 1 ton			t[!a-g]n
+1 1 ton			t[^a-g]n
+1 1 a]b			a[]]b
+1 1 a-b			a[]-]b
+1 1 a]b			a[]-]b
+0 1 aab			a[]-]b
+1 1 aab			a[]a-]b
+1 1 ]			]
+
+# Extended slash-matching features
+0 1 foo/baz/bar		foo*bar
+1 1 foo/baz/bar		foo**bar
+0 1 foo/bar		foo?bar
+0 1 foo/bar		foo[/]bar
+0 1 foo/bar		f[^eiu][^eiu][^eiu][^eiu][^eiu]r
+1 1 foo-bar		f[^eiu][^eiu][^eiu][^eiu][^eiu]r
+0 1 foo			**/foo
+1 1 /foo		**/foo
+1 1 bar/baz/foo		**/foo
+0 1 bar/baz/foo		*/foo
+0 0 foo/bar/baz		**/bar*
+1 1 deep/foo/bar/baz	**/bar/*
+0 1 deep/foo/bar/baz/	**/bar/*
+1 1 deep/foo/bar/baz/	**/bar/**
+0 1 deep/foo/bar	**/bar/*
+1 1 deep/foo/bar/	**/bar/**
+1 1 foo/bar/baz		**/bar**
+1 1 foo/bar/baz/x	*/bar/**
+0 0 deep/foo/bar/baz/x	*/bar/**
+1 1 deep/foo/bar/baz/x	**/bar/*/*
+
+# Various additional tests
+0 1 acrt		a[c-c]st
+1 1 acrt		a[c-c]rt
+0 1 ]			[!]-]
+1 1 a			[!]-]
+0 1 ''			\
+0 1 \			\
+0 1 /\			*/\
+1 1 /\			*/\\
+1 1 foo			foo
+1 1 @foo		@foo
+0 1 foo			@foo
+1 1 [ab]		\[ab]
+1 1 [ab]		[[]ab]
+1 1 [ab]		[[:]ab]
+0 1 [ab]		[[::]ab]
+1 1 [ab]		[[:digit]ab]
+1 1 [ab]		[\[:]ab]
+1 1 ?a?b		\??\?b
+1 1 abc			\a\b\c
+0 1 foo			''
+1 1 foo/bar/baz/to	**/t[o]
+
+# Character class tests
+1 1 a1B		[[:alpha:]][[:digit:]][[:upper:]]
+0 1 a		[[:digit:][:upper:][:space:]]
+1 1 A		[[:digit:][:upper:][:space:]]
+1 1 1		[[:digit:][:upper:][:space:]]
+0 1 1		[[:digit:][:upper:][:spaci:]]
+1 1 ' '		[[:digit:][:upper:][:space:]]
+0 1 .		[[:digit:][:upper:][:space:]]
+1 1 .		[[:digit:][:punct:][:space:]]
+1 1 5		[[:xdigit:]]
+1 1 f		[[:xdigit:]]
+1 1 D		[[:xdigit:]]
+1 1 _		[[:alnum:][:alpha:][:blank:][:cntrl:][:digit:][:graph:][:lower:][:print:][:punct:][:space:][:upper:][:xdigit:]]
+#1 1 �		[^[:alnum:][:alpha:][:blank:][:cntrl:][:digit:][:graph:][:lower:][:print:][:punct:][:space:][:upper:][:xdigit:]]
+1 1 		[^[:alnum:][:alpha:][:blank:][:digit:][:graph:][:lower:][:print:][:punct:][:space:][:upper:][:xdigit:]]
+1 1 .		[^[:alnum:][:alpha:][:blank:][:cntrl:][:digit:][:lower:][:space:][:upper:][:xdigit:]]
+1 1 5		[a-c[:digit:]x-z]
+1 1 b		[a-c[:digit:]x-z]
+1 1 y		[a-c[:digit:]x-z]
+0 1 q		[a-c[:digit:]x-z]
+
+# Additional tests, including some malformed wildmats
+1 1 ]		[\\-^]
+0 1 [		[\\-^]
+1 1 -		[\-_]
+1 1 ]		[\]]
+0 1 \]		[\]]
+0 1 \		[\]]
+0 1 ab		a[]b
+0 1 a[]b	a[]b
+0 1 ab[		ab[
+0 1 ab		[!
+0 1 ab		[-
+1 1 -		[-]
+0 1 -		[a-
+0 1 -		[!a-
+1 1 -		[--A]
+1 1 5		[--A]
+1 1 ' '		'[ --]'
+1 1 $		'[ --]'
+1 1 -		'[ --]'
+0 1 0		'[ --]'
+1 1 -		[---]
+1 1 -		[------]
+0 1 j		[a-e-n]
+1 1 -		[a-e-n]
+1 1 a		[!------]
+0 1 [		[]-a]
+1 1 ^		[]-a]
+0 1 ^		[!]-a]
+1 1 [		[!]-a]
+1 1 ^		[a^bc]
+1 1 -b]		[a-]b]
+0 1 \		[\]
+1 1 \		[\\]
+0 1 \		[!\\]
+1 1 G		[A-\\]
+0 1 aaabbb	b*a
+0 1 aabcaa	*ba*
+1 1 ,		[,]
+1 1 ,		[\\,]
+1 1 \		[\\,]
+1 1 -		[,-.]
+0 1 +		[,-.]
+0 1 -.]		[,-.]
+1 1 2		[\1-\3]
+1 1 3		[\1-\3]
+0 1 4		[\1-\3]
+1 1 \		[[-\]]
+1 1 [		[[-\]]
+1 1 ]		[[-\]]
+0 1 -		[[-\]]
+
+# Test recursion and the abort code (use "wildtest -i" to see iteration counts)
+1 1 -adobe-courier-bold-o-normal--12-120-75-75-m-70-iso8859-1	-*-*-*-*-*-*-12-*-*-*-m-*-*-*
+0 1 -adobe-courier-bold-o-normal--12-120-75-75-X-70-iso8859-1	-*-*-*-*-*-*-12-*-*-*-m-*-*-*
+0 1 -adobe-courier-bold-o-normal--12-120-75-75-/-70-iso8859-1	-*-*-*-*-*-*-12-*-*-*-m-*-*-*
+1 1 /adobe/courier/bold/o/normal//12/120/75/75/m/70/iso8859/1	/*/*/*/*/*/*/12/*/*/*/m/*/*/*
+0 1 /adobe/courier/bold/o/normal//12/120/75/75/X/70/iso8859/1	/*/*/*/*/*/*/12/*/*/*/m/*/*/*
+1 1 abcd/abcdefg/abcdefghijk/abcdefghijklmnop.txt		**/*a*b*g*n*t
+0 1 abcd/abcdefg/abcdefghijk/abcdefghijklmnop.txtz		**/*a*b*g*n*t
wildmatch.c new file +368 -0

368 lines not on this page · raw message

wildmatch.h new file +6 -0
new file mode 100644
index 0000000..e7f1a35
@@ -0,0 +1,6 @@
+/* wildmatch.h */
+
+int wildmatch(const char *pattern, const char *text);
+int iwildmatch(const char *pattern, const char *text);
+int wildmatch_array(const char *pattern, const char*const *texts, int where);
+int litmatch_array(const char *string, const char*const *texts, int where);
Signature · 1 line
1.7.12.1.406.g6ab07c4
#4 lore raw

PATCH v4 4/12 wildmatch: remove unnecessary functions

In reply to Nguyễn Thái Ngọc Duy
---
 wildmatch.c | 161 ++++--------------------------------------------------------
 wildmatch.h |   2 -
 2 files changed, 9 insertions(+), 154 deletions(-)
wildmatch.c +9 -152
index f3a1731..71dba76 100644
@@ -53,33 +53,19 @@
 #define ISUPPER(c) (ISASCII(c) && isupper(c))
 #define ISXDIGIT(c) (ISASCII(c) && isxdigit(c))
 
-#ifdef WILD_TEST_ITERATIONS
-int wildmatch_iteration_count;
-#endif
-
 static int force_lower_case = 0;
 
 /* Match pattern "p" against the a virtually-joined string consisting
  * of "text" and any strings in array "a". */
-static int dowild(const uchar *p, const uchar *text, const uchar*const *a)
+static int dowild(const uchar *p, const uchar *text)
 {
     uchar p_ch;
 
-#ifdef WILD_TEST_ITERATIONS
-    wildmatch_iteration_count++;
-#endif
-
     for ( ; (p_ch = *p) != '\0'; text++, p++) {
 	int matched, special;
 	uchar t_ch, prev_ch;
-	while ((t_ch = *text) == '\0') {
-	    if (*a == NULL) {
-		if (p_ch != '*')
-		    return ABORT_ALL;
-		break;
-	    }
-	    text = *a++;
-	}
+	if ((t_ch = *text) == '\0' && p_ch != '*')
+		return ABORT_ALL;
 	if (force_lower_case && ISUPPER(t_ch))
 	    t_ch = tolower(t_ch);
 	switch (p_ch) {
@@ -107,21 +93,15 @@ static int dowild(const uchar *p, const uchar *text, const uchar*const *a)
 		/* Trailing "**" matches everything.  Trailing "*" matches
 		 * only if there are no more slash characters. */
 		if (!special) {
-		    do {
 			if (strchr((char*)text, '/') != NULL)
 			    return FALSE;
-		    } while ((text = *a++) != NULL);
 		}
 		return TRUE;
 	    }
 	    while (1) {
-		if (t_ch == '\0') {
-		    if ((text = *a++) == NULL)
-			break;
-		    t_ch = *text;
-		    continue;
-		}
-		if ((matched = dowild(p, text, a)) != FALSE) {
+		if (t_ch == '\0')
+		    break;
+		if ((matched = dowild(p, text)) != FALSE) {
 		    if (!special || matched != ABORT_TO_STARSTAR)
 			return matched;
 		} else if (!special && t_ch == '/')
@@ -225,144 +205,21 @@ static int dowild(const uchar *p, const uchar *text, const uchar*const *a)
 	}
     }
 
-    do {
-	if (*text)
-	    return FALSE;
-    } while ((text = *a++) != NULL);
-
-    return TRUE;
-}
-
-/* Match literal string "s" against the a virtually-joined string consisting
- * of "text" and any strings in array "a". */
-static int doliteral(const uchar *s, const uchar *text, const uchar*const *a)
-{
-    for ( ; *s != '\0'; text++, s++) {
-	while (*text == '\0') {
-	    if ((text = *a++) == NULL)
-		return FALSE;
-	}
-	if (*text != *s)
-	    return FALSE;
-    }
-
-    do {
-	if (*text)
-	    return FALSE;
-    } while ((text = *a++) != NULL);
-
-    return TRUE;
-}
-
-/* Return the last "count" path elements from the concatenated string.
- * We return a string pointer to the start of the string, and update the
- * array pointer-pointer to point to any remaining string elements. */
-static const uchar *trailing_N_elements(const uchar*const **a_ptr, int count)
-{
-    const uchar*const *a = *a_ptr;
-    const uchar*const *first_a = a;
-
-    while (*a)
-	    a++;
-
-    while (a != first_a) {
-	const uchar *s = *--a;
-	s += strlen((char*)s);
-	while (--s >= *a) {
-	    if (*s == '/' && !--count) {
-		*a_ptr = a+1;
-		return s+1;
-	    }
-	}
-    }
-
-    if (count == 1) {
-	*a_ptr = a+1;
-	return *a;
-    }
-
-    return NULL;
+    return *text ? FALSE : TRUE;
 }
 
 /* Match the "pattern" against the "text" string. */
 int wildmatch(const char *pattern, const char *text)
 {
-    static const uchar *nomore[1]; /* A NULL pointer. */
-#ifdef WILD_TEST_ITERATIONS
-    wildmatch_iteration_count = 0;
-#endif
-    return dowild((const uchar*)pattern, (const uchar*)text, nomore) == TRUE;
+    return dowild((const uchar*)pattern, (const uchar*)text) == TRUE;
 }
 
 /* Match the "pattern" against the forced-to-lower-case "text" string. */
 int iwildmatch(const char *pattern, const char *text)
 {
-    static const uchar *nomore[1]; /* A NULL pointer. */
     int ret;
-#ifdef WILD_TEST_ITERATIONS
-    wildmatch_iteration_count = 0;
-#endif
     force_lower_case = 1;
-    ret = dowild((const uchar*)pattern, (const uchar*)text, nomore) == TRUE;
+    ret = dowild((const uchar*)pattern, (const uchar*)text) == TRUE;
     force_lower_case = 0;
     return ret;
 }
-
-/* Match pattern "p" against the a virtually-joined string consisting
- * of all the pointers in array "texts" (which has a NULL pointer at the
- * end).  The int "where" can be 0 (normal matching), > 0 (match only
- * the trailing N slash-separated filename components of "texts"), or < 0
- * (match the "pattern" at the start or after any slash in "texts"). */
-int wildmatch_array(const char *pattern, const char*const *texts, int where)
-{
-    const uchar *p = (const uchar*)pattern;
-    const uchar*const *a = (const uchar*const*)texts;
-    const uchar *text;
-    int matched;
-
-#ifdef WILD_TEST_ITERATIONS
-    wildmatch_iteration_count = 0;
-#endif
-
-    if (where > 0)
-	text = trailing_N_elements(&a, where);
-    else
-	text = *a++;
-    if (!text)
-	return FALSE;
-
-    if ((matched = dowild(p, text, a)) != TRUE && where < 0
-     && matched != ABORT_ALL) {
-	while (1) {
-	    if (*text == '\0') {
-		if ((text = (uchar*)*a++) == NULL)
-		    return FALSE;
-		continue;
-	    }
-	    if (*text++ == '/' && (matched = dowild(p, text, a)) != FALSE
-	     && matched != ABORT_TO_STARSTAR)
-		break;
-	}
-    }
-    return matched == TRUE;
-}
-
-/* Match literal string "s" against the a virtually-joined string consisting
- * of all the pointers in array "texts" (which has a NULL pointer at the
- * end).  The int "where" can be 0 (normal matching), or > 0 (match
- * only the trailing N slash-separated filename components of "texts"). */
-int litmatch_array(const char *string, const char*const *texts, int where)
-{
-    const uchar *s = (const uchar*)string;
-    const uchar*const *a = (const uchar* const*)texts;
-    const uchar *text;
-
-    if (where > 0)
-	text = trailing_N_elements(&a, where);
-    else
-	text = *a++;
-    if (!text)
-	return FALSE;
-
-    return doliteral(s, text, a) == TRUE;
-}
wildmatch.h +0 -2
index e7f1a35..562faa3 100644
@@ -2,5 +2,3 @@
 
 int wildmatch(const char *pattern, const char *text);
 int iwildmatch(const char *pattern, const char *text);
-int wildmatch_array(const char *pattern, const char*const *texts, int where);
-int litmatch_array(const char *string, const char*const *texts, int where);
Signature · 1 line
1.7.12.1.406.g6ab07c4
#5 lore raw

Re: [PATCH v4 04/12] wildmatch: remove unnecessary functions

Quoted 15 lines · Nguyễn Thái Ngọc Duy
---
 wildmatch.c | 161 ++++--------------------------------------------------------
 wildmatch.h |   2 -
 2 files changed, 9 insertions(+), 154 deletions(-)
wildmatch.c +0 -0
index f3a1731..71dba76 100644
@@ -53,33 +53,19 @@
 #define ISUPPER(c) (ISASCII(c) && isupper(c))
 #define ISXDIGIT(c) (ISASCII(c) && isxdigit(c))
 

wildmatch.c line 60

Quoted 10 lines
wildmatch.c +1 -5
-#ifdef WILD_TEST_ITERATIONS
-int wildmatch_iteration_count;
-#endif
-
 static int force_lower_case = 0;
 
 /* Match pattern "p" against the a virtually-joined string consisting
  * of "text" and any strings in array "a". */
-static int dowild(const uchar *p, const uchar *text, const uchar*const *a)
+static int dowild(const uchar *p, const uchar *text)

The comment still refers to array "a".

Michael

Signature · 3 lines
Michael Haggerty
[email protected]
http://softwareswirl.blogspot.com/
#6 lore raw

PATCH v4 5/12 Integrate wildmatch to git

In reply to Nguyễn Thái Ngọc Duy
---
 .gitignore           |   1 +
 Makefile             |   3 +
 t/t3070-wildmatch.sh | 178 +++++++++++++++++++++++++++++++++++++++++++++++++++
 t/t3070/wildtest.txt | 165 -----------------------------------------------
 test-wildmatch.c     |  14 ++++
 wildmatch.c          |   5 +-
 6 files changed, 200 insertions(+), 166 deletions(-)
 create mode 100755 t/t3070-wildmatch.sh
 delete mode 100644 t/t3070/wildtest.txt
 create mode 100644 test-wildmatch.c
.gitignore +1 -0
index a188a82..37c3507 100644
@@ -197,6 +197,7 @@
 /test-string-list
 /test-subprocess
 /test-svn-fe
+/test-wildmatch
 /common-cmds.h
 *.tar.gz
 *.dsc
Makefile +3 -0
index 8413606..9a97379 100644
@@ -523,6 +523,7 @@ TEST_PROGRAMS_NEED_X += test-sigchain
 TEST_PROGRAMS_NEED_X += test-string-list
 TEST_PROGRAMS_NEED_X += test-subprocess
 TEST_PROGRAMS_NEED_X += test-svn-fe
+TEST_PROGRAMS_NEED_X += test-wildmatch
 
 TEST_PROGRAMS = $(patsubst %,%$X,$(TEST_PROGRAMS_NEED_X))
 
@@ -695,6 +696,7 @@ LIB_H += userdiff.h
 LIB_H += utf8.h
 LIB_H += varint.h
 LIB_H += walker.h
+LIB_H += wildmatch.h
 LIB_H += wt-status.h
 LIB_H += xdiff-interface.h
 LIB_H += xdiff/xdiff.h
@@ -826,6 +828,7 @@ LIB_OBJS += utf8.o
 LIB_OBJS += varint.o
 LIB_OBJS += version.o
 LIB_OBJS += walker.o
+LIB_OBJS += wildmatch.o
 LIB_OBJS += wrapper.o
 LIB_OBJS += write_or_die.o
 LIB_OBJS += ws.o
t/t3070-wildmatch.sh new file +178 -0

178 lines not on this page · raw message

t/t3070/wildtest.txt deleted +0 -165

165 lines not on this page · raw message

test-wildmatch.c new file +14 -0
new file mode 100644
index 0000000..08962d5
@@ -0,0 +1,14 @@
+#include "cache.h"
+#include "wildmatch.h"
+
+int main(int argc, char **argv)
+{
+	if (!strcmp(argv[1], "wildmatch"))
+		return wildmatch(argv[3], argv[2]) ? 0 : 1;
+	else if (!strcmp(argv[1], "iwildmatch"))
+		return iwildmatch(argv[3], argv[2]) ? 0 : 1;
+	else if (!strcmp(argv[1], "fnmatch"))
+		return fnmatch(argv[3], argv[2], FNM_PATHNAME);
+	else
+		return 1;
+}
wildmatch.c +4 -1
index 71dba76..6092bde 100644
@@ -9,7 +9,10 @@
 **  work differently than '*', and to fix the character-class code.
 */
 
-#include "rsync.h"
+#include "cache.h"
+#include "wildmatch.h"
+
+typedef unsigned char uchar;
 
 /* What character marks an inverted character class? */
 #define NEGATE_CLASS	'!'
Signature · 1 line
1.7.12.1.406.g6ab07c4
#7 lore raw

Re: [PATCH v4 05/12] Integrate wildmatch to git

--- >8 ---
From: Johannes Sixt <[email protected]>
Subject: [PATCH] test-wildmatch: avoid exit code -1

Our bash on Windows does not recognize -1 as failure.

---
Please squash this in, in the next round.

 test-wildmatch.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
test-wildmatch.c +3 -3
index d716852..74c0864 100644
@@ -4,11 +4,11 @@
 int main(int argc, char **argv)
 {
 	if (!strcmp(argv[1], "wildmatch"))
-		return wildmatch(argv[3], argv[2], 0);
+		return !!wildmatch(argv[3], argv[2], 0);
 	else if (!strcmp(argv[1], "iwildmatch"))
-		return wildmatch(argv[3], argv[2], FNM_CASEFOLD);
+		return !!wildmatch(argv[3], argv[2], FNM_CASEFOLD);
 	else if (!strcmp(argv[1], "fnmatch"))
-		return fnmatch(argv[3], argv[2], FNM_PATHNAME);
+		return !!fnmatch(argv[3], argv[2], FNM_PATHNAME);
 	else
 		return 1;
 }
Signature · 1 line
1.8.0.rc2.1237.g5522246
#8 lore raw

Re: [PATCH v4 05/12] Integrate wildmatch to git

Quoted 9 lines · Johannes Sixt

--- >8 ---
From: Johannes Sixt <[email protected]>
Subject: [PATCH] test-wildmatch: avoid exit code -1

Our bash on Windows does not recognize -1 as failure.

---
Please squash this in, in the next round.

I do think the patch is good, but I am curious if people who ported bash to windows consider this a bug.

Shouldn't the argument to exit() be truncated to its least significant 8 bits (that is, status & 0377) and be made available to the waiting parent process (which is bash in this case)?

Quoted 22 lines
 test-wildmatch.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
test-wildmatch.c +3 -3
index d716852..74c0864 100644
@@ -4,11 +4,11 @@
 int main(int argc, char **argv)
 {
 	if (!strcmp(argv[1], "wildmatch"))
-		return wildmatch(argv[3], argv[2], 0);
+		return !!wildmatch(argv[3], argv[2], 0);
 	else if (!strcmp(argv[1], "iwildmatch"))
-		return wildmatch(argv[3], argv[2], FNM_CASEFOLD);
+		return !!wildmatch(argv[3], argv[2], FNM_CASEFOLD);
 	else if (!strcmp(argv[1], "fnmatch"))
-		return fnmatch(argv[3], argv[2], FNM_PATHNAME);
+		return !!fnmatch(argv[3], argv[2], FNM_PATHNAME);
 	else
 		return 1;
 }
#9 lore raw

PATCH v4 6/12 wildmatch: make wildmatch's return value compatible with fnmatch

In reply to Nguyễn Thái Ngọc Duy

wildmatch returns non-zero if matched, zero otherwise. This patch makes it return zero if matches, non-zero otherwise, like fnmatch().

---
 test-wildmatch.c |  4 ++--
 wildmatch.c      | 21 ++++++++++++---------
 2 files changed, 14 insertions(+), 11 deletions(-)
test-wildmatch.c +2 -2
index 08962d5..596029c 100644
@@ -4,9 +4,9 @@
 int main(int argc, char **argv)
 {
 	if (!strcmp(argv[1], "wildmatch"))
-		return wildmatch(argv[3], argv[2]) ? 0 : 1;
+		return wildmatch(argv[3], argv[2]);
 	else if (!strcmp(argv[1], "iwildmatch"))
-		return iwildmatch(argv[3], argv[2]) ? 0 : 1;
+		return iwildmatch(argv[3], argv[2]);
 	else if (!strcmp(argv[1], "fnmatch"))
 		return fnmatch(argv[3], argv[2], FNM_PATHNAME);
 	else
wildmatch.c +12 -9
index 6092bde..7c180e3 100644
@@ -20,6 +20,9 @@ typedef unsigned char uchar;
 
 #define FALSE 0
 #define TRUE 1
+
+#define NOMATCH 1
+#define MATCH 0
 #define ABORT_ALL -1
 #define ABORT_TO_STARSTAR -2
 
@@ -79,12 +82,12 @@ static int dowild(const uchar *p, const uchar *text)
 	    /* FALLTHROUGH */
 	  default:
 	    if (t_ch != p_ch)
-		return FALSE;
+		return NOMATCH;
 	    continue;
 	  case '?':
 	    /* Match anything but '/'. */
 	    if (t_ch == '/')
-		return FALSE;
+		return NOMATCH;
 	    continue;
 	  case '*':
 	    if (*++p == '*') {
@@ -97,14 +100,14 @@ static int dowild(const uchar *p, const uchar *text)
 		 * only if there are no more slash characters. */
 		if (!special) {
 			if (strchr((char*)text, '/') != NULL)
-			    return FALSE;
+			    return NOMATCH;
 		}
-		return TRUE;
+		return MATCH;
 	    }
 	    while (1) {
 		if (t_ch == '\0')
 		    break;
-		if ((matched = dowild(p, text)) != FALSE) {
+		if ((matched = dowild(p, text)) != NOMATCH) {
 		    if (!special || matched != ABORT_TO_STARSTAR)
 			return matched;
 		} else if (!special && t_ch == '/')
@@ -203,18 +206,18 @@ static int dowild(const uchar *p, const uchar *text)
 		    matched = TRUE;
 	    } while (prev_ch = p_ch, (p_ch = *++p) != ']');
 	    if (matched == special || t_ch == '/')
-		return FALSE;
+		return NOMATCH;
 	    continue;
 	}
     }
 
-    return *text ? FALSE : TRUE;
+    return *text ? NOMATCH : MATCH;
 }
 
 /* Match the "pattern" against the "text" string. */
 int wildmatch(const char *pattern, const char *text)
 {
-    return dowild((const uchar*)pattern, (const uchar*)text) == TRUE;
+    return dowild((const uchar*)pattern, (const uchar*)text);
 }
 
 /* Match the "pattern" against the forced-to-lower-case "text" string. */
@@ -222,7 +225,7 @@ int iwildmatch(const char *pattern, const char *text)
 {
     int ret;
     force_lower_case = 1;
-    ret = dowild((const uchar*)pattern, (const uchar*)text) == TRUE;
+    ret = dowild((const uchar*)pattern, (const uchar*)text);
     force_lower_case = 0;
     return ret;
 }
Signature · 1 line
1.7.12.1.406.g6ab07c4
#10 lore raw

PATCH v4 7/12 wildmatch: remove static variable force_lower_case

In reply to Nguyễn Thái Ngọc Duy

One place less to worry about thread safety. Also combine wildmatch and iwildmatch into one.

---
 test-wildmatch.c |  4 ++--
 wildmatch.c      | 21 +++++----------------
 wildmatch.h      |  3 +--
 3 files changed, 8 insertions(+), 20 deletions(-)
test-wildmatch.c +2 -2
index 596029c..d716852 100644
@@ -4,9 +4,9 @@
 int main(int argc, char **argv)
 {
 	if (!strcmp(argv[1], "wildmatch"))
-		return wildmatch(argv[3], argv[2]);
+		return wildmatch(argv[3], argv[2], 0);
 	else if (!strcmp(argv[1], "iwildmatch"))
-		return iwildmatch(argv[3], argv[2]);
+		return wildmatch(argv[3], argv[2], FNM_CASEFOLD);
 	else if (!strcmp(argv[1], "fnmatch"))
 		return fnmatch(argv[3], argv[2], FNM_PATHNAME);
 	else
wildmatch.c +5 -16
index 7c180e3..d18d721 100644
@@ -59,11 +59,9 @@ typedef unsigned char uchar;
 #define ISUPPER(c) (ISASCII(c) && isupper(c))
 #define ISXDIGIT(c) (ISASCII(c) && isxdigit(c))
 
-static int force_lower_case = 0;
-
 /* Match pattern "p" against the a virtually-joined string consisting
  * of "text" and any strings in array "a". */
-static int dowild(const uchar *p, const uchar *text)
+static int dowild(const uchar *p, const uchar *text, int force_lower_case)
 {
     uchar p_ch;
 
@@ -107,7 +105,7 @@ static int dowild(const uchar *p, const uchar *text)
 	    while (1) {
 		if (t_ch == '\0')
 		    break;
-		if ((matched = dowild(p, text)) != NOMATCH) {
+		if ((matched = dowild(p, text, force_lower_case)) != NOMATCH) {
 		    if (!special || matched != ABORT_TO_STARSTAR)
 			return matched;
 		} else if (!special && t_ch == '/')
@@ -215,17 +213,8 @@ static int dowild(const uchar *p, const uchar *text)
 }
 
 /* Match the "pattern" against the "text" string. */
-int wildmatch(const char *pattern, const char *text)
-{
-    return dowild((const uchar*)pattern, (const uchar*)text);
-}
-
-/* Match the "pattern" against the forced-to-lower-case "text" string. */
-int iwildmatch(const char *pattern, const char *text)
+int wildmatch(const char *pattern, const char *text, int flags)
 {
-    int ret;
-    force_lower_case = 1;
-    ret = dowild((const uchar*)pattern, (const uchar*)text);
-    force_lower_case = 0;
-    return ret;
+    return dowild((const uchar*)pattern, (const uchar*)text,
+		  flags & FNM_CASEFOLD ? 1 : 0);
 }
wildmatch.h +1 -2
index 562faa3..e974f9a 100644
@@ -1,4 +1,3 @@
 /* wildmatch.h */
 
-int wildmatch(const char *pattern, const char *text);
-int iwildmatch(const char *pattern, const char *text);
+int wildmatch(const char *pattern, const char *text, int flags);
Signature · 1 line
1.7.12.1.406.g6ab07c4
#11 lore raw

PATCH v4 8/12 wildmatch: fix case-insensitive matching

In reply to Nguyễn Thái Ngọc Duy

dowild() does case insensitive matching by lower-casing the text. That means lower case letters in patterns imply case-insensitive matching, but upper case means exact matching.

We do not want that subtlety. Lower case pattern too so iwildmatch() always does what we expect it to do.

---
 wildmatch.c | 2 ++
 1 file changed, 2 insertions(+)
wildmatch.c +2 -0
index d18d721..b700631 100644
@@ -72,6 +72,8 @@ static int dowild(const uchar *p, const uchar *text, int force_lower_case)
 		return ABORT_ALL;
 	if (force_lower_case && ISUPPER(t_ch))
 	    t_ch = tolower(t_ch);
+	if (force_lower_case && ISUPPER(p_ch))
+	    p_ch = tolower(p_ch);
 	switch (p_ch) {
 	  case '\\':
 	    /* Literal match with following character.  Note that the test
Signature · 1 line
1.7.12.1.406.g6ab07c4
#12 lore raw

PATCH v4 9/12 wildmatch: adjust "**" behavior

In reply to Nguyễn Thái Ngọc Duy

Standard wildmatch() sees consecutive asterisks as "*" that can also match slashes. But that may be hard to explain to users as "abc/**/def" can match "abcdef", "abcxyzdef", "abc/def", "abc/x/def", "abc/x/y/def"...

This patch changes wildmatch so that users can do

- "**/def" -> all paths ending with file/directory 'def'
- "abc/**" - equivalent to "/abc/"
- "abc/**/def" -> "abc/x/def", "abc/x/y/def"...
- otherwise consider the pattern malformed if "**" is found

Basically the magic of "**" only remains if it's wrapped around by slashes.

---
 t/t3070-wildmatch.sh |  5 +++--
 wildmatch.c          | 13 +++++++------
 wildmatch.h          |  6 ++++++
 3 files changed, 16 insertions(+), 8 deletions(-)
t/t3070-wildmatch.sh +3 -2
index bb92f8d..f6c64be 100755
@@ -36,7 +36,7 @@ match 0 0 foobar 'foo\*bar'
 match 1 1 'f\oo' 'f\\oo'
 match 1 1 ball '*[al]?'
 match 0 0 ten '[ten]'
-match 1 1 ten '**[!te]'
+match 0 1 ten '**[!te]'
 match 0 0 ten '**[!ten]'
 match 1 1 ten 't[a-g]n'
 match 0 0 ten 't[!a-g]n'
@@ -51,7 +51,8 @@ match 1 1 ']' ']'
 
 # Extended slash-matching features
 match 0 0 'foo/baz/bar' 'foo*bar'
-match 1 0 'foo/baz/bar' 'foo**bar'
+match 0 0 'foo/baz/bar' 'foo**bar'
+match 0 1 'foobazbar' 'foo**bar'
 match 0 0 'foo/bar' 'foo?bar'
 match 0 0 'foo/bar' 'foo[/]bar'
 match 0 0 'foo/bar' 'f[^eiu][^eiu][^eiu][^eiu][^eiu]r'
wildmatch.c +7 -6
index b700631..e09a459 100644
@@ -21,11 +21,6 @@ typedef unsigned char uchar;
 #define FALSE 0
 #define TRUE 1
 
-#define NOMATCH 1
-#define MATCH 0
-#define ABORT_ALL -1
-#define ABORT_TO_STARSTAR -2
-
 #define CC_EQ(class, len, litmatch) ((len) == sizeof (litmatch)-1 \
 				    && *(class) == *(litmatch) \
 				    && strncmp((char*)class, litmatch, len) == 0)
@@ -91,8 +86,14 @@ static int dowild(const uchar *p, const uchar *text, int force_lower_case)
 	    continue;
 	  case '*':
 	    if (*++p == '*') {
+		const uchar *prev_p = p - 2;
 		while (*++p == '*') {}
-		special = TRUE;
+		if ((prev_p == text || *prev_p == '/') ||
+		    (*p == '\0' || *p == '/' ||
+		     (p[0] == '\\' && p[1] == '/'))) {
+		    special = TRUE;
+		} else
+		    return ABORT_MALFORMED;
 	    } else
 		special = FALSE;
 	    if (*p == '\0') {
wildmatch.h +6 -0
index e974f9a..984a38c 100644
@@ -1,3 +1,9 @@
 /* wildmatch.h */
 
+#define ABORT_MALFORMED 2
+#define NOMATCH 1
+#define MATCH 0
+#define ABORT_ALL -1
+#define ABORT_TO_STARSTAR -2
+
 int wildmatch(const char *pattern, const char *text, int flags);
Signature · 1 line
1.7.12.1.406.g6ab07c4
#13 lore raw

PATCH v4 10/12 wildmatch: make /**/ match zero or more directories

In reply to Nguyễn Thái Ngọc Duy

"foo/**/bar" matches "foo/x/bar", "foo/x/y/bar"... but not "foo/bar". We make a special case, when foo/**/ is detected (and "foo/" part is already matched), try matching "bar" with the rest of the string.

"Match one or more directories" semantics can be easily achieved using "foo/*/**/bar".

This also makes "**/foo" match "foo" in addition to "x/foo", "x/y/foo"..

---
 t/t3070-wildmatch.sh |  8 +++++++-
 wildmatch.c          | 17 +++++++++++++++++
 2 files changed, 24 insertions(+), 1 deletion(-)
t/t3070-wildmatch.sh +7 -1
index f6c64be..f21da6c 100755
@@ -53,11 +53,17 @@ match 1 1 ']' ']'
 match 0 0 'foo/baz/bar' 'foo*bar'
 match 0 0 'foo/baz/bar' 'foo**bar'
 match 0 1 'foobazbar' 'foo**bar'
+match 1 1 'foo/baz/bar' 'foo/**/bar'
+match 1 0 'foo/baz/bar' 'foo/**/**/bar'
+match 1 0 'foo/b/a/z/bar' 'foo/**/bar'
+match 1 0 'foo/b/a/z/bar' 'foo/**/**/bar'
+match 1 0 'foo/bar' 'foo/**/bar'
+match 1 0 'foo/bar' 'foo/**/**/bar'
 match 0 0 'foo/bar' 'foo?bar'
 match 0 0 'foo/bar' 'foo[/]bar'
 match 0 0 'foo/bar' 'f[^eiu][^eiu][^eiu][^eiu][^eiu]r'
 match 1 1 'foo-bar' 'f[^eiu][^eiu][^eiu][^eiu][^eiu]r'
-match 0 0 'foo' '**/foo'
+match 1 0 'foo' '**/foo'
 match 1 1 '/foo' '**/foo'
 match 1 0 'bar/baz/foo' '**/foo'
 match 0 0 'bar/baz/foo' '*/foo'
wildmatch.c +17 -0
index e09a459..f060bb0 100644
@@ -91,6 +91,23 @@ static int dowild(const uchar *p, const uchar *text, int force_lower_case)
 		if ((prev_p == text || *prev_p == '/') ||
 		    (*p == '\0' || *p == '/' ||
 		     (p[0] == '\\' && p[1] == '/'))) {
+			/*
+			 * Assuming we already match 'foo/' and are at
+			 * <star star slash>, just assume it matches
+			 * nothing and go ahead match the rest of the
+			 * pattern with the remaining string. This
+			 * helps make foo/<*><*>/bar (<> because
+			 * otherwise it breaks C comment syntax) match
+			 * both foo/bar and foo/a/bar.
+			 *
+			 * Crazy patterns like /<*><*>/<*><*>/ are
+			 * treated like /<*><*>/. But undefined
+			 * behavior is even appropriate for people
+			 * writing such a pattern.
+			 */
+			if (p[0] == '/' &&
+			    dowild(p + 1, text, force_lower_case) == MATCH)
+				return MATCH;
 		    special = TRUE;
 		} else
 		    return ABORT_MALFORMED;
Signature · 1 line
1.7.12.1.406.g6ab07c4
#14 lore raw

PATCH v4 11/12 Support "**" wildcard in .gitignore and .gitattributes

In reply to Nguyễn Thái Ngọc Duy
---
 Documentation/gitattributes.txt    |  6 ++++++
 Documentation/gitignore.txt        | 19 +++++++++++++++++++
 attr.c                             |  4 +++-
 dir.c                              |  4 +++-
 t/t0003-attributes.sh              | 38 ++++++++++++++++++++++++++++++++++++++
 t/t3001-ls-files-others-exclude.sh | 19 +++++++++++++++++++
 6 files changed, 88 insertions(+), 2 deletions(-)
Documentation/gitattributes.txt +6 -0
index 99ed04d..93c542b 100644
@@ -57,6 +57,12 @@ overrides an earlier line.  This overriding is done per
 attribute.  The rules how the pattern matches paths are the
 same as in `.gitignore` files; see linkgit:gitignore[5].
 
+Note that if a .gitignore rule matches a directory, the directory
+is ignored, which may be seen as "ignore" attribute propagated to
+to all files and directories inside. If a .gitattributes rule
+matches a directory, it manipulates attributes on that directory
+only, not files and directories inside.
+
 When deciding what attributes are assigned to a path, git
 consults `$GIT_DIR/info/attributes` file (which has the highest
 precedence), `.gitattributes` file in the same directory as the
Documentation/gitignore.txt +19 -0
index 96639e0..b564b4b 100644
@@ -104,6 +104,25 @@ PATTERN FORMAT
    For example, "/{asterisk}.c" matches "cat-file.c" but not
    "mozilla-sha1/sha1.c".
 
+Two consecutive asterisks ("`**`") in patterns matched against
+full pathname may have special meaning:
+
+ - A leading "`**`" followed by a slash means match in all
+   directories. For example, "`**/foo`" matches file or directory
+   "`foo`" anywhere, the same as pattern "`foo`". "**/foo/bar"
+   matches file or directory "`bar`" anywhere that is directly
+   under directory "`foo`".
+
+ - A trailing "/**" matches everything inside. For example,
+   "abc/**" matches all files inside directory "abc", relative
+   to the location of the `.gitignore` file, with infinite depth.
+
+ - A slash followed by two consecutive asterisks then a slash
+   matches zero or more directories. For example, "`a/**/b`"
+   matches "`a/b`", "`a/x/b`", "`a/x/y/b`" and so on.
+
+ - Other consecutive asterisks are considered invalid.
+
 NOTES
 -----
 
attr.c +3 -1
index 887a9ae..8010429 100644
@@ -12,6 +12,7 @@
 #include "exec_cmd.h"
 #include "attr.h"
 #include "dir.h"
+#include "wildmatch.h"
 
 const char git_attr__true[] = "(builtin)true";
 const char git_attr__false[] = "\0(builtin)false";
@@ -666,7 +667,8 @@ static int path_matches(const char *pathname, int pathlen,
 		return 0;
 	if (baselen != 0)
 		baselen++;
-	return fnmatch_icase(pattern, pathname + baselen, FNM_PATHNAME) == 0;
+	return wildmatch(pattern, pathname + baselen,
+			 ignore_case ? FNM_CASEFOLD : 0) == 0;
 }
 
 static int macroexpand_one(int attr_nr, int rem);
dir.c +3 -1
index 4868339..442db1c 100644
@@ -8,6 +8,7 @@
 #include "cache.h"
 #include "dir.h"
 #include "refs.h"
+#include "wildmatch.h"
 
 struct path_simplify {
 	int len;
@@ -575,7 +576,8 @@ int excluded_from_list(const char *pathname,
 			namelen -= prefix;
 		}
 
-		if (!namelen || !fnmatch_icase(exclude, name, FNM_PATHNAME))
+		if (!namelen ||
+		    wildmatch(exclude, name, ignore_case ? FNM_CASEFOLD : 0) == 0)
 			return to_exclude;
 	}
 	return -1; /* undecided */
t/t0003-attributes.sh +38 -0
index febc45c..67a5694 100755
@@ -232,4 +232,42 @@ test_expect_success 'bare repository: test info/attributes' '
 	attr_check subdir/a/i unspecified
 '
 
+test_expect_success '"**" test' '
+	cd .. &&
+	echo "**/f foo=bar" >.gitattributes &&
+	cat <<\EOF >expect &&
+f: foo: bar
+a/f: foo: bar
+a/b/f: foo: bar
+a/b/c/f: foo: bar
+EOF
+	git check-attr foo -- "f" >actual 2>err &&
+	git check-attr foo -- "a/f" >>actual 2>>err &&
+	git check-attr foo -- "a/b/f" >>actual 2>>err &&
+	git check-attr foo -- "a/b/c/f" >>actual 2>>err &&
+	test_cmp expect actual &&
+	test_line_count = 0 err
+'
+
+test_expect_success '"**" with no slashes test' '
+	echo "a**f foo=bar" >.gitattributes &&
+	git check-attr foo -- "f" >actual &&
+	cat <<\EOF >expect &&
+f: foo: unspecified
+af: foo: bar
+axf: foo: bar
+a/f: foo: unspecified
+a/b/f: foo: unspecified
+a/b/c/f: foo: unspecified
+EOF
+	git check-attr foo -- "f" >actual 2>err &&
+	git check-attr foo -- "af" >>actual 2>err &&
+	git check-attr foo -- "axf" >>actual 2>err &&
+	git check-attr foo -- "a/f" >>actual 2>>err &&
+	git check-attr foo -- "a/b/f" >>actual 2>>err &&
+	git check-attr foo -- "a/b/c/f" >>actual 2>>err &&
+	test_cmp expect actual &&
+	test_line_count = 0 err
+'
+
 test_done
t/t3001-ls-files-others-exclude.sh +19 -0
index c8fe978..278315d 100755
@@ -214,4 +214,23 @@ test_expect_success 'subdirectory ignore (l1)' '
 	test_cmp expect actual
 '
 
+
+test_expect_success 'ls-files with "**" patterns' '
+	cat <<\EOF >expect &&
+a.1
+one/a.1
+one/two/a.1
+three/a.1
+EOF
+	git ls-files -o -i --exclude "**/a.1" >actual
+	test_cmp expect actual
+'
+
+
+test_expect_success 'ls-files with "**" patterns and no slashes' '
+	: >expect &&
+	git ls-files -o -i --exclude "one**a.1" >actual &&
+	test_cmp expect actual
+'
+
 test_done
Signature · 1 line
1.7.12.1.406.g6ab07c4
#15 lore raw

PATCH v4 12/12 t3070: disable two fnmatch tests that have different results on different libc

In reply to Nguyễn Thái Ngọc Duy

fnmatch on glibc-2.12.1 returns no match. glibc-2.15 returns ok.

---
 t/t3070-wildmatch.sh | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
t/t3070-wildmatch.sh +4 -2
index f21da6c..38042eb 100755
@@ -13,6 +13,8 @@ match() {
 	fi &&
 	if [ $2 = 1 ]; then
 	    test-wildmatch fnmatch '$3' '$4'
+	elif [ $2 = x ]; then
+	    true
 	else
 	    ! test-wildmatch fnmatch '$3' '$4'
 	fi
@@ -129,8 +131,8 @@ match 1 1 ']' '[\]]'
 match 0 0 '\]' '[\]]'
 match 0 0 '\' '[\]]'
 match 0 0 'ab' 'a[]b'
-match 0 1 'a[]b' 'a[]b'
-match 0 1 'ab[' 'ab['
+match 0 x 'a[]b' 'a[]b'
+match 0 x 'ab[' 'ab['
 match 0 0 'ab' '[!'
 match 0 0 'ab' '[-'
 match 1 1 '-' '[-]'
Signature · 1 line
1.7.12.1.406.g6ab07c4
#16 lore raw

Re: [PATCH v4 12/12] t3070: disable two fnmatch tests that have different results on different libc

Am 10/10/2012 12:40, schrieb Nguyễn Thái Ngọc Duy:

Quoted 1 line

fnmatch on glibc-2.12.1 returns no match. glibc-2.15 returns ok.

There are many more cases that fail with the fnmatch() that we ship in compat/fnmatch. To test this on Linux, you have to remove the "#if defined _LIBC || !defined __GNU_LIBRARY__" brackets from compat/fnmatch/fnmatch.c and build with NO_FNMATCH.

-- Hannes

#17 lore raw

Re: [PATCH v4 12/12] t3070: disable two fnmatch tests that have different results on different libc

Quoted 7 lines · Johannes Sixt

Am 10/10/2012 12:40, schrieb Nguyễn Thái Ngọc Duy:

Quoted 1 line

fnmatch on glibc-2.12.1 returns no match. glibc-2.15 returns ok.

There are many more cases that fail with the fnmatch() that we ship in compat/fnmatch. To test this on Linux, you have to remove the "#if defined _LIBC || !defined __GNU_LIBRARY__" brackets from compat/fnmatch/fnmatch.c and build with NO_FNMATCH.

Thanks. The point of checking against fnmatch is to make sure that wildmatch does not divert in behavior from fnmatch. For some corner cases that behavior is undefined, I think it is ok for different fnmatch versions to behave differently.

But some of failed tests make me worry about fnmatch. compat/fnmatch for example does not match '**/foo' with '/foo' (it does '*/foo' with '/foo'). 'A' is matched with '[[:digit:][:space:][:upper:]]' but not '[[:digit:][:upper:][:space:]]'. Perhaps we better off convert git to use wildmatch only to keep matching behavior more reliable. wildmatch does not support non-FNM_PATHNAME mode, but that should be easy to fix. The only downside I see is fnmatch may support locale while wildmatch does not.

Signature · 1 line
Duy
#19 lore raw
Quoted 4 lines · Junio C Hamano
Quoted 2 lines · Nguyễn Thái Ngọc Duy

Really small updates. I did not want to resend it this soon but this may fix the compile errors for Junio.

t3070 seems to break TAP,

*** prove ***
t3070-wildmatch.sh .. Failed 1/151 subtests

Test Summary Report
-------------------
t3070-wildmatch.sh (Wstat: 0 Tests: 150 Failed: 0)
Parse errors: Tests out of sequence. Found (76) but expected (75)
Tests out of sequence. Found (77) but expected (76) Tests out of sequence. Found (78) but expected (77) Tests out of sequence. Found (79) but expected (78) Tests out of sequence. Found (80) but expected (79)
Displayed the first 5 of 77 TAP syntax errors.

This probably is due to this part of the output:

    ok 72 - wildmatch 1 1 [ab] [\[:]ab]
    ok 73 - wildmatch 1 1 ?a?b \??\?b
    ok 74 - wildmatch 1 1 abc ^G^Hok 75 - wildmatch 0 0 foo 
    ok 76 - wildmatch 1 0 foo/bar/baz/to **/t[o]
    ok 77 - wildmatch 1 1 a1B [[:alpha:]][[:digit:]][[:upper:]]
#20 lore raw
Quoted 22 lines · Junio C Hamano
Quoted 4 lines · Junio C Hamano
Quoted 2 lines · Nguyễn Thái Ngọc Duy

Really small updates. I did not want to resend it this soon but this may fix the compile errors for Junio.

t3070 seems to break TAP,

*** prove ***
t3070-wildmatch.sh .. Failed 1/151 subtests

Test Summary Report
-------------------
t3070-wildmatch.sh (Wstat: 0 Tests: 150 Failed: 0)
Parse errors: Tests out of sequence. Found (76) but expected (75)
Tests out of sequence. Found (77) but expected (76) Tests out of sequence. Found (78) but expected (77) Tests out of sequence. Found (79) but expected (78) Tests out of sequence. Found (80) but expected (79)
Displayed the first 5 of 77 TAP syntax errors.

Quoted 8 lines

This probably is due to this part of the output:

    ok 72 - wildmatch 1 1 [ab] [\[:]ab]
    ok 73 - wildmatch 1 1 ?a?b \??\?b
    ok 74 - wildmatch 1 1 abc ^G^Hok 75 - wildmatch 0 0 foo
    ok 76 - wildmatch 1 0 foo/bar/baz/to **/t[o]
    ok 77 - wildmatch 1 1 a1B [[:alpha:]][[:digit:]][[:upper:]]

It seems to prove fine here with perl 5.12.3, Test-Harness-3.230, bash-4.0_p38. What version do you use?

Signature · 1 line
Duy
#21 lore raw
Quoted 32 lines · Nguyen Thai Ngoc Duy
Quoted 22 lines · Junio C Hamano
Quoted 4 lines · Junio C Hamano
Quoted 2 lines · Nguyễn Thái Ngọc Duy

Really small updates. I did not want to resend it this soon but this may fix the compile errors for Junio.

t3070 seems to break TAP,

*** prove ***
t3070-wildmatch.sh .. Failed 1/151 subtests

Test Summary Report
-------------------
t3070-wildmatch.sh (Wstat: 0 Tests: 150 Failed: 0)
Parse errors: Tests out of sequence. Found (76) but expected (75)
Tests out of sequence. Found (77) but expected (76) Tests out of sequence. Found (78) but expected (77) Tests out of sequence. Found (79) but expected (78) Tests out of sequence. Found (80) but expected (79)
Displayed the first 5 of 77 TAP syntax errors.

Quoted 8 lines

This probably is due to this part of the output:

    ok 72 - wildmatch 1 1 [ab] [\[:]ab]
    ok 73 - wildmatch 1 1 ?a?b \??\?b
    ok 74 - wildmatch 1 1 abc ^G^Hok 75 - wildmatch 0 0 foo
    ok 76 - wildmatch 1 0 foo/bar/baz/to **/t[o]
    ok 77 - wildmatch 1 1 a1B [[:alpha:]][[:digit:]][[:upper:]]
Quoted 2 lines

It seems to prove fine here with perl 5.12.3, Test-Harness-3.230, bash-4.0_p38. What version do you use?

I seem to have Perl 5.10.1, Test::Harness 3.17, Dash 0.5.5.1. But as you can see above, what is _fed_ to the Perl-side is broken (notice the concatenation at the end of "ok 74"), so I do not think versions of Perl-side matters.

I suspect that this is the immediate culprit:

    match 1 1 'abc' '\a\b\c'

The symptom looks like that somebody is interpreting \a as BEL, \b as backspace, etc. when showing the "ok ..." line, no?

#22 lore raw
Quoted 7 lines · Junio C Hamano
Quoted 7 lines
Quoted 7 lines

This probably is due to this part of the output:

    ok 72 - wildmatch 1 1 [ab] [\[:]ab]
    ok 73 - wildmatch 1 1 ?a?b \??\?b
    ok 74 - wildmatch 1 1 abc ^G^Hok 75 - wildmatch 0 0 foo
    ok 76 - wildmatch 1 0 foo/bar/baz/to **/t[o]
    ok 77 - wildmatch 1 1 a1B [[:alpha:]][[:digit:]][[:upper:]]
Quoted 8 lines
Quoted 1 line

...

I suspect that this is the immediate culprit:

    match 1 1 'abc' '\a\b\c'

The symptom looks like that somebody is interpreting \a as BEL, \b as backspace, etc. when showing the "ok ..." line, no?

Ahh, it must be this bits from t/test-lib.sh

 t/test-lib.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
t/test-lib.sh +1 -1
index 514282c..489bc80 100644
@@ -230,7 +230,7 @@ else
 	say_color() {
 		test -z "$1" && test -n "$quiet" && return
 		shift
-		echo "$*"
+		printf "%s\n" "$*"
 	}
 fi
 
#23 lore raw
Quoted 10 lines · Junio C Hamano

Ahh, it must be this bits from t/test-lib.sh

 t/test-lib.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
t/test-lib.sh +0 -0
index 514282c..489bc80 100644

t/test-lib.sh else · line 235

Quoted 7 lines
t/test-lib.sh +1 -1
@@ -230,7 +230,7 @@ else
 	say_color() {
 		test -z "$1" && test -n "$quiet" && return
 		shift
-		echo "$*"
+		printf "%s\n" "$*"
 	}
 fi

I'll queue this fix separately before your series on 'pu'.

-- >8 --
Subject: [PATCH] test-lib: Fix say_color () not to interpret \a\b\c in the message

When running with color disabled (e.g. under prove to produce TAP output), say_color() helper function is defined to use echo to show the message. With a message that ends with "\c", echo is allowed to interpret it as "Do not end the line with LF".

Use printf "%s\n" to emit the message literally.

---
 t/test-lib.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
t/test-lib.sh +1 -1
index c0d04c4..280b3aa 100644
@@ -169,7 +169,7 @@ else
 	say_color() {
 		test -z "$1" && test -n "$quiet" && return
 		shift
-		echo "$*"
+		printf "%s\n" "$*"
 	}
 fi
 
Signature · 1 line
1.8.0.rc1.82.ga68bb49
#24 lore raw
In reply to Nguyen Thai Ngoc Duy
Quoted 32 lines · Nguyen Thai Ngoc Duy
Quoted 22 lines · Junio C Hamano
Quoted 4 lines · Junio C Hamano
Quoted 2 lines · Nguyễn Thái Ngọc Duy

Really small updates. I did not want to resend it this soon but this may fix the compile errors for Junio.

t3070 seems to break TAP,

*** prove ***
t3070-wildmatch.sh .. Failed 1/151 subtests

Test Summary Report
-------------------
t3070-wildmatch.sh (Wstat: 0 Tests: 150 Failed: 0)
Parse errors: Tests out of sequence. Found (76) but expected (75)
Tests out of sequence. Found (77) but expected (76) Tests out of sequence. Found (78) but expected (77) Tests out of sequence. Found (79) but expected (78) Tests out of sequence. Found (80) but expected (79)
Displayed the first 5 of 77 TAP syntax errors.

Quoted 8 lines

This probably is due to this part of the output:

    ok 72 - wildmatch 1 1 [ab] [\[:]ab]
    ok 73 - wildmatch 1 1 ?a?b \??\?b
    ok 74 - wildmatch 1 1 abc ^G^Hok 75 - wildmatch 0 0 foo
    ok 76 - wildmatch 1 0 foo/bar/baz/to **/t[o]
    ok 77 - wildmatch 1 1 a1B [[:alpha:]][[:digit:]][[:upper:]]
Quoted 3 lines

It seems to prove fine here with perl 5.12.3, Test-Harness-3.230, bash-4.0_p38. What version do you use?

Some problems even here (Mac OS) commit 2aeb6d4d7884f4c4425

not ok 61 - wildmatch 0 0 \ \
not ok 62 - wildmatch 0 0 /\ */\
not ok 69 - wildmatch 1 1 [ab] [[:]ab]
not ok 71 - wildmatch 1 1 [ab] [[:digit]ab]
not ok 80 - wildmatch 1 0 1 [[:digit:][:upper:][:space:]]
not ok 81 - wildmatch 0 0 1 [[:digit:][:upper:][:spaci:]]
not ok 88 - wildmatch 1 0 _ [[:alnum:][:alpha:][:blank:][:cntrl:][:digit:][:graph:][:lower:][:print:][:punct:][:space:][:upper:][:xdigit:]] not ok 89 - wildmatch 1 0 _ [[:alnum:][:alpha:][:blank:][:cntrl:][:digit:][:graph:][:lower:][:print:][:punct:][:space:][:upper:][:xdigit:]] not ok 93 - wildmatch 1 1 y [a-c[:digit:]x-z]

I have 2 perls, I'm not sure which versin is used by git these days.

which perl
/opt/local/bin/perl
tb@birne:~/projects/git/git.pu/t> perl --version

This is perl, v5.8.9 built for darwin-2level

----------------
/usr/bin/perl --version

This is perl, v5.10.0 built for darwin-thread-multi-2level (with 2 registered patches, see perl -V for more detail)
----------

If I can do more debugging/testing please let me know /Torsten

#25 lore raw
Quoted 48 lines · Torsten Bögershausen
Quoted 32 lines · Nguyen Thai Ngoc Duy
Quoted 22 lines · Junio C Hamano
Quoted 4 lines · Junio C Hamano
Quoted 2 lines · Nguyễn Thái Ngọc Duy

Really small updates. I did not want to resend it this soon but this may fix the compile errors for Junio.

t3070 seems to break TAP,

*** prove ***
t3070-wildmatch.sh .. Failed 1/151 subtests

Test Summary Report
-------------------
t3070-wildmatch.sh (Wstat: 0 Tests: 150 Failed: 0)
Parse errors: Tests out of sequence. Found (76) but expected (75)
Tests out of sequence. Found (77) but expected (76) Tests out of sequence. Found (78) but expected (77) Tests out of sequence. Found (79) but expected (78) Tests out of sequence. Found (80) but expected (79)
Displayed the first 5 of 77 TAP syntax errors.

Quoted 8 lines

This probably is due to this part of the output:

    ok 72 - wildmatch 1 1 [ab] [\[:]ab]
    ok 73 - wildmatch 1 1 ?a?b \??\?b
    ok 74 - wildmatch 1 1 abc ^G^Hok 75 - wildmatch 0 0 foo
    ok 76 - wildmatch 1 0 foo/bar/baz/to **/t[o]
    ok 77 - wildmatch 1 1 a1B [[:alpha:]][[:digit:]][[:upper:]]
Quoted 3 lines

It seems to prove fine here with perl 5.12.3, Test-Harness-3.230, bash-4.0_p38. What version do you use?

Some problems even here (Mac OS) commit 2aeb6d4d7884f4c4425

not ok 61 - wildmatch 0 0 \ \
not ok 62 - wildmatch 0 0 /\ */\
not ok 69 - wildmatch 1 1 [ab] [[:]ab]
not ok 71 - wildmatch 1 1 [ab] [[:digit]ab]
not ok 80 - wildmatch 1 0 1 [[:digit:][:upper:][:space:]]
not ok 81 - wildmatch 0 0 1 [[:digit:][:upper:][:spaci:]]
not ok 88 - wildmatch 1 0 _ [[:alnum:][:alpha:][:blank:][:cntrl:][:digit:][:graph:][:lower:][:print:][:punct:][:space:][:upper:][:xdigit:]] not ok 89 - wildmatch 1 0 _ [[:alnum:][:alpha:][:blank:][:cntrl:][:digit:][:graph:][:lower:][:print:][:punct:][:space:][:upper:][:xdigit:]] not ok 93 - wildmatch 1 1 y [a-c[:digit:]x-z]

Quoted 1 line

I have 2 perls,...

The problem under discussion was that the output from passing tests were mangled and not interpreted correctly by a program that analyzes them, which happens to be written in Perl. Even in that context, it was pointless to ask for Perl versions, as it was clear that the input to that Perl-written program, i.e. output from the tests, were not formatted correctly to say "ok NN message".

If you are getting "not ok", I do not think you need to look at your Perl. The wildmatch tests are failing, and it is far more likely that the wildmatch code is failing in your environment, than the test harness that runs wildmatch code is failing.

Neither the wildmatch code itself (in C), nor the test harness that is giving you the above "not ok" (in shell) depends on Perl.

Thanks for a report, but the debugging needs to see how the matching code in mildmatch misbehaves.

I suspect it is another case where the platform fnmatch (from MacOS) is not behaving as these tests expect.

Nguyen, how about updating the match () shell function in 3070 so that it not just says not-ok, but indicates what failed (wildmatch failed, or wildmatch passed but fnmatch failed), at least when the test is run as "./t3070-*.sh -v -i"?

#26 lore raw
Quoted 4 lines · Junio C Hamano

Nguyen, how about updating the match () shell function in 3070 so that it not just says not-ok, but indicates what failed (wildmatch failed, or wildmatch passed but fnmatch failed), at least when the test is run as "./t3070-*.sh -v -i"?

You could squash this to the "Integrate wildmatch to git" patch, or just put it at the end of the series (I'll need to send a series update anyway). This splits fnmatch and wildmatch tests separately so we can easily identify which one fails.

-- 8< --

t/t3070-wildmatch.sh +18 -10
index c3ee729..4f97923 100755
@@ -5,20 +5,28 @@ test_description='wildmatch tests'
 . ./test-lib.sh
 
 match() {
-    test_expect_success "wildmatch $*" "
-	if [ $1 = 1 ]; then
+    if [ $1 = 1 ]; then
+	test_expect_success "wildmatch:    match $3 $4" "
 	    test-wildmatch wildmatch '$3' '$4'
-	else
+	"
+    else
+	test_expect_success "wildmatch: no match $3 $4" "
 	    ! test-wildmatch wildmatch '$3' '$4'
-	fi &&
-	if [ $2 = 1 ]; then
+	"
+    fi
+    if [ $2 = 1 ]; then
+	test_expect_success "fnmatch:      match $3 $4" "
 	    test-wildmatch fnmatch '$3' '$4'
-	elif [ $2 = x ]; then
-	    true
-	else
+	"
+    elif [ $2 = 0 ]; then
+	test_expect_success "fnmatch:   no match $3 $4" "
 	    ! test-wildmatch fnmatch '$3' '$4'
-	fi
-    "
+	"
+#    else
+#	test_expect_success BROKEN_FNMATCH "fnmatch:       $3 $4" "
+#	    test-wildmatch fnmatch '$3' '$4'
+#	"
+    fi
 }
 
 # Basic wildmat features

-- 8< --

Signature · 1 line
Duy
#27 lore raw
In reply to Junio C Hamano
Quoted 12 lines · Junio C Hamano
Quoted 11 lines

Some problems even here (Mac OS) commit 2aeb6d4d7884f4c4425

not ok 61 - wildmatch 0 0 \ \
not ok 62 - wildmatch 0 0 /\ */\
not ok 69 - wildmatch 1 1 [ab] [[:]ab]
not ok 71 - wildmatch 1 1 [ab] [[:digit]ab]
not ok 80 - wildmatch 1 0 1 [[:digit:][:upper:][:space:]]
not ok 81 - wildmatch 0 0 1 [[:digit:][:upper:][:spaci:]]
not ok 88 - wildmatch 1 0 _ [[:alnum:][:alpha:][:blank:][:cntrl:][:digit:][:graph:][:lower:][:print:][:punct:][:space:][:upper:][:xdigit:]] not ok 89 - wildmatch 1 0 _ [[:alnum:][:alpha:][:blank:][:cntrl:][:digit:][:graph:][:lower:][:print:][:punct:][:space:][:upper:][:xdigit:]] not ok 93 - wildmatch 1 1 y [a-c[:digit:]x-z]

Quoted 4 lines

Nguyen, how about updating the match () shell function in 3070 so that it not just says not-ok, but indicates what failed (wildmatch failed, or wildmatch passed but fnmatch failed), at least when the test is run as "./t3070-*.sh -v -i"?

It seams to be the fnmatch, since removing the
fnmatch makes t3070 pass.

However, pullling in compat/fnmatch in the Makefile

ifeq ($(uname_S),Darwin)
+ NO_FNMATCH = YesPlease

================
gives this result:
./t3070-wildmatch.sh 2>&1 | grep "not ok"
not ok 23 - wildmatch 1 1 a]b a[]]b
not ok 25 - wildmatch 1 1 a]b a[]-]b
not ok 43 - wildmatch 1 1 /foo **/foo
not ok 79 - wildmatch 1 1 A [[:digit:][:upper:][:space:]]
not ok 84 - wildmatch 1 1 . [[:digit:][:punct:][:space:]]
not ok 85 - wildmatch 1 1 5 [[:xdigit:]]
not ok 86 - wildmatch 1 1 f [[:xdigit:]]
not ok 87 - wildmatch 1 1 D [[:xdigit:]]
not ok 90 - wildmatch 1 1 . [^[:alnum:][:alpha:][:blank:][:cntrl:][:digit:][:lower:][:space:][:upper:][:xdigit:]] not ok 92 - wildmatch 1 1 b [a-c[:digit:]x-z]
not ok 95 - wildmatch 1 1 ] [\\-^]
not ok 98 - wildmatch 1 1 ] [\]]

(Confused)