tree.h 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. #ifndef TREE_H
  2. #define TREE_H
  3. #include "object.h"
  4. struct repository;
  5. struct strbuf;
  6. struct tree {
  7. struct object object;
  8. void *buffer;
  9. unsigned long size;
  10. };
  11. extern const char *tree_type;
  12. struct tree *lookup_tree(struct repository *r, const struct object_id *oid);
  13. int parse_tree_buffer(struct tree *item, void *buffer, unsigned long size);
  14. int parse_tree_gently(struct tree *tree, int quiet_on_missing);
  15. static inline int parse_tree(struct tree *tree)
  16. {
  17. return parse_tree_gently(tree, 0);
  18. }
  19. void free_tree_buffer(struct tree *tree);
  20. /* Parses and returns the tree in the given ent, chasing tags and commits. */
  21. struct tree *parse_tree_indirect(const struct object_id *oid);
  22. #define READ_TREE_RECURSIVE 1
  23. typedef int (*read_tree_fn_t)(const struct object_id *, struct strbuf *, const char *, unsigned int, int, void *);
  24. int read_tree_recursive(struct repository *r,
  25. struct tree *tree,
  26. const char *base, int baselen,
  27. int stage, const struct pathspec *pathspec,
  28. read_tree_fn_t fn, void *context);
  29. int read_tree(struct repository *r, struct tree *tree,
  30. int stage, struct pathspec *pathspec,
  31. struct index_state *istate);
  32. #endif /* TREE_H */