mingw: short-circuit the conversion of `/dev/null` to UTF-16
[git/debian.git] / tree-walk.h
blobabe2caf4e0faae271967787b02137505a22ac5ff
1 #ifndef TREE_WALK_H
2 #define TREE_WALK_H
4 #include "cache.h"
6 struct name_entry {
7 struct object_id oid;
8 const char *path;
9 int pathlen;
10 unsigned int mode;
13 struct tree_desc {
14 const void *buffer;
15 struct name_entry entry;
16 unsigned int size;
19 static inline const struct object_id *tree_entry_extract(struct tree_desc *desc, const char **pathp, unsigned short *modep)
21 *pathp = desc->entry.path;
22 *modep = desc->entry.mode;
23 return &desc->entry.oid;
26 static inline int tree_entry_len(const struct name_entry *ne)
28 return ne->pathlen;
32 * The _gently versions of these functions warn and return false on a
33 * corrupt tree entry rather than dying,
36 void update_tree_entry(struct tree_desc *);
37 int update_tree_entry_gently(struct tree_desc *);
38 void init_tree_desc(struct tree_desc *desc, const void *buf, unsigned long size);
39 int init_tree_desc_gently(struct tree_desc *desc, const void *buf, unsigned long size);
42 * Helper function that does both tree_entry_extract() and update_tree_entry()
43 * and returns true for success
45 int tree_entry(struct tree_desc *, struct name_entry *);
46 int tree_entry_gently(struct tree_desc *, struct name_entry *);
48 void *fill_tree_descriptor(struct repository *r,
49 struct tree_desc *desc,
50 const struct object_id *oid);
52 struct traverse_info;
53 typedef int (*traverse_callback_t)(int n, unsigned long mask, unsigned long dirmask, struct name_entry *entry, struct traverse_info *);
54 int traverse_trees(struct index_state *istate, int n, struct tree_desc *t, struct traverse_info *info);
56 enum get_oid_result get_tree_entry_follow_symlinks(struct repository *r, struct object_id *tree_oid, const char *name, struct object_id *result, struct strbuf *result_path, unsigned short *mode);
58 struct traverse_info {
59 const char *traverse_path;
60 struct traverse_info *prev;
61 const char *name;
62 size_t namelen;
63 unsigned mode;
65 size_t pathlen;
66 struct pathspec *pathspec;
68 unsigned long df_conflicts;
69 traverse_callback_t fn;
70 void *data;
71 int show_all_errors;
74 int get_tree_entry(struct repository *, const struct object_id *, const char *, struct object_id *, unsigned short *);
75 char *make_traverse_path(char *path, size_t pathlen, const struct traverse_info *info,
76 const char *name, size_t namelen);
77 void strbuf_make_traverse_path(struct strbuf *out,
78 const struct traverse_info *info,
79 const char *name, size_t namelen);
80 void setup_traverse_info(struct traverse_info *info, const char *base);
82 static inline size_t traverse_path_len(const struct traverse_info *info,
83 size_t namelen)
85 return st_add(info->pathlen, namelen);
88 /* in general, positive means "kind of interesting" */
89 enum interesting {
90 all_entries_not_interesting = -1, /* no, and no subsequent entries will be either */
91 entry_not_interesting = 0,
92 entry_interesting = 1,
93 all_entries_interesting = 2 /* yes, and all subsequent entries will be */
96 enum interesting tree_entry_interesting(struct index_state *istate,
97 const struct name_entry *,
98 struct strbuf *, int,
99 const struct pathspec *ps);
101 #endif