tree-walk: store object_id in a separate member
[git/raj.git] / tree-walk.h
blob08d349c54ffa413347bbf7237c84371bda0878e1
1 #ifndef TREE_WALK_H
2 #define TREE_WALK_H
4 #include "cache.h"
6 struct strbuf;
8 struct name_entry {
9 struct object_id oid;
10 const char *path;
11 int pathlen;
12 unsigned int mode;
15 struct tree_desc {
16 const void *buffer;
17 struct name_entry entry;
18 unsigned int size;
21 static inline const struct object_id *tree_entry_extract(struct tree_desc *desc, const char **pathp, unsigned int *modep)
23 *pathp = desc->entry.path;
24 *modep = desc->entry.mode;
25 return &desc->entry.oid;
28 static inline int tree_entry_len(const struct name_entry *ne)
30 return ne->pathlen;
34 * The _gently versions of these functions warn and return false on a
35 * corrupt tree entry rather than dying,
38 void update_tree_entry(struct tree_desc *);
39 int update_tree_entry_gently(struct tree_desc *);
40 void init_tree_desc(struct tree_desc *desc, const void *buf, unsigned long size);
41 int init_tree_desc_gently(struct tree_desc *desc, const void *buf, unsigned long size);
44 * Helper function that does both tree_entry_extract() and update_tree_entry()
45 * and returns true for success
47 int tree_entry(struct tree_desc *, struct name_entry *);
48 int tree_entry_gently(struct tree_desc *, struct name_entry *);
50 void *fill_tree_descriptor(struct tree_desc *desc, 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(int n, struct tree_desc *t, struct traverse_info *info);
56 enum follow_symlinks_result {
57 FOUND = 0, /* This includes out-of-tree links */
58 MISSING_OBJECT = -1, /* The initial symlink is missing */
59 DANGLING_SYMLINK = -2, /*
60 * The initial symlink is there, but
61 * (transitively) points to a missing
62 * in-tree file
64 SYMLINK_LOOP = -3,
65 NOT_DIR = -4, /*
66 * Somewhere along the symlink chain, a path is
67 * requested which contains a file as a
68 * non-final element.
72 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);
74 struct traverse_info {
75 const char *traverse_path;
76 struct traverse_info *prev;
77 struct name_entry name;
78 int pathlen;
79 struct pathspec *pathspec;
81 unsigned long df_conflicts;
82 traverse_callback_t fn;
83 void *data;
84 int show_all_errors;
87 int get_tree_entry(const struct object_id *, const char *, struct object_id *, unsigned *);
88 extern char *make_traverse_path(char *path, const struct traverse_info *info, const struct name_entry *n);
89 extern void setup_traverse_info(struct traverse_info *info, const char *base);
91 static inline int traverse_path_len(const struct traverse_info *info, const struct name_entry *n)
93 return info->pathlen + tree_entry_len(n);
96 /* in general, positive means "kind of interesting" */
97 enum interesting {
98 all_entries_not_interesting = -1, /* no, and no subsequent entries will be either */
99 entry_not_interesting = 0,
100 entry_interesting = 1,
101 all_entries_interesting = 2 /* yes, and all subsequent entries will be */
104 extern enum interesting tree_entry_interesting(const struct name_entry *,
105 struct strbuf *, int,
106 const struct pathspec *ps);
108 #endif