Highlight keyboard shortcuts in git-add--interactive
[git/git-p4.git] / tree-walk.h
blob903a7b0f483fec5cbb6c6b372ab49cc28b655e75
1 #ifndef TREE_WALK_H
2 #define TREE_WALK_H
4 struct name_entry {
5 const unsigned char *sha1;
6 const char *path;
7 unsigned int mode;
8 };
10 static inline enum object_type object_type(unsigned int mode)
12 return S_ISDIR(mode) ? OBJ_TREE :
13 S_ISGITLINK(mode) ? OBJ_COMMIT :
14 OBJ_BLOB;
17 struct tree_desc {
18 const void *buffer;
19 struct name_entry entry;
20 unsigned int size;
23 static inline const unsigned char *tree_entry_extract(struct tree_desc *desc, const char **pathp, unsigned int *modep)
25 *pathp = desc->entry.path;
26 *modep = canon_mode(desc->entry.mode);
27 return desc->entry.sha1;
30 static inline int tree_entry_len(const char *name, const unsigned char *sha1)
32 return (const char *)sha1 - name - 1;
35 void update_tree_entry(struct tree_desc *);
36 void init_tree_desc(struct tree_desc *desc, const void *buf, unsigned long size);
38 /* Helper function that does both of the above and returns true for success */
39 int tree_entry(struct tree_desc *, struct name_entry *);
41 void *fill_tree_descriptor(struct tree_desc *desc, const unsigned char *sha1);
43 typedef void (*traverse_callback_t)(int n, unsigned long mask, struct name_entry *entry, const char *base);
45 void traverse_trees(int n, struct tree_desc *t, const char *base, traverse_callback_t callback);
47 int get_tree_entry(const unsigned char *, const char *, unsigned char *, unsigned *);
49 #endif