]> git.ipfire.org Git - thirdparty/git.git/blame - t/helper/test-read-cache.c
Merge branch 'am/t0028-utf16-tests'
[thirdparty/git.git] / t / helper / test-read-cache.c
CommitLineData
5fbe600c 1#include "test-tool.h"
1ecb5ff1 2#include "cache.h"
dc76852d 3#include "config.h"
1ecb5ff1 4
5fbe600c 5int cmd__read_cache(int argc, const char **argv)
1ecb5ff1 6{
7e6b96c7 7 int i, cnt = 1;
dc76852d
JS
8 const char *name = NULL;
9
10 if (argc > 1 && skip_prefix(argv[1], "--print-and-refresh=", &name)) {
dc76852d
JS
11 argc--;
12 argv++;
13 }
14
1ecb5ff1
RS
15 if (argc == 2)
16 cnt = strtol(argv[1], NULL, 0);
bccb22cb 17 setup_git_directory();
dc76852d 18 git_config(git_default_config, NULL);
1ecb5ff1
RS
19 for (i = 0; i < cnt; i++) {
20 read_cache();
dc76852d
JS
21 if (name) {
22 int pos;
23
24 refresh_index(&the_index, REFRESH_QUIET,
25 NULL, NULL, NULL);
7e6b96c7 26 pos = index_name_pos(&the_index, name, strlen(name));
dc76852d
JS
27 if (pos < 0)
28 die("%s not in index", name);
29 printf("%s is%s up to date\n", name,
30 ce_uptodate(the_index.cache[pos]) ? "" : " not");
31 write_file(name, "%d\n", i);
32 }
1ecb5ff1
RS
33 discard_cache();
34 }
35 return 0;
36}