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>
This commit is contained in:
parent
e2df6c3972
commit
2782db3eed
@ -4,6 +4,7 @@
|
|||||||
#include "blob.h"
|
#include "blob.h"
|
||||||
#include "commit.h"
|
#include "commit.h"
|
||||||
#include "tree.h"
|
#include "tree.h"
|
||||||
|
#include "sparse-index.h"
|
||||||
|
|
||||||
static void print_cache_entry(struct cache_entry *ce)
|
static void print_cache_entry(struct cache_entry *ce)
|
||||||
{
|
{
|
||||||
@ -35,13 +36,19 @@ int cmd__read_cache(int argc, const char **argv)
|
|||||||
struct repository *r = the_repository;
|
struct repository *r = the_repository;
|
||||||
int i, cnt = 1;
|
int i, cnt = 1;
|
||||||
const char *name = NULL;
|
const char *name = NULL;
|
||||||
int table = 0;
|
int table = 0, expand = 0;
|
||||||
|
|
||||||
|
initialize_the_repository();
|
||||||
|
prepare_repo_settings(r);
|
||||||
|
r->settings.command_requires_full_index = 0;
|
||||||
|
|
||||||
for (++argv, --argc; *argv && starts_with(*argv, "--"); ++argv, --argc) {
|
for (++argv, --argc; *argv && starts_with(*argv, "--"); ++argv, --argc) {
|
||||||
if (skip_prefix(*argv, "--print-and-refresh=", &name))
|
if (skip_prefix(*argv, "--print-and-refresh=", &name))
|
||||||
continue;
|
continue;
|
||||||
if (!strcmp(*argv, "--table"))
|
if (!strcmp(*argv, "--table"))
|
||||||
table = 1;
|
table = 1;
|
||||||
|
else if (!strcmp(*argv, "--expand"))
|
||||||
|
expand = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (argc == 1)
|
if (argc == 1)
|
||||||
@ -51,6 +58,10 @@ int cmd__read_cache(int argc, const char **argv)
|
|||||||
|
|
||||||
for (i = 0; i < cnt; i++) {
|
for (i = 0; i < cnt; i++) {
|
||||||
repo_read_index(r);
|
repo_read_index(r);
|
||||||
|
|
||||||
|
if (expand)
|
||||||
|
ensure_full_index(r->index);
|
||||||
|
|
||||||
if (name) {
|
if (name) {
|
||||||
int pos;
|
int pos;
|
||||||
|
|
||||||
|
@ -130,6 +130,11 @@ test_sparse_match () {
|
|||||||
test_cmp sparse-checkout-err sparse-index-err
|
test_cmp sparse-checkout-err sparse-index-err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
test_expect_success 'expanded in-memory index matches full index' '
|
||||||
|
init_repos &&
|
||||||
|
test_sparse_match test-tool read-cache --expand --table
|
||||||
|
'
|
||||||
|
|
||||||
test_expect_success 'status with options' '
|
test_expect_success 'status with options' '
|
||||||
init_repos &&
|
init_repos &&
|
||||||
test_all_match git status --porcelain=v2 &&
|
test_all_match git status --porcelain=v2 &&
|
||||||
|
Loading…
x
Reference in New Issue
Block a user