9 struct cache_tree_sub
{
10 struct cache_tree
*cache_tree
;
11 int count
; /* internally used by update_one() */
14 char name
[FLEX_ARRAY
];
18 int entry_count
; /* negative means "invalid" */
22 struct cache_tree_sub
**down
;
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 *);
30 int cache_tree_subtree_pos(struct cache_tree
*it
, const char *path
, int pathlen
);
32 struct cache_tree
*cache_tree_find_path(struct cache_tree
*it
, const char *path
);
34 void cache_tree_write(struct strbuf
*, struct cache_tree
*root
);
35 struct cache_tree
*cache_tree_read(const char *buffer
, unsigned long size
);
37 int cache_tree_fully_valid(struct cache_tree
*);
38 int cache_tree_update(struct index_state
*, int);
39 void cache_tree_verify(struct repository
*, struct index_state
*);
41 /* bitmasks to write_index_as_tree flags */
42 #define WRITE_TREE_MISSING_OK 1
43 #define WRITE_TREE_IGNORE_CACHE_TREE 2
44 #define WRITE_TREE_DRY_RUN 4
45 #define WRITE_TREE_SILENT 8
46 #define WRITE_TREE_REPAIR 16
48 /* error return codes */
49 #define WRITE_TREE_UNREADABLE_INDEX (-1)
50 #define WRITE_TREE_UNMERGED_INDEX (-2)
51 #define WRITE_TREE_PREFIX_ERROR (-3)
53 struct tree
* write_in_core_index_as_tree(struct repository
*repo
);
54 int write_index_as_tree(struct object_id
*oid
, struct index_state
*index_state
, const char *index_path
, int flags
, const char *prefix
);
55 void prime_cache_tree(struct repository
*, struct index_state
*, struct tree
*);
57 int cache_tree_matches_traversal(struct cache_tree
*, struct name_entry
*ent
, struct traverse_info
*info
);
59 #ifdef USE_THE_INDEX_COMPATIBILITY_MACROS
60 static inline int write_cache_as_tree(struct object_id
*oid
, int flags
, const char *prefix
)
62 return write_index_as_tree(oid
, &the_index
, get_index_file(), flags
, prefix
);
65 static inline int update_main_cache_tree(int flags
)
67 if (!the_index
.cache_tree
)
68 the_index
.cache_tree
= cache_tree();
69 return cache_tree_update(&the_index
, flags
);