You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

commit-graph.h 2.2KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. #ifndef COMMIT_GRAPH_H
  2. #define COMMIT_GRAPH_H
  3. #include "git-compat-util.h"
  4. #include "repository.h"
  5. #include "string-list.h"
  6. #include "cache.h"
  7. #define GIT_TEST_COMMIT_GRAPH "GIT_TEST_COMMIT_GRAPH"
  8. #define GIT_TEST_COMMIT_GRAPH_DIE_ON_LOAD "GIT_TEST_COMMIT_GRAPH_DIE_ON_LOAD"
  9. struct commit;
  10. char *get_commit_graph_filename(const char *obj_dir);
  11. int open_commit_graph(const char *graph_file, int *fd, struct stat *st);
  12. /*
  13. * Given a commit struct, try to fill the commit struct info, including:
  14. * 1. tree object
  15. * 2. date
  16. * 3. parents.
  17. *
  18. * Returns 1 if and only if the commit was found in the packed graph.
  19. *
  20. * See parse_commit_buffer() for the fallback after this call.
  21. */
  22. int parse_commit_in_graph(struct repository *r, struct commit *item);
  23. /*
  24. * It is possible that we loaded commit contents from the commit buffer,
  25. * but we also want to ensure the commit-graph content is correctly
  26. * checked and filled. Fill the graph_pos and generation members of
  27. * the given commit.
  28. */
  29. void load_commit_graph_info(struct repository *r, struct commit *item);
  30. struct tree *get_commit_tree_in_graph(struct repository *r,
  31. const struct commit *c);
  32. struct commit_graph {
  33. int graph_fd;
  34. const unsigned char *data;
  35. size_t data_len;
  36. unsigned char hash_len;
  37. unsigned char num_chunks;
  38. uint32_t num_commits;
  39. struct object_id oid;
  40. const uint32_t *chunk_oid_fanout;
  41. const unsigned char *chunk_oid_lookup;
  42. const unsigned char *chunk_commit_data;
  43. const unsigned char *chunk_extra_edges;
  44. };
  45. struct commit_graph *load_commit_graph_one_fd_st(int fd, struct stat *st);
  46. struct commit_graph *parse_commit_graph(void *graph_map, int fd,
  47. size_t graph_size);
  48. /*
  49. * Return 1 if and only if the repository has a commit-graph
  50. * file and generation numbers are computed in that file.
  51. */
  52. int generation_numbers_enabled(struct repository *r);
  53. void write_commit_graph_reachable(const char *obj_dir, int append,
  54. int report_progress);
  55. void write_commit_graph(const char *obj_dir,
  56. struct string_list *pack_indexes,
  57. struct string_list *commit_hex,
  58. int append, int report_progress);
  59. int verify_commit_graph(struct repository *r, struct commit_graph *g);
  60. void close_commit_graph(struct repository *);
  61. void free_commit_graph(struct commit_graph *);
  62. #endif