2020-01-12 00:36:56 +01:00
|
|
|
#include "test-tool.h"
|
|
|
|
#include "cache.h"
|
|
|
|
#include "config.h"
|
|
|
|
|
|
|
|
int cmd__read_cache(int argc, const char **argv)
|
|
|
|
{
|
2020-05-26 01:06:52 +02:00
|
|
|
int i, cnt = 1, namelen;
|
2020-01-12 00:36:56 +01:00
|
|
|
const char *name = NULL;
|
|
|
|
|
|
|
|
if (argc > 1 && skip_prefix(argv[1], "--print-and-refresh=", &name)) {
|
2020-05-26 01:06:52 +02:00
|
|
|
namelen = strlen(name);
|
2020-01-12 00:36:56 +01:00
|
|
|
argc--;
|
|
|
|
argv++;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (argc == 2)
|
|
|
|
cnt = strtol(argv[1], NULL, 0);
|
|
|
|
setup_git_directory();
|
|
|
|
git_config(git_default_config, NULL);
|
|
|
|
for (i = 0; i < cnt; i++) {
|
|
|
|
read_cache();
|
|
|
|
if (name) {
|
|
|
|
int pos;
|
|
|
|
|
|
|
|
refresh_index(&the_index, REFRESH_QUIET,
|
|
|
|
NULL, NULL, NULL);
|
2020-05-26 01:06:52 +02:00
|
|
|
pos = index_name_pos(&the_index, name, namelen);
|
2020-01-12 00:36:56 +01:00
|
|
|
if (pos < 0)
|
|
|
|
die("%s not in index", name);
|
|
|
|
printf("%s is%s up to date\n", name,
|
|
|
|
ce_uptodate(the_index.cache[pos]) ? "" : " not");
|
|
|
|
write_file(name, "%d\n", i);
|
|
|
|
}
|
|
|
|
discard_cache();
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|