From d22fd81cf78888738b37eb593612cf082bb50138 Mon Sep 17 00:00:00 2001 From: Patrick Steinhardt Date: Tue, 5 Jun 2018 16:46:07 +0200 Subject: 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. --- src/ignore.c | 17 +++-------------- 1 file 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 '/' 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) { -- cgit v1.2.1