THIS IS A TEST INSTANCE ONLY! REPOSITORIES CAN BE DELETED AT ANY TIME!

Git Source Code Mirror - This is a publish-only repository and all pull requests are ignored. Please follow Documentation/SubmittingPatches procedure for any of your improvements.
git
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.

196 lines
5.2KB

  1. #ifndef REPOSITORY_H
  2. #define REPOSITORY_H
  3. #include "path.h"
  4. struct config_set;
  5. struct git_hash_algo;
  6. struct index_state;
  7. struct lock_file;
  8. struct pathspec;
  9. struct raw_object_store;
  10. struct submodule_cache;
  11. enum untracked_cache_setting {
  12. UNTRACKED_CACHE_UNSET = -1,
  13. UNTRACKED_CACHE_REMOVE = 0,
  14. UNTRACKED_CACHE_KEEP = 1,
  15. UNTRACKED_CACHE_WRITE = 2
  16. };
  17. enum fetch_negotiation_setting {
  18. FETCH_NEGOTIATION_UNSET = -1,
  19. FETCH_NEGOTIATION_NONE = 0,
  20. FETCH_NEGOTIATION_DEFAULT = 1,
  21. FETCH_NEGOTIATION_SKIPPING = 2,
  22. };
  23. struct repo_settings {
  24. int initialized;
  25. int core_commit_graph;
  26. int gc_write_commit_graph;
  27. int fetch_write_commit_graph;
  28. int index_version;
  29. enum untracked_cache_setting core_untracked_cache;
  30. int pack_use_sparse;
  31. enum fetch_negotiation_setting fetch_negotiation_algorithm;
  32. };
  33. struct repository {
  34. /* Environment */
  35. /*
  36. * Path to the git directory.
  37. * Cannot be NULL after initialization.
  38. */
  39. char *gitdir;
  40. /*
  41. * Path to the common git directory.
  42. * Cannot be NULL after initialization.
  43. */
  44. char *commondir;
  45. /*
  46. * Holds any information related to accessing the raw object content.
  47. */
  48. struct raw_object_store *objects;
  49. /*
  50. * All objects in this repository that have been parsed. This structure
  51. * owns all objects it references, so users of "struct object *"
  52. * generally do not need to free them; instead, when a repository is no
  53. * longer used, call parsed_object_pool_clear() on this structure, which
  54. * is called by the repositories repo_clear on its desconstruction.
  55. */
  56. struct parsed_object_pool *parsed_objects;
  57. /* The store in which the refs are held. */
  58. struct ref_store *refs;
  59. /*
  60. * Contains path to often used file names.
  61. */
  62. struct path_cache cached_paths;
  63. /*
  64. * Path to the repository's graft file.
  65. * Cannot be NULL after initialization.
  66. */
  67. char *graft_file;
  68. /*
  69. * Path to the current worktree's index file.
  70. * Cannot be NULL after initialization.
  71. */
  72. char *index_file;
  73. /*
  74. * Path to the working directory.
  75. * A NULL value indicates that there is no working directory.
  76. */
  77. char *worktree;
  78. /*
  79. * Path from the root of the top-level superproject down to this
  80. * repository. This is only non-NULL if the repository is initialized
  81. * as a submodule of another repository.
  82. */
  83. char *submodule_prefix;
  84. struct repo_settings settings;
  85. /* Subsystems */
  86. /*
  87. * Repository's config which contains key-value pairs from the usual
  88. * set of config files (i.e. repo specific .git/config, user wide
  89. * ~/.gitconfig, XDG config file and the global /etc/gitconfig)
  90. */
  91. struct config_set *config;
  92. /* Repository's submodule config as defined by '.gitmodules' */
  93. struct submodule_cache *submodule_cache;
  94. /*
  95. * Repository's in-memory index.
  96. * 'repo_read_index()' can be used to populate 'index'.
  97. */
  98. struct index_state *index;
  99. /* Repository's current hash algorithm, as serialized on disk. */
  100. const struct git_hash_algo *hash_algo;
  101. /* A unique-id for tracing purposes. */
  102. int trace2_repo_id;
  103. /* True if commit-graph has been disabled within this process. */
  104. int commit_graph_disabled;
  105. /* Configurations */
  106. /* Indicate if a repository has a different 'commondir' from 'gitdir' */
  107. unsigned different_commondir:1;
  108. };
  109. extern struct repository *the_repository;
  110. /*
  111. * Define a custom repository layout. Any field can be NULL, which
  112. * will default back to the path according to the default layout.
  113. */
  114. struct set_gitdir_args {
  115. const char *commondir;
  116. const char *object_dir;
  117. const char *graft_file;
  118. const char *index_file;
  119. const char *alternate_db;
  120. };
  121. void repo_set_gitdir(struct repository *repo, const char *root,
  122. const struct set_gitdir_args *extra_args);
  123. void repo_set_worktree(struct repository *repo, const char *path);
  124. void repo_set_hash_algo(struct repository *repo, int algo);
  125. void initialize_the_repository(void);
  126. int repo_init(struct repository *r, const char *gitdir, const char *worktree);
  127. /*
  128. * Initialize the repository 'subrepo' as the submodule given by the
  129. * struct submodule 'sub' in parent repository 'superproject'.
  130. * Return 0 upon success and a non-zero value upon failure, which may happen
  131. * if the submodule is not found, or 'sub' is NULL.
  132. */
  133. struct submodule;
  134. int repo_submodule_init(struct repository *subrepo,
  135. struct repository *superproject,
  136. const struct submodule *sub);
  137. void repo_clear(struct repository *repo);
  138. /*
  139. * Populates the repository's index from its index_file, an index struct will
  140. * be allocated if needed.
  141. *
  142. * Return the number of index entries in the populated index or a value less
  143. * than zero if an error occured. If the repository's index has already been
  144. * populated then the number of entries will simply be returned.
  145. */
  146. int repo_read_index(struct repository *repo);
  147. int repo_hold_locked_index(struct repository *repo,
  148. struct lock_file *lf,
  149. int flags);
  150. int repo_read_index_preload(struct repository *,
  151. const struct pathspec *pathspec,
  152. unsigned refresh_flags);
  153. int repo_read_index_unmerged(struct repository *);
  154. /*
  155. * Opportunistically update the index but do not complain if we can't.
  156. * The lockfile is always committed or rolled back.
  157. */
  158. void repo_update_index_if_able(struct repository *, struct lock_file *);
  159. void prepare_repo_settings(struct repository *r);
  160. #endif /* REPOSITORY_H */