Junio C Hamano | 7498646 | 2006-04-23 16:52:20 -0700 | [diff] [blame] | 1 | #ifndef CACHE_TREE_H |
| 2 | #define CACHE_TREE_H |
| 3 | |
Junio C Hamano | b9d37a5 | 2009-04-20 03:58:18 -0700 | [diff] [blame] | 4 | #include "tree.h" |
Junio C Hamano | b65982b | 2009-05-20 15:57:22 -0700 | [diff] [blame] | 5 | #include "tree-walk.h" |
Junio C Hamano | b9d37a5 | 2009-04-20 03:58:18 -0700 | [diff] [blame] | 6 | |
Junio C Hamano | 7498646 | 2006-04-23 16:52:20 -0700 | [diff] [blame] | 7 | struct cache_tree; |
| 8 | struct cache_tree_sub { |
| 9 | struct cache_tree *cache_tree; |
Nguyễn Thái Ngọc Duy | 3cf773e | 2012-12-16 11:15:27 +0700 | [diff] [blame] | 10 | int count; /* internally used by update_one() */ |
Junio C Hamano | 7498646 | 2006-04-23 16:52:20 -0700 | [diff] [blame] | 11 | int namelen; |
| 12 | int used; |
| 13 | char name[FLEX_ARRAY]; |
| 14 | }; |
| 15 | |
| 16 | struct cache_tree { |
| 17 | int entry_count; /* negative means "invalid" */ |
brian m. carlson | e0a9280 | 2017-05-01 02:28:56 +0000 | [diff] [blame] | 18 | struct object_id oid; |
Junio C Hamano | 7498646 | 2006-04-23 16:52:20 -0700 | [diff] [blame] | 19 | int subtree_nr; |
| 20 | int subtree_alloc; |
| 21 | struct cache_tree_sub **down; |
| 22 | }; |
| 23 | |
| 24 | struct cache_tree *cache_tree(void); |
Junio C Hamano | bad68ec | 2006-04-24 21:18:58 -0700 | [diff] [blame] | 25 | void cache_tree_free(struct cache_tree **); |
Nguyễn Thái Ngọc Duy | a5400ef | 2014-06-13 19:19:31 +0700 | [diff] [blame] | 26 | void cache_tree_invalidate_path(struct index_state *, const char *); |
Junio C Hamano | 7927a55 | 2006-04-27 01:33:07 -0700 | [diff] [blame] | 27 | struct cache_tree_sub *cache_tree_sub(struct cache_tree *, const char *); |
Junio C Hamano | 7498646 | 2006-04-23 16:52:20 -0700 | [diff] [blame] | 28 | |
Derrick Stolee | c80dd39 | 2021-01-23 19:58:13 +0000 | [diff] [blame] | 29 | int cache_tree_subtree_pos(struct cache_tree *it, const char *path, int pathlen); |
| 30 | |
Pierre Habouzit | 1dffb8f | 2007-09-25 10:22:44 +0200 | [diff] [blame] | 31 | void cache_tree_write(struct strbuf *, struct cache_tree *root); |
Junio C Hamano | bad68ec | 2006-04-24 21:18:58 -0700 | [diff] [blame] | 32 | struct cache_tree *cache_tree_read(const char *buffer, unsigned long size); |
Junio C Hamano | 7498646 | 2006-04-23 16:52:20 -0700 | [diff] [blame] | 33 | |
Junio C Hamano | bad68ec | 2006-04-24 21:18:58 -0700 | [diff] [blame] | 34 | int cache_tree_fully_valid(struct cache_tree *); |
Nguyễn Thái Ngọc Duy | d0cfc3e | 2014-06-13 19:19:32 +0700 | [diff] [blame] | 35 | int cache_tree_update(struct index_state *, int); |
Nguyễn Thái Ngọc Duy | c207e9e | 2018-11-10 06:49:02 +0100 | [diff] [blame] | 36 | void cache_tree_verify(struct repository *, struct index_state *); |
Thomas Rast | 996277c | 2011-12-06 18:43:37 +0100 | [diff] [blame] | 37 | |
Elijah Newren | 724dd76 | 2019-08-17 11:41:32 -0700 | [diff] [blame] | 38 | /* bitmasks to write_index_as_tree flags */ |
Junio C Hamano | d11b8d3 | 2009-05-20 11:04:35 -0700 | [diff] [blame] | 39 | #define WRITE_TREE_MISSING_OK 1 |
| 40 | #define WRITE_TREE_IGNORE_CACHE_TREE 2 |
Nguyễn Thái Ngọc Duy | e859c69 | 2012-01-16 09:36:46 +0700 | [diff] [blame] | 41 | #define WRITE_TREE_DRY_RUN 4 |
| 42 | #define WRITE_TREE_SILENT 8 |
David Turner | aecf567 | 2014-07-05 21:06:56 -0700 | [diff] [blame] | 43 | #define WRITE_TREE_REPAIR 16 |
Junio C Hamano | d11b8d3 | 2009-05-20 11:04:35 -0700 | [diff] [blame] | 44 | |
| 45 | /* error return codes */ |
Junio C Hamano | 45525bd | 2008-01-10 22:49:35 -0800 | [diff] [blame] | 46 | #define WRITE_TREE_UNREADABLE_INDEX (-1) |
| 47 | #define WRITE_TREE_UNMERGED_INDEX (-2) |
| 48 | #define WRITE_TREE_PREFIX_ERROR (-3) |
| 49 | |
Elijah Newren | 724dd76 | 2019-08-17 11:41:32 -0700 | [diff] [blame] | 50 | struct tree* write_in_core_index_as_tree(struct repository *repo); |
brian m. carlson | fc5cb99 | 2018-03-12 02:27:23 +0000 | [diff] [blame] | 51 | int write_index_as_tree(struct object_id *oid, struct index_state *index_state, const char *index_path, int flags, const char *prefix); |
Nguyễn Thái Ngọc Duy | c207e9e | 2018-11-10 06:49:02 +0100 | [diff] [blame] | 52 | void prime_cache_tree(struct repository *, struct index_state *, struct tree *); |
Junio C Hamano | b9d37a5 | 2009-04-20 03:58:18 -0700 | [diff] [blame] | 53 | |
Nguyễn Thái Ngọc Duy | 9ab34f9 | 2018-06-30 11:20:23 +0200 | [diff] [blame] | 54 | int cache_tree_matches_traversal(struct cache_tree *, struct name_entry *ent, struct traverse_info *info); |
Junio C Hamano | 7498646 | 2006-04-23 16:52:20 -0700 | [diff] [blame] | 55 | #endif |