Skip to content

Commit 9ad2d5e

Browse files
derrickstoleegitster
authored andcommitted
sparse-index: loose integration with cache_tree_verify()
The cache_tree_verify() method is run when GIT_TEST_CHECK_CACHE_TREE is enabled, which it is by default in the test suite. The logic must be adjusted for the presence of these directory entries. For now, leave the test as a simple check for whether the directory entry is sparse. Do not go any further until needed. This allows us to re-enable GIT_TEST_CHECK_CACHE_TREE in t1092-sparse-checkout-compatibility.sh. Further, p2000-sparse-operations.sh uses the test suite and hence this is enabled for all tests. We need to integrate with it before we run our performance tests with a sparse-index. Signed-off-by: Derrick Stolee <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 2de37c5 commit 9ad2d5e

File tree

2 files changed

+19
-3
lines changed

2 files changed

+19
-3
lines changed

cache-tree.c

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -808,6 +808,19 @@ int cache_tree_matches_traversal(struct cache_tree *root,
808808
return 0;
809809
}
810810

811+
static void verify_one_sparse(struct repository *r,
812+
struct index_state *istate,
813+
struct cache_tree *it,
814+
struct strbuf *path,
815+
int pos)
816+
{
817+
struct cache_entry *ce = istate->cache[pos];
818+
819+
if (!S_ISSPARSEDIR(ce->ce_mode))
820+
BUG("directory '%s' is present in index, but not sparse",
821+
path->buf);
822+
}
823+
811824
static void verify_one(struct repository *r,
812825
struct index_state *istate,
813826
struct cache_tree *it,
@@ -830,6 +843,12 @@ static void verify_one(struct repository *r,
830843

831844
if (path->len) {
832845
pos = index_name_pos(istate, path->buf, path->len);
846+
847+
if (pos >= 0) {
848+
verify_one_sparse(r, istate, it, path, pos);
849+
return;
850+
}
851+
833852
pos = -pos - 1;
834853
} else {
835854
pos = 0;

t/t1092-sparse-checkout-compatibility.sh

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,6 @@
22

33
test_description='compare full workdir to sparse workdir'
44

5-
# The verify_cache_tree() check is not sparse-aware (yet).
6-
# So, disable the check until that integration is complete.
7-
GIT_TEST_CHECK_CACHE_TREE=0
85
GIT_TEST_SPLIT_INDEX=0
96
GIT_TEST_SPARSE_INDEX=
107

0 commit comments

Comments
 (0)