7 #include "sparse-index.h"
8 #include "parse-options.h"
10 static const char *read_cache_usage[] = {
11 "test-tool read-cache [<options>...]",
15 static void print_cache_entry(struct cache_entry *ce)
18 printf("%06o ", ce->ce_mode & 0177777);
20 if (S_ISSPARSEDIR(ce->ce_mode))
22 else if (S_ISGITLINK(ce->ce_mode))
33 static void print_cache(struct index_state *istate)
36 for (i = 0; i < istate->cache_nr; i++)
37 print_cache_entry(istate->cache[i]);
40 int cmd__read_cache(int argc, const char **argv)
42 struct repository *r = the_repository;
43 int table = 0, expand = 0;
44 struct option options[] = {
45 OPT_BOOL(0, "table", &table,
46 "print a dump of the cache"),
47 OPT_BOOL(0, "expand", &expand,
48 "call ensure_full_index()"),
52 argc = parse_options(argc, argv, "test-tools", options, read_cache_usage, 0);
54 usage_msg_opt("Too many arguments.", read_cache_usage, options);
56 initialize_the_repository();
57 prepare_repo_settings(r);
58 r->settings.command_requires_full_index = 0;
60 setup_git_directory();
61 git_config(git_default_config, NULL);
65 ensure_full_index(r->index);
68 print_cache(r->index);
69 discard_index(r->index);