Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@xxxxxxxxx> --- dir.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/dir.c b/dir.c index 7b6a625..880b5e6 100644 --- a/dir.c +++ b/dir.c @@ -764,9 +764,9 @@ int is_excluded_from_list(const char *pathname, */ static struct exclude *last_exclude_matching(struct dir_struct *dir, const char *pathname, + int pathlen, int *dtype_p) { - int pathlen = strlen(pathname); int i, j; struct exclude_list_group *group; struct exclude *exclude; @@ -793,10 +793,12 @@ static struct exclude *last_exclude_matching(struct dir_struct *dir, * scans all exclude lists to determine whether pathname is excluded. * Returns 1 if true, otherwise 0. */ -static int is_excluded(struct dir_struct *dir, const char *pathname, int *dtype_p) +static int is_excluded(struct dir_struct *dir, + const char *pathname, int pathlen, + int *dtype_p) { struct exclude *exclude = - last_exclude_matching(dir, pathname, dtype_p); + last_exclude_matching(dir, pathname, pathlen, dtype_p); if (exclude) return exclude->flags & EXC_FLAG_NEGATIVE ? 0 : 1; return 0; @@ -859,7 +861,8 @@ struct exclude *last_exclude_matching_path(struct path_exclude_check *check, if (ch == '/') { int dt = DT_DIR; exclude = last_exclude_matching(check->dir, - path->buf, &dt); + path->buf, path->len, + &dt); if (exclude) { check->exclude = exclude; return exclude; @@ -871,7 +874,7 @@ struct exclude *last_exclude_matching_path(struct path_exclude_check *check, /* An entry in the index; cannot be a directory with subentries */ strbuf_setlen(path, 0); - return last_exclude_matching(check->dir, name, dtype); + return last_exclude_matching(check->dir, name, namelen, dtype); } /* @@ -1249,7 +1252,7 @@ static enum path_treatment treat_one_path(struct dir_struct *dir, const struct path_simplify *simplify, int dtype, struct dirent *de) { - int exclude = is_excluded(dir, path->buf, &dtype); + int exclude = is_excluded(dir, path->buf, path->len, &dtype); if (exclude && (dir->flags & DIR_COLLECT_IGNORED) && exclude_matches_pathspec(path->buf, path->len, simplify)) dir_add_ignored(dir, path->buf, path->len); -- 1.8.1.2.536.gf441e6d -- 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