1#ifndef CACHE_TREE_H2#define CACHE_TREE_H34#include "cache.h"5#include "tree.h"6#include "tree-walk.h"78struct cache_tree;9struct cache_tree_sub {10struct cache_tree *cache_tree;11int count; /* internally used by update_one() */12int namelen;13int used;14char name[FLEX_ARRAY];15};1617struct cache_tree {18int entry_count; /* negative means "invalid" */19struct object_id oid;20int subtree_nr;21int subtree_alloc;22struct cache_tree_sub **down;23};2425struct cache_tree *cache_tree(void);26void cache_tree_free(struct cache_tree **);27void cache_tree_invalidate_path(struct index_state *, const char *);28struct cache_tree_sub *cache_tree_sub(struct cache_tree *, const char *);2930void cache_tree_write(struct strbuf *, struct cache_tree *root);31struct cache_tree *cache_tree_read(const char *buffer, unsigned long size);3233int cache_tree_fully_valid(struct cache_tree *);34int cache_tree_update(struct index_state *, int);35void cache_tree_verify(struct index_state *);3637/* bitmasks to write_cache_as_tree flags */38#define WRITE_TREE_MISSING_OK 139#define WRITE_TREE_IGNORE_CACHE_TREE 240#define WRITE_TREE_DRY_RUN 441#define WRITE_TREE_SILENT 842#define WRITE_TREE_REPAIR 164344/* error return codes */45#define WRITE_TREE_UNREADABLE_INDEX (-1)46#define WRITE_TREE_UNMERGED_INDEX (-2)47#define WRITE_TREE_PREFIX_ERROR (-3)4849int write_index_as_tree(struct object_id *oid, struct index_state *index_state, const char *index_path, int flags, const char *prefix);50void prime_cache_tree(struct index_state *, struct tree *);5152int cache_tree_matches_traversal(struct cache_tree *, struct name_entry *ent, struct traverse_info *info);5354#ifndef NO_THE_INDEX_COMPATIBILITY_MACROS55static inline int write_cache_as_tree(struct object_id *oid, int flags, const char *prefix)56{57return write_index_as_tree(oid, &the_index, get_index_file(), flags, prefix);58}5960static inline int update_main_cache_tree(int flags)61{62if (!the_index.cache_tree)63the_index.cache_tree = cache_tree();64return cache_tree_update(&the_index, flags);65}66#endif6768#endif