summaryrefslogtreecommitdiffstats
path: root/t/helper/test-read-cache.c
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-09 13:34:27 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-09 13:34:27 +0000
commit4dbdc42d9e7c3968ff7f690d00680419c9b8cb0f (patch)
tree47c1d492e9c956c1cd2b74dbd3b9d8b0db44dc4e /t/helper/test-read-cache.c
parentInitial commit. (diff)
downloadgit-4dbdc42d9e7c3968ff7f690d00680419c9b8cb0f.tar.xz
git-4dbdc42d9e7c3968ff7f690d00680419c9b8cb0f.zip
Adding upstream version 1:2.43.0.upstream/1%2.43.0
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 't/helper/test-read-cache.c')
-rw-r--r--t/helper/test-read-cache.c42
1 files changed, 42 insertions, 0 deletions
diff --git a/t/helper/test-read-cache.c b/t/helper/test-read-cache.c
new file mode 100644
index 0000000..1acd362
--- /dev/null
+++ b/t/helper/test-read-cache.c
@@ -0,0 +1,42 @@
+#define USE_THE_INDEX_VARIABLE
+#include "test-tool.h"
+#include "config.h"
+#include "read-cache-ll.h"
+#include "repository.h"
+#include "setup.h"
+
+int cmd__read_cache(int argc, const char **argv)
+{
+ int i, cnt = 1;
+ const char *name = NULL;
+
+ initialize_the_repository();
+
+ 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++) {
+ repo_read_index(the_repository);
+ 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_index(&the_index);
+ }
+ return 0;
+}