diff options
author | Russell Belfer <rb@github.com> | 2014-05-01 12:46:46 -0700 |
---|---|---|
committer | Russell Belfer <rb@github.com> | 2014-05-01 12:46:46 -0700 |
commit | d19b2f9f9f2480130bd901246aa3e3843810e5fd (patch) | |
tree | aa30337bf0d79d6418b8e59edcffe23576382bfa | |
parent | 9d878fc420037a78f6ab36b86a42641cbd9425e0 (diff) | |
download | libgit2-d19b2f9f9f2480130bd901246aa3e3843810e5fd.tar.gz |
Make ** pattern eat trailing slashrb/fix-starstar-again
This allows "foo/**/*.html" to match "foo/file.html"
-rw-r--r-- | src/fnmatch.c | 2 | ||||
-rw-r--r-- | tests/attr/ignore.c | 18 |
2 files changed, 20 insertions, 0 deletions
diff --git a/src/fnmatch.c b/src/fnmatch.c index 3846bab3c..d8a83a8ed 100644 --- a/src/fnmatch.c +++ b/src/fnmatch.c @@ -62,6 +62,8 @@ p_fnmatchx(const char *pattern, const char *string, int flags, size_t recurs) flags &= ~FNM_PATHNAME; while (c == '*') c = *++pattern; + if (c == '/') + c = *++pattern; } if (*string == '.' && (flags & FNM_PERIOD) && diff --git a/tests/attr/ignore.c b/tests/attr/ignore.c index 68875194d..5eadc7b3e 100644 --- a/tests/attr/ignore.c +++ b/tests/attr/ignore.c @@ -81,6 +81,24 @@ void test_attr_ignore__full_paths(void) assert_is_ignored(false, "Folder/Middle/More/More/Contained/Not/Happy/Child"); } +void test_attr_ignore__more_starstar_cases(void) +{ + cl_must_pass(p_unlink("attr/.gitignore")); + cl_git_mkfile( + "attr/dir/.gitignore", + "sub/**/*.html\n"); + + assert_is_ignored(false, "aaa.html"); + assert_is_ignored(false, "dir"); + assert_is_ignored(false, "dir/sub"); + assert_is_ignored(true, "dir/sub/sub2/aaa.html"); + assert_is_ignored(true, "dir/sub/aaa.html"); + assert_is_ignored(false, "dir/aaa.html"); + assert_is_ignored(false, "sub"); + assert_is_ignored(false, "sub/aaa.html"); + assert_is_ignored(false, "sub/sub2/aaa.html"); +} + void test_attr_ignore__leading_stars(void) { cl_git_rewritefile( |