When parse_exclude_pattern detects EXC_FLAG_MUSTBEDIR, it sets patternlen _not_ to include the trailing slash and expects the caller to trim it. Of the two callers, add_exclude() does, parse_attr_line() does not. Because of that, after parse_attr_line() returns, we may have pattern "foo/" but its length is reported 3. Some functions do not care about patternlen and will see the pattern as "foo/" while others may see it as "foo". This patch makes patternlen reflect the true length of pattern. This is a bandage patch that's required for the next patch to pass the test suite as that patch will rely on patternlen's correctness. The true fix comes in the patch after the next one. Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@xxxxxxxxx> --- attr.c | 2 ++ dir.h | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/attr.c b/attr.c index e2f9377..1818ba5 100644 --- a/attr.c +++ b/attr.c @@ -255,6 +255,8 @@ static struct match_attr *parse_attr_line(const char *line, const char *src, &res->u.pat.patternlen, &res->u.pat.flags, &res->u.pat.nowildcardlen); + if (res->u.pat.flags & EXC_FLAG_MUSTBEDIR) + res->u.pat.patternlen++; if (res->u.pat.flags & EXC_FLAG_NEGATIVE) { warning(_("Negative patterns are ignored in git attributes\n" "Use '\\!' for literal leading exclamation.")); diff --git a/dir.h b/dir.h index c3eb4b5..dc63fc8 100644 --- a/dir.h +++ b/dir.h @@ -40,7 +40,7 @@ struct exclude_list { struct exclude_list *el; const char *pattern; - int patternlen; + int patternlen; /* must equal strlen(pattern) */ int nowildcardlen; const char *base; int baselen; -- 1.8.2.82.gc24b958 -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html