repository: mark the "refs" pointer as private
[git/raj.git] / repository.h
blob4ecc201f89dc94e27d434846740b8d3f618ad494
1 #ifndef REPOSITORY_H
2 #define REPOSITORY_H
4 #include "path.h"
6 struct config_set;
7 struct git_hash_algo;
8 struct index_state;
9 struct lock_file;
10 struct pathspec;
11 struct raw_object_store;
12 struct submodule_cache;
14 struct repository {
15 /* Environment */
17 * Path to the git directory.
18 * Cannot be NULL after initialization.
20 char *gitdir;
23 * Path to the common git directory.
24 * Cannot be NULL after initialization.
26 char *commondir;
29 * Holds any information related to accessing the raw object content.
31 struct raw_object_store *objects;
34 * All objects in this repository that have been parsed. This structure
35 * owns all objects it references, so users of "struct object *"
36 * generally do not need to free them; instead, when a repository is no
37 * longer used, call parsed_object_pool_clear() on this structure, which
38 * is called by the repositories repo_clear on its desconstruction.
40 struct parsed_object_pool *parsed_objects;
43 * The store in which the refs are held. This should generally only be
44 * accessed via get_main_ref_store(), as that will lazily initialize
45 * the ref object.
47 struct ref_store *refs_private;
50 * Contains path to often used file names.
52 struct path_cache cached_paths;
55 * Path to the repository's graft file.
56 * Cannot be NULL after initialization.
58 char *graft_file;
61 * Path to the current worktree's index file.
62 * Cannot be NULL after initialization.
64 char *index_file;
67 * Path to the working directory.
68 * A NULL value indicates that there is no working directory.
70 char *worktree;
73 * Path from the root of the top-level superproject down to this
74 * repository. This is only non-NULL if the repository is initialized
75 * as a submodule of another repository.
77 char *submodule_prefix;
79 /* Subsystems */
81 * Repository's config which contains key-value pairs from the usual
82 * set of config files (i.e. repo specific .git/config, user wide
83 * ~/.gitconfig, XDG config file and the global /etc/gitconfig)
85 struct config_set *config;
87 /* Repository's submodule config as defined by '.gitmodules' */
88 struct submodule_cache *submodule_cache;
91 * Repository's in-memory index.
92 * 'repo_read_index()' can be used to populate 'index'.
94 struct index_state *index;
96 /* Repository's current hash algorithm, as serialized on disk. */
97 const struct git_hash_algo *hash_algo;
99 /* A unique-id for tracing purposes. */
100 int trace2_repo_id;
102 /* Configurations */
104 /* Indicate if a repository has a different 'commondir' from 'gitdir' */
105 unsigned different_commondir:1;
108 extern struct repository *the_repository;
111 * Define a custom repository layout. Any field can be NULL, which
112 * will default back to the path according to the default layout.
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;
122 void repo_set_gitdir(struct repository *repo, const char *root,
123 const struct set_gitdir_args *extra_args);
124 void repo_set_worktree(struct repository *repo, const char *path);
125 void repo_set_hash_algo(struct repository *repo, int algo);
126 void initialize_the_repository(void);
127 int repo_init(struct repository *r, const char *gitdir, const char *worktree);
130 * Initialize the repository 'subrepo' as the submodule given by the
131 * struct submodule 'sub' in parent repository 'superproject'.
132 * Return 0 upon success and a non-zero value upon failure, which may happen
133 * if the submodule is not found, or 'sub' is NULL.
135 struct submodule;
136 int repo_submodule_init(struct repository *subrepo,
137 struct repository *superproject,
138 const struct submodule *sub);
139 void repo_clear(struct repository *repo);
142 * Populates the repository's index from its index_file, an index struct will
143 * be allocated if needed.
145 * Return the number of index entries in the populated index or a value less
146 * than zero if an error occured. If the repository's index has already been
147 * populated then the number of entries will simply be returned.
149 int repo_read_index(struct repository *repo);
150 int repo_hold_locked_index(struct repository *repo,
151 struct lock_file *lf,
152 int flags);
154 int repo_read_index_preload(struct repository *,
155 const struct pathspec *pathspec,
156 unsigned refresh_flags);
157 int repo_read_index_unmerged(struct repository *);
159 * Opportunistically update the index but do not complain if we can't.
160 * The lockfile is always committed or rolled back.
162 void repo_update_index_if_able(struct repository *, struct lock_file *);
165 #endif /* REPOSITORY_H */