7 #include "sparse-index.h"
9 static void print_cache_entry(struct cache_entry
*ce
)
12 printf("%06o ", ce
->ce_mode
& 0177777);
14 if (S_ISSPARSEDIR(ce
->ce_mode
))
16 else if (S_ISGITLINK(ce
->ce_mode
))
27 static void print_cache(struct index_state
*istate
)
30 for (i
= 0; i
< istate
->cache_nr
; i
++)
31 print_cache_entry(istate
->cache
[i
]);
34 int cmd__read_cache(int argc
, const char **argv
)
36 struct repository
*r
= the_repository
;
38 const char *name
= NULL
;
39 int table
= 0, expand
= 0;
41 initialize_the_repository();
42 prepare_repo_settings(r
);
43 r
->settings
.command_requires_full_index
= 0;
45 for (++argv
, --argc
; *argv
&& starts_with(*argv
, "--"); ++argv
, --argc
) {
46 if (skip_prefix(*argv
, "--print-and-refresh=", &name
))
48 if (!strcmp(*argv
, "--table"))
50 else if (!strcmp(*argv
, "--expand"))
55 cnt
= strtol(argv
[0], NULL
, 0);
56 setup_git_directory();
57 git_config(git_default_config
, NULL
);
59 for (i
= 0; i
< cnt
; i
++) {
63 ensure_full_index(r
->index
);
68 refresh_index(r
->index
, REFRESH_QUIET
,
70 pos
= index_name_pos(r
->index
, name
, strlen(name
));
72 die("%s not in index", name
);
73 printf("%s is%s up to date\n", name
,
74 ce_uptodate(r
->index
->cache
[pos
]) ? "" : " not");
75 write_file(name
, "%d\n", i
);
78 print_cache(r
->index
);
79 discard_index(r
->index
);