]>
Commit | Line | Data |
---|---|---|
74986462 JH |
1 | #ifndef CACHE_TREE_H |
2 | #define CACHE_TREE_H | |
3 | ||
e0a92804 | 4 | #include "cache.h" |
b9d37a54 | 5 | #include "tree.h" |
b65982b6 | 6 | #include "tree-walk.h" |
b9d37a54 | 7 | |
74986462 JH |
8 | struct cache_tree; |
9 | struct cache_tree_sub { | |
10 | struct cache_tree *cache_tree; | |
3cf773e4 | 11 | int count; /* internally used by update_one() */ |
74986462 JH |
12 | int namelen; |
13 | int used; | |
14 | char name[FLEX_ARRAY]; | |
15 | }; | |
16 | ||
17 | struct cache_tree { | |
18 | int entry_count; /* negative means "invalid" */ | |
e0a92804 | 19 | struct object_id oid; |
74986462 JH |
20 | int subtree_nr; |
21 | int subtree_alloc; | |
22 | struct cache_tree_sub **down; | |
23 | }; | |
24 | ||
25 | struct cache_tree *cache_tree(void); | |
bad68ec9 | 26 | void cache_tree_free(struct cache_tree **); |
a5400efe | 27 | void cache_tree_invalidate_path(struct index_state *, const char *); |
7927a55d | 28 | struct cache_tree_sub *cache_tree_sub(struct cache_tree *, const char *); |
74986462 | 29 | |
1dffb8fa | 30 | void cache_tree_write(struct strbuf *, struct cache_tree *root); |
bad68ec9 | 31 | struct cache_tree *cache_tree_read(const char *buffer, unsigned long size); |
74986462 | 32 | |
bad68ec9 | 33 | int cache_tree_fully_valid(struct cache_tree *); |
d0cfc3e8 | 34 | int cache_tree_update(struct index_state *, int); |
996277c5 | 35 | |
d11b8d34 JH |
36 | /* bitmasks to write_cache_as_tree flags */ |
37 | #define WRITE_TREE_MISSING_OK 1 | |
38 | #define WRITE_TREE_IGNORE_CACHE_TREE 2 | |
e859c69b NTND |
39 | #define WRITE_TREE_DRY_RUN 4 |
40 | #define WRITE_TREE_SILENT 8 | |
aecf567c | 41 | #define WRITE_TREE_REPAIR 16 |
d11b8d34 JH |
42 | |
43 | /* error return codes */ | |
45525bd0 JH |
44 | #define WRITE_TREE_UNREADABLE_INDEX (-1) |
45 | #define WRITE_TREE_UNMERGED_INDEX (-2) | |
46 | #define WRITE_TREE_PREFIX_ERROR (-3) | |
47 | ||
fc5cb99f | 48 | int write_index_as_tree(struct object_id *oid, struct index_state *index_state, const char *index_path, int flags, const char *prefix); |
e6c286e8 | 49 | void prime_cache_tree(struct index_state *, struct tree *); |
b9d37a54 | 50 | |
9ab34f9e | 51 | int cache_tree_matches_traversal(struct cache_tree *, struct name_entry *ent, struct traverse_info *info); |
b65982b6 | 52 | |
07096c96 NTND |
53 | #ifndef NO_THE_INDEX_COMPATIBILITY_MACROS |
54 | static inline int write_cache_as_tree(struct object_id *oid, int flags, const char *prefix) | |
55 | { | |
56 | return write_index_as_tree(oid, &the_index, get_index_file(), flags, prefix); | |
57 | } | |
58 | ||
59 | static inline int update_main_cache_tree(int flags) | |
60 | { | |
61 | if (!the_index.cache_tree) | |
62 | the_index.cache_tree = cache_tree(); | |
63 | return cache_tree_update(&the_index, flags); | |
64 | } | |
65 | #endif | |
66 | ||
74986462 | 67 | #endif |