Skip to content

Commit d22fd81

Browse files
committed
ignore: remove now-useless check for LEADINGDIR
When checking whether a rule negates another rule, we were checking whether a rule had the `GIT_ATTR_FNMATCH_LEADINGDIR` flag set and, if so, added a "/*" to its end before passing it to `fnmatch`. Our code now sets `GIT_ATTR_FNMATCH_NOLEADINGDIR`, thus the `LEADINGDIR` flag shall never be set. Furthermore, due to the `NOLEADINGDIR` flag, trailing globs do not get consumed by our ignore parser anymore. Clean up code by just dropping this now useless logic.
1 parent 20b4c17 commit d22fd81

File tree

1 file changed

+3
-14
lines changed

1 file changed

+3
-14
lines changed

src/ignore.c

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -133,23 +133,12 @@ static int does_negate_rule(int *out, git_vector *rules, git_attr_fnmatch *match
133133
continue;
134134
}
135135

136-
/*
137-
* When dealing with a directory, we add '/<star>' so
138-
* p_fnmatch() honours FNM_PATHNAME. Checking for LEADINGDIR
139-
* alone isn't enough as that's also set for nagations, so we
140-
* need to check that NEGATIVE is off.
141-
*/
142136
git_buf_clear(&buf);
143-
if (rule->containing_dir) {
137+
if (rule->containing_dir)
144138
git_buf_puts(&buf, rule->containing_dir);
145-
}
146-
147-
error = git_buf_puts(&buf, rule->pattern);
139+
git_buf_puts(&buf, rule->pattern);
148140

149-
if ((rule->flags & (GIT_ATTR_FNMATCH_LEADINGDIR | GIT_ATTR_FNMATCH_NEGATIVE)) == GIT_ATTR_FNMATCH_LEADINGDIR)
150-
error = git_buf_PUTS(&buf, "/*");
151-
152-
if (error < 0)
141+
if (git_buf_oom(&buf))
153142
goto out;
154143

155144
if ((error = p_fnmatch(git_buf_cstr(&buf), path, fnflags)) < 0) {

0 commit comments

Comments
 (0)