blob: 330ab64bbd40bd9202a7474cbda0818b98640cde [file] [log] [blame]
Daniel Barkalow6eb8ae02005-04-18 11:39:48 -07001#ifndef TREE_H
2#define TREE_H
3
4#include "object.h"
5
6extern const char *tree_type;
7
Daniel Barkalow08692162005-04-23 18:47:23 -07008struct tree_entry_list {
9 struct tree_entry_list *next;
10 unsigned directory : 1;
11 unsigned executable : 1;
Linus Torvalds42ea9cb2005-05-05 16:18:48 -070012 unsigned symlink : 1;
Linus Torvalds64071802005-07-27 16:08:43 -070013 unsigned zeropad : 1;
Linus Torvalds42ea9cb2005-05-05 16:18:48 -070014 unsigned int mode;
Daniel Barkalow08692162005-04-23 18:47:23 -070015 char *name;
16 union {
barkalow@iabervon.org66e481b2005-08-02 19:45:48 -040017 struct object *any;
Daniel Barkalow08692162005-04-23 18:47:23 -070018 struct tree *tree;
19 struct blob *blob;
20 } item;
21};
22
Daniel Barkalow6eb8ae02005-04-18 11:39:48 -070023struct tree {
24 struct object object;
Daniel Barkalow08692162005-04-23 18:47:23 -070025 struct tree_entry_list *entries;
Daniel Barkalow6eb8ae02005-04-18 11:39:48 -070026};
27
Jason McMullan5d6ccf52005-06-03 11:05:39 -040028struct tree *lookup_tree(const unsigned char *sha1);
Daniel Barkalow6eb8ae02005-04-18 11:39:48 -070029
Nicolas Pitrebd2c39f2005-05-06 13:48:34 -040030int parse_tree_buffer(struct tree *item, void *buffer, unsigned long size);
31
Daniel Barkalow6eb8ae02005-04-18 11:39:48 -070032int parse_tree(struct tree *tree);
33
Daniel Barkalow77675e22005-09-05 02:03:51 -040034/* Parses and returns the tree in the given ent, chasing tags and commits. */
35struct tree *parse_tree_indirect(const unsigned char *sha1);
36
Linus Torvalds3c5e8462005-11-26 09:38:20 -080037#define READ_TREE_RECURSIVE 1
38typedef int (*read_tree_fn_t)(unsigned char *, const char *, int, const char *, unsigned int, int);
39
Daniel Barkalow521698b2006-01-26 01:13:36 -050040extern int read_tree_recursive(struct tree *tree,
41 const char *base, int baselen,
42 int stage, const char **match,
43 read_tree_fn_t fn);
Linus Torvalds3c5e8462005-11-26 09:38:20 -080044
Daniel Barkalow521698b2006-01-26 01:13:36 -050045extern int read_tree(struct tree *tree, int stage, const char **paths);
Linus Torvalds3c5e8462005-11-26 09:38:20 -080046
Daniel Barkalow6eb8ae02005-04-18 11:39:48 -070047#endif /* TREE_H */