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