| Daniel Barkalow | 6eb8ae0 | 2005-04-18 18:39:48 | [diff] [blame] | 1 | #ifndef TREE_H |
| 2 | #define TREE_H |
| 3 | |
| 4 | #include "object.h" |
| 5 | |
| Elijah Newren | d1cbe1e | 2023-04-22 20:17:20 | [diff] [blame] | 6 | struct pathspec; |
| Nguyễn Thái Ngọc Duy | e092073 | 2018-11-18 16:47:56 | [diff] [blame] | 7 | struct repository; |
| Nguyễn Thái Ngọc Duy | 6a0b0b6 | 2014-11-30 09:05:00 | [diff] [blame] | 8 | struct strbuf; |
| Daniel Barkalow | 6eb8ae0 | 2005-04-18 18:39:48 | [diff] [blame] | 9 | |
| 10 | struct tree { |
| 11 | struct object object; |
| Linus Torvalds | 136f2e5 | 2006-05-29 19:16:12 | [diff] [blame] | 12 | void *buffer; |
| 13 | unsigned long size; |
| Daniel Barkalow | 6eb8ae0 | 2005-04-18 18:39:48 | [diff] [blame] | 14 | }; |
| 15 | |
| Nguyễn Thái Ngọc Duy | e092073 | 2018-11-18 16:47:56 | [diff] [blame] | 16 | extern const char *tree_type; |
| 17 | |
| Stefan Beller | f58a6cb | 2018-06-29 01:22:09 | [diff] [blame] | 18 | struct tree *lookup_tree(struct repository *r, const struct object_id *oid); |
| Daniel Barkalow | 6eb8ae0 | 2005-04-18 18:39:48 | [diff] [blame] | 19 | |
| Nicolas Pitre | bd2c39f | 2005-05-06 17:48:34 | [diff] [blame] | 20 | int parse_tree_buffer(struct tree *item, void *buffer, unsigned long size); |
| 21 | |
| Jeff King | 9cc2b07 | 2015-06-01 09:56:26 | [diff] [blame] | 22 | int parse_tree_gently(struct tree *tree, int quiet_on_missing); |
| 23 | static inline int parse_tree(struct tree *tree) |
| 24 | { |
| 25 | return parse_tree_gently(tree, 0); |
| 26 | } |
| Jeff King | 6e454b9 | 2013-06-05 22:37:39 | [diff] [blame] | 27 | void free_tree_buffer(struct tree *tree); |
| Daniel Barkalow | 6eb8ae0 | 2005-04-18 18:39:48 | [diff] [blame] | 28 | |
| Daniel Barkalow | 77675e2 | 2005-09-05 06:03:51 | [diff] [blame] | 29 | /* Parses and returns the tree in the given ent, chasing tags and commits. */ |
| brian m. carlson | a9dbc17 | 2017-05-06 22:10:37 | [diff] [blame] | 30 | struct tree *parse_tree_indirect(const struct object_id *oid); |
| Daniel Barkalow | 77675e2 | 2005-09-05 06:03:51 | [diff] [blame] | 31 | |
| Elijah Newren | 53dca33 | 2023-04-22 20:17:22 | [diff] [blame] | 32 | /* |
| 33 | * Functions for comparing pathnames |
| 34 | */ |
| 35 | int base_name_compare(const char *name1, size_t len1, int mode1, |
| 36 | const char *name2, size_t len2, int mode2); |
| 37 | int df_name_compare(const char *name1, size_t len1, int mode1, |
| 38 | const char *name2, size_t len2, int mode2); |
| 39 | int name_compare(const char *name1, size_t len1, |
| 40 | const char *name2, size_t len2); |
| Elijah Newren | 70912f6 | 2020-12-13 08:04:25 | [diff] [blame] | 41 | |
| Linus Torvalds | 3c5e846 | 2005-11-26 17:38:20 | [diff] [blame] | 42 | #define READ_TREE_RECURSIVE 1 |
| Ævar Arnfjörð Bjarmason | 4795748 | 2021-03-20 22:37:51 | [diff] [blame] | 43 | typedef int (*read_tree_fn_t)(const struct object_id *, struct strbuf *, const char *, unsigned int, void *); |
| Linus Torvalds | 3c5e846 | 2005-11-26 17:38:20 | [diff] [blame] | 44 | |
| Ævar Arnfjörð Bjarmason | 6c9fc42 | 2021-03-20 22:37:50 | [diff] [blame] | 45 | int read_tree_at(struct repository *r, |
| 46 | struct tree *tree, struct strbuf *base, |
| Jeff King | 1ee7a5c | 2023-08-31 06:21:55 | [diff] [blame] | 47 | int depth, |
| Ævar Arnfjörð Bjarmason | 6c9fc42 | 2021-03-20 22:37:50 | [diff] [blame] | 48 | const struct pathspec *pathspec, |
| 49 | read_tree_fn_t fn, void *context); |
| 50 | |
| Ævar Arnfjörð Bjarmason | 4795748 | 2021-03-20 22:37:51 | [diff] [blame] | 51 | int read_tree(struct repository *r, |
| 52 | struct tree *tree, |
| 53 | const struct pathspec *pathspec, |
| 54 | read_tree_fn_t fn, void *context); |
| 55 | |
| Daniel Barkalow | 6eb8ae0 | 2005-04-18 18:39:48 | [diff] [blame] | 56 | #endif /* TREE_H */ |