🌐 AI搜索 & 代理 主页
blob: cc6ddf51b3273c2dbeb798b2cb945de29dd28a36 [file] [log] [blame]
Daniel Barkalow6eb8ae02005-04-18 18:39:481#ifndef TREE_H
2#define TREE_H
3
4#include "object.h"
5
Elijah Newrend1cbe1e2023-04-22 20:17:206struct pathspec;
Nguyễn Thái Ngọc Duye0920732018-11-18 16:47:567struct repository;
Nguyễn Thái Ngọc Duy6a0b0b62014-11-30 09:05:008struct strbuf;
Daniel Barkalow6eb8ae02005-04-18 18:39:489
10struct tree {
11 struct object object;
Linus Torvalds136f2e52006-05-29 19:16:1212 void *buffer;
13 unsigned long size;
Daniel Barkalow6eb8ae02005-04-18 18:39:4814};
15
Nguyễn Thái Ngọc Duye0920732018-11-18 16:47:5616extern const char *tree_type;
17
Stefan Bellerf58a6cb2018-06-29 01:22:0918struct tree *lookup_tree(struct repository *r, const struct object_id *oid);
Daniel Barkalow6eb8ae02005-04-18 18:39:4819
Nicolas Pitrebd2c39f2005-05-06 17:48:3420int parse_tree_buffer(struct tree *item, void *buffer, unsigned long size);
21
Jeff King9cc2b072015-06-01 09:56:2622int 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 22:37:3927void free_tree_buffer(struct tree *tree);
Daniel Barkalow6eb8ae02005-04-18 18:39:4828
Daniel Barkalow77675e22005-09-05 06:03:5129/* Parses and returns the tree in the given ent, chasing tags and commits. */
brian m. carlsona9dbc172017-05-06 22:10:3730struct tree *parse_tree_indirect(const struct object_id *oid);
Daniel Barkalow77675e22005-09-05 06:03:5131
Elijah Newren53dca332023-04-22 20:17:2232/*
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:2541
Linus Torvalds3c5e8462005-11-26 17:38:2042#define READ_TREE_RECURSIVE 1
Ævar Arnfjörð Bjarmason47957482021-03-20 22:37:5143typedef int (*read_tree_fn_t)(const struct object_id *, struct strbuf *, const char *, unsigned int, void *);
Linus Torvalds3c5e8462005-11-26 17:38:2044
Ævar Arnfjörð Bjarmason6c9fc422021-03-20 22:37:5045int read_tree_at(struct repository *r,
46 struct tree *tree, struct strbuf *base,
Jeff King1ee7a5c2023-08-31 06:21:5547 int depth,
Ævar Arnfjörð Bjarmason6c9fc422021-03-20 22:37:5048 const struct pathspec *pathspec,
49 read_tree_fn_t fn, void *context);
50
Ævar Arnfjörð Bjarmason47957482021-03-20 22:37:5151int 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 18:39:4856#endif /* TREE_H */