Skip to content

Commit

Permalink
Convert ce_path_match() to use match_pathspec_depth()
Browse files Browse the repository at this point in the history
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
Nguyễn Thái Ngọc Duy authored and Junio C Hamano committed Feb 3, 2011
1 parent eb9cb55 commit 898bbd9
Showing 1 changed file with 1 addition and 23 deletions.
24 changes: 1 addition & 23 deletions read-cache.c
Original file line number Diff line number Diff line change
Expand Up @@ -708,29 +708,7 @@ int ce_same_name(struct cache_entry *a, struct cache_entry *b)

int ce_path_match(const struct cache_entry *ce, const struct pathspec *pathspec)
{
const char *match, *name;
const char **ps = pathspec->raw;
int len;

if (!pathspec->nr)
return 1;

len = ce_namelen(ce);
name = ce->name;
while ((match = *ps++) != NULL) {
int matchlen = strlen(match);
if (matchlen > len)
continue;
if (memcmp(name, match, matchlen))
continue;
if (matchlen && name[matchlen-1] == '/')
return 1;
if (name[matchlen] == '/' || !name[matchlen])
return 1;
if (!matchlen)
return 1;
}
return 0;
return match_pathspec_depth(pathspec, ce->name, ce_namelen(ce), 0, NULL);
}

/*
Expand Down

0 comments on commit 898bbd9

Please sign in to comment.