RelNotes 2.20: move some items between sections
[git/gitster.git] / tree-walk.h
blob196831007e618f808661bf4b7f54030890f48563
1 #ifndef TREE_WALK_H
2 #define TREE_WALK_H
4 struct strbuf;
6 struct name_entry {
7 const struct object_id *oid;
8 const char *path;
9 unsigned int mode;
12 struct tree_desc {
13 const void *buffer;
14 struct name_entry entry;
15 unsigned int size;
18 static inline const struct object_id *tree_entry_extract(struct tree_desc *desc, const char **pathp, unsigned int *modep)
20 *pathp = desc->entry.path;
21 *modep = desc->entry.mode;
22 return desc->entry.oid;
25 static inline int tree_entry_len(const struct name_entry *ne)
27 return (const char *)ne->oid - ne->path - 1;
31 * The _gently versions of these functions warn and return false on a
32 * corrupt tree entry rather than dying,
35 void update_tree_entry(struct tree_desc *);
36 int update_tree_entry_gently(struct tree_desc *);
37 void init_tree_desc(struct tree_desc *desc, const void *buf, unsigned long size);
38 int init_tree_desc_gently(struct tree_desc *desc, const void *buf, unsigned long size);
41 * Helper function that does both tree_entry_extract() and update_tree_entry()
42 * and returns true for success
44 int tree_entry(struct tree_desc *, struct name_entry *);
45 int tree_entry_gently(struct tree_desc *, struct name_entry *);
47 void *fill_tree_descriptor(struct tree_desc *desc, const struct object_id *oid);
49 struct traverse_info;
50 typedef int (*traverse_callback_t)(int n, unsigned long mask, unsigned long dirmask, struct name_entry *entry, struct traverse_info *);
51 int traverse_trees(int n, struct tree_desc *t, struct traverse_info *info);
53 enum follow_symlinks_result {
54 FOUND = 0, /* This includes out-of-tree links */
55 MISSING_OBJECT = -1, /* The initial symlink is missing */
56 DANGLING_SYMLINK = -2, /*
57 * The initial symlink is there, but
58 * (transitively) points to a missing
59 * in-tree file
61 SYMLINK_LOOP = -3,
62 NOT_DIR = -4, /*
63 * Somewhere along the symlink chain, a path is
64 * requested which contains a file as a
65 * non-final element.
69 enum follow_symlinks_result get_tree_entry_follow_symlinks(struct object_id *tree_oid, const char *name, struct object_id *result, struct strbuf *result_path, unsigned *mode);
71 struct traverse_info {
72 const char *traverse_path;
73 struct traverse_info *prev;
74 struct name_entry name;
75 int pathlen;
76 struct pathspec *pathspec;
78 unsigned long df_conflicts;
79 traverse_callback_t fn;
80 void *data;
81 int show_all_errors;
84 int get_tree_entry(const struct object_id *, const char *, struct object_id *, unsigned *);
85 extern char *make_traverse_path(char *path, const struct traverse_info *info, const struct name_entry *n);
86 extern void setup_traverse_info(struct traverse_info *info, const char *base);
88 static inline int traverse_path_len(const struct traverse_info *info, const struct name_entry *n)
90 return info->pathlen + tree_entry_len(n);
93 /* in general, positive means "kind of interesting" */
94 enum interesting {
95 all_entries_not_interesting = -1, /* no, and no subsequent entries will be either */
96 entry_not_interesting = 0,
97 entry_interesting = 1,
98 all_entries_interesting = 2 /* yes, and all subsequent entries will be */
101 extern enum interesting tree_entry_interesting(const struct name_entry *,
102 struct strbuf *, int,
103 const struct pathspec *ps);
105 #endif