blob: d8cb2e9e39d2be9c4dad67db44a464c2a1004d2f [file] [log] [blame]
Junio C Hamano74986462006-04-23 16:52:20 -07001#ifndef CACHE_TREE_H
2#define CACHE_TREE_H
3
Junio C Hamanob9d37a52009-04-20 03:58:18 -07004#include "tree.h"
Junio C Hamanob65982b2009-05-20 15:57:22 -07005#include "tree-walk.h"
Junio C Hamanob9d37a52009-04-20 03:58:18 -07006
Junio C Hamano74986462006-04-23 16:52:20 -07007struct cache_tree;
8struct cache_tree_sub {
9 struct cache_tree *cache_tree;
10 int namelen;
11 int used;
12 char name[FLEX_ARRAY];
13};
14
15struct cache_tree {
16 int entry_count; /* negative means "invalid" */
17 unsigned char sha1[20];
18 int subtree_nr;
19 int subtree_alloc;
20 struct cache_tree_sub **down;
21};
22
23struct cache_tree *cache_tree(void);
Junio C Hamanobad68ec2006-04-24 21:18:58 -070024void cache_tree_free(struct cache_tree **);
Junio C Hamano74986462006-04-23 16:52:20 -070025void cache_tree_invalidate_path(struct cache_tree *, const char *);
Junio C Hamano7927a552006-04-27 01:33:07 -070026struct cache_tree_sub *cache_tree_sub(struct cache_tree *, const char *);
Junio C Hamano74986462006-04-23 16:52:20 -070027
Pierre Habouzit1dffb8f2007-09-25 10:22:44 +020028void cache_tree_write(struct strbuf *, struct cache_tree *root);
Junio C Hamanobad68ec2006-04-24 21:18:58 -070029struct cache_tree *cache_tree_read(const char *buffer, unsigned long size);
Junio C Hamano74986462006-04-23 16:52:20 -070030
Junio C Hamanobad68ec2006-04-24 21:18:58 -070031int cache_tree_fully_valid(struct cache_tree *);
Nguyễn Thái Ngọc Duye859c692012-01-16 09:36:46 +070032int cache_tree_update(struct cache_tree *, struct cache_entry **, int, int);
Thomas Rast996277c2011-12-06 18:43:37 +010033
34int update_main_cache_tree(int);
Junio C Hamano74986462006-04-23 16:52:20 -070035
Junio C Hamanod11b8d32009-05-20 11:04:35 -070036/* bitmasks to write_cache_as_tree flags */
37#define WRITE_TREE_MISSING_OK 1
38#define WRITE_TREE_IGNORE_CACHE_TREE 2
Nguyễn Thái Ngọc Duye859c692012-01-16 09:36:46 +070039#define WRITE_TREE_DRY_RUN 4
40#define WRITE_TREE_SILENT 8
Junio C Hamanod11b8d32009-05-20 11:04:35 -070041
42/* error return codes */
Junio C Hamano45525bd2008-01-10 22:49:35 -080043#define WRITE_TREE_UNREADABLE_INDEX (-1)
44#define WRITE_TREE_UNMERGED_INDEX (-2)
45#define WRITE_TREE_PREFIX_ERROR (-3)
46
Junio C Hamanod11b8d32009-05-20 11:04:35 -070047int write_cache_as_tree(unsigned char *sha1, int flags, const char *prefix);
Junio C Hamanob9d37a52009-04-20 03:58:18 -070048void prime_cache_tree(struct cache_tree **, struct tree *);
49
Junio C Hamanob65982b2009-05-20 15:57:22 -070050extern int cache_tree_matches_traversal(struct cache_tree *, struct name_entry *ent, struct traverse_info *info);
51
Junio C Hamano74986462006-04-23 16:52:20 -070052#endif