Skip to content

Commit 408c51f

Browse files
derrickstoleegitster
authored andcommitted
test-read-cache: remove --table, --expand options
This commit effectively reverts 2782db3 (test-tool: don't force full index, 2021-03-30) and e2df6c3 (test-read-cache: print cache entries with --table, 2021-03-30) to remove the --table and --expand options from 'test-tool read-cache'. The previous changes already removed these options from the test suite in favor of 'git ls-files --sparse'. The initial thought of creating these options was to allow for tests to see additional information with every cache entry. In particular, the object type is still not mirrored in 'git ls-files'. Since sparse directory entries always end with a slash, the object type is not critical to verify the sparse index is enabled. It was thought that it would be helpful to have additional information, such as flags, but that was not needed for the FS Monitor integration and hasn't been needed since. Signed-off-by: Derrick Stolee <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent c2a2940 commit 408c51f

File tree

1 file changed

+10
-54
lines changed

1 file changed

+10
-54
lines changed

t/helper/test-read-cache.c

Lines changed: 10 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -1,83 +1,39 @@
11
#include "test-tool.h"
22
#include "cache.h"
33
#include "config.h"
4-
#include "blob.h"
5-
#include "commit.h"
6-
#include "tree.h"
7-
#include "sparse-index.h"
8-
9-
static void print_cache_entry(struct cache_entry *ce)
10-
{
11-
const char *type;
12-
printf("%06o ", ce->ce_mode & 0177777);
13-
14-
if (S_ISSPARSEDIR(ce->ce_mode))
15-
type = tree_type;
16-
else if (S_ISGITLINK(ce->ce_mode))
17-
type = commit_type;
18-
else
19-
type = blob_type;
20-
21-
printf("%s %s\t%s\n",
22-
type,
23-
oid_to_hex(&ce->oid),
24-
ce->name);
25-
}
26-
27-
static void print_cache(struct index_state *istate)
28-
{
29-
int i;
30-
for (i = 0; i < istate->cache_nr; i++)
31-
print_cache_entry(istate->cache[i]);
32-
}
334

345
int cmd__read_cache(int argc, const char **argv)
356
{
36-
struct repository *r = the_repository;
377
int i, cnt = 1;
388
const char *name = NULL;
39-
int table = 0, expand = 0;
409

4110
initialize_the_repository();
4211

43-
for (++argv, --argc; *argv && starts_with(*argv, "--"); ++argv, --argc) {
44-
if (skip_prefix(*argv, "--print-and-refresh=", &name))
45-
continue;
46-
if (!strcmp(*argv, "--table"))
47-
table = 1;
48-
else if (!strcmp(*argv, "--expand"))
49-
expand = 1;
12+
if (argc > 1 && skip_prefix(argv[1], "--print-and-refresh=", &name)) {
13+
argc--;
14+
argv++;
5015
}
5116

52-
if (argc == 1)
53-
cnt = strtol(argv[0], NULL, 0);
17+
if (argc == 2)
18+
cnt = strtol(argv[1], NULL, 0);
5419
setup_git_directory();
5520
git_config(git_default_config, NULL);
5621

57-
prepare_repo_settings(r);
58-
r->settings.command_requires_full_index = 0;
59-
6022
for (i = 0; i < cnt; i++) {
61-
repo_read_index(r);
62-
63-
if (expand)
64-
ensure_full_index(r->index);
65-
23+
read_cache();
6624
if (name) {
6725
int pos;
6826

69-
refresh_index(r->index, REFRESH_QUIET,
27+
refresh_index(&the_index, REFRESH_QUIET,
7028
NULL, NULL, NULL);
71-
pos = index_name_pos(r->index, name, strlen(name));
29+
pos = index_name_pos(&the_index, name, strlen(name));
7230
if (pos < 0)
7331
die("%s not in index", name);
7432
printf("%s is%s up to date\n", name,
75-
ce_uptodate(r->index->cache[pos]) ? "" : " not");
33+
ce_uptodate(the_index.cache[pos]) ? "" : " not");
7634
write_file(name, "%d\n", i);
7735
}
78-
if (table)
79-
print_cache(r->index);
80-
discard_index(r->index);
36+
discard_cache();
8137
}
8238
return 0;
8339
}

0 commit comments

Comments
 (0)