File: test-read-cache.c

package info (click to toggle)
cgit 1.2.3%2Bgit2.25.1-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 44,972 kB
  • sloc: ansic: 236,086; sh: 194,031; perl: 29,806; tcl: 22,076; python: 6,583; makefile: 3,877; sed: 189; php: 120; asm: 98; csh: 45; ruby: 43; lisp: 12
file content (36 lines) | stat: -rw-r--r-- 790 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#include "test-tool.h"
#include "cache.h"
#include "config.h"

int cmd__read_cache(int argc, const char **argv)
{
	int i, cnt = 1;
	const char *name = NULL;

	if (argc > 1 && skip_prefix(argv[1], "--print-and-refresh=", &name)) {
		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);
			pos = index_name_pos(&the_index, name, strlen(name));
			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;
}