Unverified Commit e07dbc92 by Edward Thomson Committed by GitHub

Merge pull request #5173 from pks-t/pks/gitignore-wildmatch-error

ignore: fix determining whether a shorter pattern negates another
parents fd7a384b 6f6340af
...@@ -141,13 +141,8 @@ static int does_negate_rule(int *out, git_vector *rules, git_attr_fnmatch *match ...@@ -141,13 +141,8 @@ static int does_negate_rule(int *out, git_vector *rules, git_attr_fnmatch *match
if (git_buf_oom(&buf)) if (git_buf_oom(&buf))
goto out; goto out;
if ((error = wildmatch(git_buf_cstr(&buf), path, wildmatch_flags)) < 0) {
git_error_set(GIT_ERROR_INVALID, "error matching pattern");
goto out;
}
/* if we found a match, we want to keep this rule */ /* if we found a match, we want to keep this rule */
if (error != WM_NOMATCH) { if ((wildmatch(git_buf_cstr(&buf), path, wildmatch_flags)) == WM_MATCH) {
*out = 1; *out = 1;
error = 0; error = 0;
goto out; goto out;
......
...@@ -560,3 +560,18 @@ void test_ignore_path__escaped_space(void) ...@@ -560,3 +560,18 @@ void test_ignore_path__escaped_space(void)
assert_is_ignored(false, "bar\\\\\\"); assert_is_ignored(false, "bar\\\\\\");
assert_is_ignored(false, "bar\\\\\\ "); assert_is_ignored(false, "bar\\\\\\ ");
} }
void test_ignore_path__invalid_pattern(void)
{
cl_git_rewritefile("attr/.gitignore", "[");
assert_is_ignored(false, "[f");
assert_is_ignored(false, "f");
}
void test_ignore_path__negative_prefix_rule(void)
{
cl_git_rewritefile("attr/.gitignore", "ff*\n!f\n");
assert_is_ignored(true, "fff");
assert_is_ignored(true, "ff");
assert_is_ignored(false, "f");
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment