summaryrefslogtreecommitdiff
path: root/src/ignore.c
diff options
context:
space:
mode:
authorEdward Thomson <ethomson@edwardthomson.com>2021-07-14 08:39:24 -0400
committerGitHub <noreply@github.com>2021-07-14 08:39:24 -0400
commit84ce9746ae0699d61fc1c57ccec4887d98e1dfc1 (patch)
tree87f1ebeb71bf4436bd69ebee83930752566facc8 /src/ignore.c
parente5649e1075801303cbdf2aabc2c164cebcbd783e (diff)
parent6d2a6f3e06a2d0468c89ed4c2efced58434a8735 (diff)
downloadlibgit2-84ce9746ae0699d61fc1c57ccec4887d98e1dfc1.tar.gz
Merge pull request #5824 from palmin/fix-ignore-negate
fix check for ignoring of negate rules
Diffstat (limited to 'src/ignore.c')
-rw-r--r--src/ignore.c14
1 files changed, 11 insertions, 3 deletions
diff --git a/src/ignore.c b/src/ignore.c
index 700a6729c..948c58d85 100644
--- a/src/ignore.c
+++ b/src/ignore.c
@@ -101,7 +101,7 @@ static int does_negate_pattern(git_attr_fnmatch *rule, git_attr_fnmatch *neg)
*/
static int does_negate_rule(int *out, git_vector *rules, git_attr_fnmatch *match)
{
- int error = 0, wildmatch_flags;
+ int error = 0, wildmatch_flags, effective_flags;
size_t i;
git_attr_fnmatch *rule;
char *path;
@@ -141,8 +141,17 @@ static int does_negate_rule(int *out, git_vector *rules, git_attr_fnmatch *match
if (git_buf_oom(&buf))
goto out;
+ /*
+ * if rule isn't for full path we match without PATHNAME flag
+ * as lines like *.txt should match something like dir/test.txt
+ * requiring * to also match /
+ */
+ effective_flags = wildmatch_flags;
+ if (!(rule->flags & GIT_ATTR_FNMATCH_FULLPATH))
+ effective_flags &= ~WM_PATHNAME;
+
/* if we found a match, we want to keep this rule */
- if ((wildmatch(git_buf_cstr(&buf), path, wildmatch_flags)) == WM_MATCH) {
+ if ((wildmatch(git_buf_cstr(&buf), path, effective_flags)) == WM_MATCH) {
*out = 1;
error = 0;
goto out;
@@ -639,4 +648,3 @@ int git_ignore__check_pathspec_for_exact_ignores(
return error;
}
-