Skip to content

Commit 2782db3

Browse files
derrickstoleegitster
authored andcommitted
test-tool: don't force full index
We will use 'test-tool read-cache --table' to check that a sparse index is written as part of init_repos. Since we will no longer always expand a sparse index into a full index, add an '--expand' parameter that adds a call to ensure_full_index() so we can compare a sparse index directly against a full index, or at least what the in-memory index looks like when expanded in this way. Signed-off-by: Derrick Stolee <dstolee@microsoft.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent e2df6c3 commit 2782db3

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

t/helper/test-read-cache.c

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
#include "blob.h"
55
#include "commit.h"
66
#include "tree.h"
7+
#include "sparse-index.h"
78

89
static void print_cache_entry(struct cache_entry *ce)
910
{
@@ -35,13 +36,19 @@ int cmd__read_cache(int argc, const char **argv)
3536
struct repository *r = the_repository;
3637
int i, cnt = 1;
3738
const char *name = NULL;
38-
int table = 0;
39+
int table = 0, expand = 0;
40+
41+
initialize_the_repository();
42+
prepare_repo_settings(r);
43+
r->settings.command_requires_full_index = 0;
3944

4045
for (++argv, --argc; *argv && starts_with(*argv, "--"); ++argv, --argc) {
4146
if (skip_prefix(*argv, "--print-and-refresh=", &name))
4247
continue;
4348
if (!strcmp(*argv, "--table"))
4449
table = 1;
50+
else if (!strcmp(*argv, "--expand"))
51+
expand = 1;
4552
}
4653

4754
if (argc == 1)
@@ -51,6 +58,10 @@ int cmd__read_cache(int argc, const char **argv)
5158

5259
for (i = 0; i < cnt; i++) {
5360
repo_read_index(r);
61+
62+
if (expand)
63+
ensure_full_index(r->index);
64+
5465
if (name) {
5566
int pos;
5667

t/t1092-sparse-checkout-compatibility.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,11 @@ test_sparse_match () {
130130
test_cmp sparse-checkout-err sparse-index-err
131131
}
132132

133+
test_expect_success 'expanded in-memory index matches full index' '
134+
init_repos &&
135+
test_sparse_match test-tool read-cache --expand --table
136+
'
137+
133138
test_expect_success 'status with options' '
134139
init_repos &&
135140
test_all_match git status --porcelain=v2 &&

0 commit comments

Comments
 (0)