diff options
Diffstat (limited to 'unpack-trees.c')
-rw-r--r-- | unpack-trees.c | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/unpack-trees.c b/unpack-trees.c index 89ca95ce90..d2363b44ec 100644 --- a/unpack-trees.c +++ b/unpack-trees.c @@ -1231,7 +1231,9 @@ static int find_cache_pos(struct traverse_info *info, /* * Given a sparse directory entry 'ce', compare ce->name to - * info->name + '/' + p->path + '/' if info->name is non-empty. + * info->traverse_path + p->path + '/' if info->traverse_path + * is non-empty. + * * Compare ce->name to p->path + '/' otherwise. Note that * ce->name must end in a trailing '/' because it is a sparse * directory entry. @@ -1243,11 +1245,11 @@ static int sparse_dir_matches_path(const struct cache_entry *ce, assert(S_ISSPARSEDIR(ce->ce_mode)); assert(ce->name[ce->ce_namelen - 1] == '/'); - if (info->namelen) - return ce->ce_namelen == info->namelen + p->pathlen + 2 && - ce->name[info->namelen] == '/' && - !strncmp(ce->name, info->name, info->namelen) && - !strncmp(ce->name + info->namelen + 1, p->path, p->pathlen); + if (info->pathlen) + return ce->ce_namelen == info->pathlen + p->pathlen + 1 && + ce->name[info->pathlen - 1] == '/' && + !strncmp(ce->name, info->traverse_path, info->pathlen) && + !strncmp(ce->name + info->pathlen, p->path, p->pathlen); return ce->ce_namelen == p->pathlen + 1 && !strncmp(ce->name, p->path, p->pathlen); } |