| 1 | #define USE_THE_REPOSITORY_VARIABLE |
| 2 | |
| 3 | #include "test-tool.h" |
| 4 | #include "lockfile.h" |
| 5 | #include "read-cache-ll.h" |
| 6 | #include "repository.h" |
| 7 | #include "setup.h" |
| 8 | #include "tree.h" |
| 9 | #include "cache-tree.h" |
| 10 | |
| 11 | int cmd__scrap_cache_tree(int ac UNUSED, const char **av UNUSED) |
| 12 | { |
| 13 | struct lock_file index_lock = LOCK_INIT; |
| 14 | |
| 15 | setup_git_directory(the_repository); |
| 16 | repo_hold_locked_index(the_repository, &index_lock, LOCK_DIE_ON_ERROR); |
| 17 | if (repo_read_index(the_repository) < 0) |
| 18 | die("unable to read index file"); |
| 19 | cache_tree_free(&the_repository->index->cache_tree); |
| 20 | the_repository->index->cache_tree = NULL; |
| 21 | if (write_locked_index(the_repository->index, &index_lock, COMMIT_LOCK)) |
| 22 | die("unable to write index file"); |
| 23 | return 0; |
| 24 | } |