tree.h 1.15 KB
Newer Older
1 2 3 4 5
#ifndef TREE_H
#define TREE_H

#include "object.h"

6
struct repository;
7
struct strbuf;
8 9 10

struct tree {
	struct object object;
11 12
	void *buffer;
	unsigned long size;
13 14
};

15 16
extern const char *tree_type;

17
struct tree *lookup_tree(struct repository *r, const struct object_id *oid);
18

19 20
int parse_tree_buffer(struct tree *item, void *buffer, unsigned long size);

21 22 23 24 25
int parse_tree_gently(struct tree *tree, int quiet_on_missing);
static inline int parse_tree(struct tree *tree)
{
	return parse_tree_gently(tree, 0);
}
26
void free_tree_buffer(struct tree *tree);
27

28
/* Parses and returns the tree in the given ent, chasing tags and commits. */
29
struct tree *parse_tree_indirect(const struct object_id *oid);
30

31
#define READ_TREE_RECURSIVE 1
32
typedef int (*read_tree_fn_t)(const struct object_id *, struct strbuf *, const char *, unsigned int, int, void *);
33

34 35 36 37 38
int read_tree_recursive(struct repository *r,
			struct tree *tree,
			const char *base, int baselen,
			int stage, const struct pathspec *pathspec,
			read_tree_fn_t fn, void *context);
39

40 41 42
int read_tree(struct repository *r, struct tree *tree,
	      int stage, struct pathspec *pathspec,
	      struct index_state *istate);
43

44
#endif /* TREE_H */