diff --git a/t/t1092-sparse-checkout-compatibility.sh b/t/t1092-sparse-checkout-compatibility.sh index 0697aca6f359e4..f67992a7249e6b 100755 --- a/t/t1092-sparse-checkout-compatibility.sh +++ b/t/t1092-sparse-checkout-compatibility.sh @@ -308,7 +308,7 @@ test_expect_success 'add, commit, checkout' ' test_all_match git checkout - ' -test_expect_failure 'deep changes during checkout' ' +test_expect_success 'deep changes during checkout' ' init_repos && test_sparse_match git sparse-checkout set deep/deeper1/deepest && diff --git a/unpack-trees.c b/unpack-trees.c index 7229a4a820de5c..478c83c64766d9 100644 --- a/unpack-trees.c +++ b/unpack-trees.c @@ -1270,11 +1270,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); }