From: Junio C Hamano Date: Mon, 13 Dec 2010 18:09:55 GMT Subject: Re: [PATCH 08/19] pathspec: mark wildcard pathspecs from the beginning Message-ID: <7vr5dl35os.fsf@alter.siamese.dyndns.org> In-Reply-To: <1292233616-27692-9-git-send-email-pclouds@gmail.com> Nguyễn Thái Ngọc Duy writes: > Signed-off-by: Nguyễn Thái Ngọc Duy > diff --git a/dir.c b/dir.c > index 646c79f..0987d0c 100644 > --- a/dir.c > +++ b/dir.c > @@ -1089,8 +1089,17 @@ int init_pathspec(struct pathspec *pathspec, const char **paths) > pathspec->items = xmalloc(sizeof(struct pathspec_item)*pathspec->nr); > for (i = 0; i < pathspec->nr; i++) { > struct pathspec_item *item = pathspec->items+i; > - > - item->len = strlen(paths[i]); > + const char *path = paths[i]; > + > + item->len = strlen(path); > + item->has_wildcard = !no_wildcard(path); > + if (item->has_wildcard) { > + pathspec->has_wildcard = 1; > + item->prefix_len = 0; > + while (item->prefix_len < item->len && > + strchr("*?[{\\", path[item->prefix_len]) == NULL) > + item->prefix_len++; > + } Would it make sense to use strcspn(3) here? > } > return 0; > } > -- > 1.7.3.3.476.g10a82