summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xt/t1092-sparse-checkout-compatibility.sh2
-rw-r--r--unpack-trees.c14
2 files changed, 9 insertions, 7 deletions
diff --git a/t/t1092-sparse-checkout-compatibility.sh b/t/t1092-sparse-checkout-compatibility.sh
index e6aef40e9b..f04a02c6b2 100755
--- a/t/t1092-sparse-checkout-compatibility.sh
+++ b/t/t1092-sparse-checkout-compatibility.sh
@@ -307,7 +307,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 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);
}