]> git.ipfire.org Git - thirdparty/git.git/blob - t/helper/test-scrap-cache-tree.c
Sync with Git 2.45.1
[thirdparty/git.git] / t / helper / test-scrap-cache-tree.c
1 #include "test-tool.h"
2 #include "lockfile.h"
3 #include "read-cache-ll.h"
4 #include "repository.h"
5 #include "setup.h"
6 #include "tree.h"
7 #include "cache-tree.h"
8
9 int cmd__scrap_cache_tree(int ac UNUSED, const char **av UNUSED)
10 {
11 struct lock_file index_lock = LOCK_INIT;
12
13 setup_git_directory();
14 repo_hold_locked_index(the_repository, &index_lock, LOCK_DIE_ON_ERROR);
15 if (repo_read_index(the_repository) < 0)
16 die("unable to read index file");
17 cache_tree_free(&the_repository->index->cache_tree);
18 the_repository->index->cache_tree = NULL;
19 if (write_locked_index(the_repository->index, &index_lock, COMMIT_LOCK))
20 die("unable to write index file");
21 return 0;
22 }