]> git.ipfire.org Git - thirdparty/git.git/blob - cache-tree.h
Merge branch 'jt/fetch-pack-record-refs-in-the-dot-promisor'
[thirdparty/git.git] / cache-tree.h
1 #ifndef CACHE_TREE_H
2 #define CACHE_TREE_H
3
4 #include "cache.h"
5 #include "tree.h"
6 #include "tree-walk.h"
7
8 struct cache_tree;
9 struct cache_tree_sub {
10 struct cache_tree *cache_tree;
11 int count; /* internally used by update_one() */
12 int namelen;
13 int used;
14 char name[FLEX_ARRAY];
15 };
16
17 struct cache_tree {
18 int entry_count; /* negative means "invalid" */
19 struct object_id oid;
20 int subtree_nr;
21 int subtree_alloc;
22 struct cache_tree_sub **down;
23 };
24
25 struct cache_tree *cache_tree(void);
26 void cache_tree_free(struct cache_tree **);
27 void cache_tree_invalidate_path(struct index_state *, const char *);
28 struct cache_tree_sub *cache_tree_sub(struct cache_tree *, const char *);
29
30 void cache_tree_write(struct strbuf *, struct cache_tree *root);
31 struct cache_tree *cache_tree_read(const char *buffer, unsigned long size);
32
33 int cache_tree_fully_valid(struct cache_tree *);
34 int cache_tree_update(struct index_state *, int);
35 void cache_tree_verify(struct repository *, struct index_state *);
36
37 /* bitmasks to write_index_as_tree flags */
38 #define WRITE_TREE_MISSING_OK 1
39 #define WRITE_TREE_IGNORE_CACHE_TREE 2
40 #define WRITE_TREE_DRY_RUN 4
41 #define WRITE_TREE_SILENT 8
42 #define WRITE_TREE_REPAIR 16
43
44 /* error return codes */
45 #define WRITE_TREE_UNREADABLE_INDEX (-1)
46 #define WRITE_TREE_UNMERGED_INDEX (-2)
47 #define WRITE_TREE_PREFIX_ERROR (-3)
48
49 struct tree* write_in_core_index_as_tree(struct repository *repo);
50 int write_index_as_tree(struct object_id *oid, struct index_state *index_state, const char *index_path, int flags, const char *prefix);
51 void prime_cache_tree(struct repository *, struct index_state *, struct tree *);
52
53 int cache_tree_matches_traversal(struct cache_tree *, struct name_entry *ent, struct traverse_info *info);
54
55 #ifdef USE_THE_INDEX_COMPATIBILITY_MACROS
56 static inline int write_cache_as_tree(struct object_id *oid, int flags, const char *prefix)
57 {
58 return write_index_as_tree(oid, &the_index, get_index_file(), flags, prefix);
59 }
60
61 static inline int update_main_cache_tree(int flags)
62 {
63 if (!the_index.cache_tree)
64 the_index.cache_tree = cache_tree();
65 return cache_tree_update(&the_index, flags);
66 }
67 #endif
68
69 #endif