blob: cc6ddf51b3273c2dbeb798b2cb945de29dd28a36 [file] [log] [blame]
Daniel Barkalow6eb8ae02005-04-18 11:39:48 -07001#ifndef TREE_H
2#define TREE_H
3
4#include "object.h"
5
Elijah Newrend1cbe1e2023-04-22 20:17:20 +00006struct pathspec;
Nguyễn Thái Ngọc Duye0920732018-11-18 17:47:56 +01007struct repository;
Nguyễn Thái Ngọc Duy6a0b0b62014-11-30 16:05:00 +07008struct strbuf;
Daniel Barkalow6eb8ae02005-04-18 11:39:48 -07009
10struct tree {
11 struct object object;
Linus Torvalds136f2e52006-05-29 12:16:12 -070012 void *buffer;
13 unsigned long size;
Daniel Barkalow6eb8ae02005-04-18 11:39:48 -070014};
15
Nguyễn Thái Ngọc Duye0920732018-11-18 17:47:56 +010016extern const char *tree_type;
17
Stefan Bellerf58a6cb2018-06-28 18:22:09 -070018struct tree *lookup_tree(struct repository *r, const struct object_id *oid);
Daniel Barkalow6eb8ae02005-04-18 11:39:48 -070019
Nicolas Pitrebd2c39f2005-05-06 13:48:34 -040020int parse_tree_buffer(struct tree *item, void *buffer, unsigned long size);
21
Jeff King9cc2b072015-06-01 05:56:26 -040022int parse_tree_gently(struct tree *tree, int quiet_on_missing);
23static inline int parse_tree(struct tree *tree)
24{
25 return parse_tree_gently(tree, 0);
26}
Jeff King6e454b92013-06-05 18:37:39 -040027void free_tree_buffer(struct tree *tree);
Daniel Barkalow6eb8ae02005-04-18 11:39:48 -070028
Daniel Barkalow77675e22005-09-05 02:03:51 -040029/* Parses and returns the tree in the given ent, chasing tags and commits. */
brian m. carlsona9dbc172017-05-06 22:10:37 +000030struct tree *parse_tree_indirect(const struct object_id *oid);
Daniel Barkalow77675e22005-09-05 02:03:51 -040031
Elijah Newren53dca332023-04-22 20:17:22 +000032/*
33 * Functions for comparing pathnames
34 */
35int base_name_compare(const char *name1, size_t len1, int mode1,
36 const char *name2, size_t len2, int mode2);
37int df_name_compare(const char *name1, size_t len1, int mode1,
38 const char *name2, size_t len2, int mode2);
39int name_compare(const char *name1, size_t len1,
40 const char *name2, size_t len2);
Elijah Newren70912f62020-12-13 08:04:25 +000041
Linus Torvalds3c5e8462005-11-26 09:38:20 -080042#define READ_TREE_RECURSIVE 1
Ævar Arnfjörð Bjarmason47957482021-03-20 23:37:51 +010043typedef int (*read_tree_fn_t)(const struct object_id *, struct strbuf *, const char *, unsigned int, void *);
Linus Torvalds3c5e8462005-11-26 09:38:20 -080044
Ævar Arnfjörð Bjarmason6c9fc422021-03-20 23:37:50 +010045int read_tree_at(struct repository *r,
46 struct tree *tree, struct strbuf *base,
Jeff King1ee7a5c2023-08-31 02:21:55 -040047 int depth,
Ævar Arnfjörð Bjarmason6c9fc422021-03-20 23:37:50 +010048 const struct pathspec *pathspec,
49 read_tree_fn_t fn, void *context);
50
Ævar Arnfjörð Bjarmason47957482021-03-20 23:37:51 +010051int read_tree(struct repository *r,
52 struct tree *tree,
53 const struct pathspec *pathspec,
54 read_tree_fn_t fn, void *context);
55
Daniel Barkalow6eb8ae02005-04-18 11:39:48 -070056#endif /* TREE_H */