]> git.ipfire.org Git - thirdparty/git.git/blame - t/helper/test-read-cache.c
Merge branch 'js/rebase-reschedule-applies-only-to-interactive' into maint
[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{
dc76852d
JS
7 int i, cnt = 1, namelen;
8 const char *name = NULL;
9
10 if (argc > 1 && skip_prefix(argv[1], "--print-and-refresh=", &name)) {
11 namelen = strlen(name);
12 argc--;
13 argv++;
14 }
15
1ecb5ff1
RS
16 if (argc == 2)
17 cnt = strtol(argv[1], NULL, 0);
bccb22cb 18 setup_git_directory();
dc76852d 19 git_config(git_default_config, NULL);
1ecb5ff1
RS
20 for (i = 0; i < cnt; i++) {
21 read_cache();
dc76852d
JS
22 if (name) {
23 int pos;
24
25 refresh_index(&the_index, REFRESH_QUIET,
26 NULL, NULL, NULL);
27 pos = index_name_pos(&the_index, name, namelen);
28 if (pos < 0)
29 die("%s not in index", name);
30 printf("%s is%s up to date\n", name,
31 ce_uptodate(the_index.cache[pos]) ? "" : " not");
32 write_file(name, "%d\n", i);
33 }
1ecb5ff1
RS
34 discard_cache();
35 }
36 return 0;
37}