summaryrefslogtreecommitdiff
path: root/unpack-trees.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2021-12-15 17:39:50 (GMT)
committerJunio C Hamano <gitster@pobox.com>2021-12-15 17:39:50 (GMT)
commite1d928826764c02ad145e93d104ee1209b80b405 (patch)
tree20eefd341bcc438e61ba92c14fe10b1996acd7c6 /unpack-trees.c
parent79aee56c1ee342953a6d9f49f45b89d7f44a624f (diff)
parent8c5de0d2657237412030407abffd033186384b96 (diff)
downloadgit-e1d928826764c02ad145e93d104ee1209b80b405.zip
git-e1d928826764c02ad145e93d104ee1209b80b405.tar.gz
git-e1d928826764c02ad145e93d104ee1209b80b405.tar.bz2
Merge branch 'ds/sparse-deep-pattern-checkout-fix'
The sparse-index/sparse-checkout feature had a bug in its use of the matching code to determine which path is in or outside the sparse checkout patterns. * ds/sparse-deep-pattern-checkout-fix: unpack-trees: use traverse_path instead of name t1092: add deeper changes during a checkout
Diffstat (limited to 'unpack-trees.c')
-rw-r--r--unpack-trees.c14
1 files changed, 8 insertions, 6 deletions
diff --git a/unpack-trees.c b/unpack-trees.c
index b71fdab..98e2f2e 100644
--- a/unpack-trees.c
+++ b/unpack-trees.c
@@ -1238,7 +1238,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.
@@ -1250,11 +1252,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);
}