shallow.h 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. #ifndef SHALLOW_H
  2. #define SHALLOW_H
  3. #include "lockfile.h"
  4. #include "object.h"
  5. #include "repository.h"
  6. #include "strbuf.h"
  7. void set_alternate_shallow_file(struct repository *r, const char *path, int override);
  8. int register_shallow(struct repository *r, const struct object_id *oid);
  9. int unregister_shallow(const struct object_id *oid);
  10. int is_repository_shallow(struct repository *r);
  11. /*
  12. * Lock for updating the $GIT_DIR/shallow file.
  13. *
  14. * Use `commit_shallow_file()` to commit an update, or
  15. * `rollback_shallow_file()` to roll it back. In either case, any
  16. * in-memory cached information about which commits are shallow will be
  17. * appropriately invalidated so that future operations reflect the new
  18. * state.
  19. */
  20. struct shallow_lock {
  21. struct lock_file lock;
  22. };
  23. #define SHALLOW_LOCK_INIT { LOCK_INIT }
  24. /* commit $GIT_DIR/shallow and reset stat-validity checks */
  25. int commit_shallow_file(struct repository *r, struct shallow_lock *lk);
  26. /* rollback $GIT_DIR/shallow and reset stat-validity checks */
  27. void rollback_shallow_file(struct repository *r, struct shallow_lock *lk);
  28. struct commit_list *get_shallow_commits(struct object_array *heads,
  29. int depth, int shallow_flag, int not_shallow_flag);
  30. struct commit_list *get_shallow_commits_by_rev_list(
  31. int ac, const char **av, int shallow_flag, int not_shallow_flag);
  32. int write_shallow_commits(struct strbuf *out, int use_pack_protocol,
  33. const struct oid_array *extra);
  34. void setup_alternate_shallow(struct shallow_lock *shallow_lock,
  35. const char **alternate_shallow_file,
  36. const struct oid_array *extra);
  37. const char *setup_temporary_shallow(const struct oid_array *extra);
  38. void advertise_shallow_grafts(int);
  39. #define PRUNE_SHOW_ONLY 1
  40. #define PRUNE_QUICK 2
  41. void prune_shallow(unsigned options);
  42. /*
  43. * Initialize with prepare_shallow_info() or zero-initialize (equivalent to
  44. * prepare_shallow_info with a NULL oid_array).
  45. */
  46. struct shallow_info {
  47. struct oid_array *shallow;
  48. int *ours, nr_ours;
  49. int *theirs, nr_theirs;
  50. struct oid_array *ref;
  51. /* for receive-pack */
  52. uint32_t **used_shallow;
  53. int *need_reachability_test;
  54. int *reachable;
  55. int *shallow_ref;
  56. struct commit **commits;
  57. int nr_commits;
  58. };
  59. void prepare_shallow_info(struct shallow_info *, struct oid_array *);
  60. void clear_shallow_info(struct shallow_info *);
  61. void remove_nonexistent_theirs_shallow(struct shallow_info *);
  62. void assign_shallow_commits_to_refs(struct shallow_info *info,
  63. uint32_t **used,
  64. int *ref_status);
  65. int delayed_reachability_test(struct shallow_info *si, int c);
  66. extern struct trace_key trace_shallow;
  67. #endif /* SHALLOW_H */