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 <dstolee@microsoft.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Derrick Stolee committed
Mar 30, 2021 at 13:11 UTC
9ad2d5ea71d1470c2fd68b76c36b2ced3612cde3
2 files changed
+19
-3
cache-tree.c
+19
@@ -808,6 +808,19 @@ int cache_tree_matches_traversal(struct cache_tree *root,
808
return 0;
809
}
810
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
+
824
static void verify_one(struct repository *r,
825
struct index_state *istate,
826
struct cache_tree *it,
@@ -830,6 +843,12 @@ static void verify_one(struct repository *r,
843
844
if (path->len) {
845
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
+
852
pos = -pos - 1;
853
} else {
854
pos = 0;
t/t1092-sparse-checkout-compatibility.sh
-3
@@ -2,9 +2,6 @@
2
3
test_description='compare full workdir to sparse workdir'
4
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
5
GIT_TEST_SPLIT_INDEX=0
6
GIT_TEST_SPARSE_INDEX=
7