read-cache*.h: move declarations for read-cache.c functions from cache.h
[alt-git.git] / t / helper / test-read-cache.c
blob0d548814e08a7405150afe441d7d88839dfa6648
1 #define USE_THE_INDEX_VARIABLE
2 #include "test-tool.h"
3 #include "cache.h"
4 #include "config.h"
5 #include "read-cache-ll.h"
6 #include "repository.h"
7 #include "setup.h"
8 #include "wrapper.h"
10 int cmd__read_cache(int argc, const char **argv)
12 int i, cnt = 1;
13 const char *name = NULL;
15 initialize_the_repository();
17 if (argc > 1 && skip_prefix(argv[1], "--print-and-refresh=", &name)) {
18 argc--;
19 argv++;
22 if (argc == 2)
23 cnt = strtol(argv[1], NULL, 0);
24 setup_git_directory();
25 git_config(git_default_config, NULL);
27 for (i = 0; i < cnt; i++) {
28 repo_read_index(the_repository);
29 if (name) {
30 int pos;
32 refresh_index(&the_index, REFRESH_QUIET,
33 NULL, NULL, NULL);
34 pos = index_name_pos(&the_index, name, strlen(name));
35 if (pos < 0)
36 die("%s not in index", name);
37 printf("%s is%s up to date\n", name,
38 ce_uptodate(the_index.cache[pos]) ? "" : " not");
39 write_file(name, "%d\n", i);
41 discard_index(&the_index);
43 return 0;