summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPatrick Steinhardt <ps@pks.im>2018-06-05 16:46:07 +0200
committerEdward Thomson <ethomson@edwardthomson.com>2019-01-25 17:43:17 +0000
commit2236b3dda0a39b7c914c02291d5c796e989bd994 (patch)
tree9fc057232f1e1449cf2aea6007b7587d42797d6e
parent5fff24ea1758b389c33029b367f16daa0c482a2e (diff)
downloadlibgit2-2236b3dda0a39b7c914c02291d5c796e989bd994.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) {