summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPatrick Steinhardt <ps@pks.im>2018-06-05 16:46:07 +0200
committerPatrick Steinhardt <ps@pks.im>2018-06-06 08:33:17 +0200
commitd22fd81cf78888738b37eb593612cf082bb50138 (patch)
tree11a6acf82c1dfc36a15f0e319b76f0a51416548f
parent20b4c1753ba5b1780ed7cdb079938b6bebf13634 (diff)
downloadlibgit2-d22fd81cf78888738b37eb593612cf082bb50138.tar.gz
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.
-rw-r--r--src/ignore.c17
1 files changed, 3 insertions, 14 deletions
diff --git a/src/ignore.c b/src/ignore.c
index 33db5bc1d..3b68e14a8 100644
--- a/src/ignore.c
+++ b/src/ignore.c
@@ -133,23 +133,12 @@ static int does_negate_rule(int *out, git_vector *rules, git_attr_fnmatch *match
continue;
}
- /*
- * When dealing with a directory, we add '/<star>' so
- * p_fnmatch() honours FNM_PATHNAME. Checking for LEADINGDIR
- * alone isn't enough as that's also set for nagations, so we
- * need to check that NEGATIVE is off.
- */
git_buf_clear(&buf);
- if (rule->containing_dir) {
+ if (rule->containing_dir)
git_buf_puts(&buf, rule->containing_dir);
- }
-
- error = git_buf_puts(&buf, rule->pattern);
+ git_buf_puts(&buf, rule->pattern);
- if ((rule->flags & (GIT_ATTR_FNMATCH_LEADINGDIR | GIT_ATTR_FNMATCH_NEGATIVE)) == GIT_ATTR_FNMATCH_LEADINGDIR)
- error = git_buf_PUTS(&buf, "/*");
-
- if (error < 0)
+ if (git_buf_oom(&buf))
goto out;
if ((error = p_fnmatch(git_buf_cstr(&buf), path, fnflags)) < 0) {