]> git.ipfire.org Git - thirdparty/git.git/blob - t/helper/test-read-cache.c
Merge branch 'es/add-doc-list-short-form-of-all-in-synopsis'
[thirdparty/git.git] / t / helper / test-read-cache.c
1 #define USE_THE_INDEX_VARIABLE
2 #include "test-tool.h"
3 #include "config.h"
4 #include "read-cache-ll.h"
5 #include "repository.h"
6 #include "setup.h"
7
8 int cmd__read_cache(int argc, const char **argv)
9 {
10 int i, cnt = 1;
11 const char *name = NULL;
12
13 initialize_the_repository();
14
15 if (argc > 1 && skip_prefix(argv[1], "--print-and-refresh=", &name)) {
16 argc--;
17 argv++;
18 }
19
20 if (argc == 2)
21 cnt = strtol(argv[1], NULL, 0);
22 setup_git_directory();
23 git_config(git_default_config, NULL);
24
25 for (i = 0; i < cnt; i++) {
26 repo_read_index(the_repository);
27 if (name) {
28 int pos;
29
30 refresh_index(&the_index, REFRESH_QUIET,
31 NULL, NULL, NULL);
32 pos = index_name_pos(&the_index, name, strlen(name));
33 if (pos < 0)
34 die("%s not in index", name);
35 printf("%s is%s up to date\n", name,
36 ce_uptodate(the_index.cache[pos]) ? "" : " not");
37 write_file(name, "%d\n", i);
38 }
39 discard_index(&the_index);
40 }
41 return 0;
42 }