fsm-listen-win32: handle shortnames
[alt-git.git] / repository.h
blob9bbb4659cc871f4981a5bb806d753702ca753e78
1 #ifndef REPOSITORY_H
2 #define REPOSITORY_H
4 #include "path.h"
6 struct config_set;
7 struct fsmonitor_settings;
8 struct git_hash_algo;
9 struct index_state;
10 struct lock_file;
11 struct pathspec;
12 struct raw_object_store;
13 struct submodule_cache;
14 struct promisor_remote_config;
15 struct remote_state;
17 enum untracked_cache_setting {
18 UNTRACKED_CACHE_KEEP,
19 UNTRACKED_CACHE_REMOVE,
20 UNTRACKED_CACHE_WRITE,
23 enum fetch_negotiation_setting {
24 FETCH_NEGOTIATION_CONSECUTIVE,
25 FETCH_NEGOTIATION_SKIPPING,
26 FETCH_NEGOTIATION_NOOP,
29 struct repo_settings {
30 int initialized;
32 int core_commit_graph;
33 int commit_graph_read_changed_paths;
34 int gc_write_commit_graph;
35 int fetch_write_commit_graph;
36 int command_requires_full_index;
37 int sparse_index;
39 struct fsmonitor_settings *fsmonitor; /* lazily loaded */
41 int index_version;
42 enum untracked_cache_setting core_untracked_cache;
44 int pack_use_sparse;
45 enum fetch_negotiation_setting fetch_negotiation_algorithm;
47 int core_multi_pack_index;
50 struct repository {
51 /* Environment */
53 * Path to the git directory.
54 * Cannot be NULL after initialization.
56 char *gitdir;
59 * Path to the common git directory.
60 * Cannot be NULL after initialization.
62 char *commondir;
65 * Holds any information related to accessing the raw object content.
67 struct raw_object_store *objects;
70 * All objects in this repository that have been parsed. This structure
71 * owns all objects it references, so users of "struct object *"
72 * generally do not need to free them; instead, when a repository is no
73 * longer used, call parsed_object_pool_clear() on this structure, which
74 * is called by the repositories repo_clear on its desconstruction.
76 struct parsed_object_pool *parsed_objects;
79 * The store in which the refs are held. This should generally only be
80 * accessed via get_main_ref_store(), as that will lazily initialize
81 * the ref object.
83 struct ref_store *refs_private;
86 * Contains path to often used file names.
88 struct path_cache cached_paths;
91 * Path to the repository's graft file.
92 * Cannot be NULL after initialization.
94 char *graft_file;
97 * Path to the current worktree's index file.
98 * Cannot be NULL after initialization.
100 char *index_file;
103 * Path to the working directory.
104 * A NULL value indicates that there is no working directory.
106 char *worktree;
109 * Path from the root of the top-level superproject down to this
110 * repository. This is only non-NULL if the repository is initialized
111 * as a submodule of another repository.
113 char *submodule_prefix;
115 struct repo_settings settings;
117 /* Subsystems */
119 * Repository's config which contains key-value pairs from the usual
120 * set of config files (i.e. repo specific .git/config, user wide
121 * ~/.gitconfig, XDG config file and the global /etc/gitconfig)
123 struct config_set *config;
125 /* Repository's submodule config as defined by '.gitmodules' */
126 struct submodule_cache *submodule_cache;
129 * Repository's in-memory index.
130 * 'repo_read_index()' can be used to populate 'index'.
132 struct index_state *index;
134 /* Repository's remotes and associated structures. */
135 struct remote_state *remote_state;
137 /* Repository's current hash algorithm, as serialized on disk. */
138 const struct git_hash_algo *hash_algo;
140 /* A unique-id for tracing purposes. */
141 int trace2_repo_id;
143 /* True if commit-graph has been disabled within this process. */
144 int commit_graph_disabled;
146 /* Configurations related to promisor remotes. */
147 char *repository_format_partial_clone;
148 struct promisor_remote_config *promisor_remote_config;
150 /* Configurations */
152 /* Indicate if a repository has a different 'commondir' from 'gitdir' */
153 unsigned different_commondir:1;
156 extern struct repository *the_repository;
159 * Define a custom repository layout. Any field can be NULL, which
160 * will default back to the path according to the default layout.
162 struct set_gitdir_args {
163 const char *commondir;
164 const char *object_dir;
165 const char *graft_file;
166 const char *index_file;
167 const char *alternate_db;
168 int disable_ref_updates;
171 void repo_set_gitdir(struct repository *repo, const char *root,
172 const struct set_gitdir_args *extra_args);
173 void repo_set_worktree(struct repository *repo, const char *path);
174 void repo_set_hash_algo(struct repository *repo, int algo);
175 void initialize_the_repository(void);
176 int repo_init(struct repository *r, const char *gitdir, const char *worktree);
179 * Initialize the repository 'subrepo' as the submodule at the given path. If
180 * the submodule's gitdir cannot be found at <path>/.git, this function calls
181 * submodule_from_path() to try to find it. treeish_name is only used if
182 * submodule_from_path() needs to be called; see its documentation for more
183 * information.
184 * Return 0 upon success and a non-zero value upon failure.
186 struct object_id;
187 int repo_submodule_init(struct repository *subrepo,
188 struct repository *superproject,
189 const char *path,
190 const struct object_id *treeish_name);
191 void repo_clear(struct repository *repo);
194 * Populates the repository's index from its index_file, an index struct will
195 * be allocated if needed.
197 * Return the number of index entries in the populated index or a value less
198 * than zero if an error occurred. If the repository's index has already been
199 * populated then the number of entries will simply be returned.
201 int repo_read_index(struct repository *repo);
202 int repo_hold_locked_index(struct repository *repo,
203 struct lock_file *lf,
204 int flags);
206 int repo_read_index_preload(struct repository *,
207 const struct pathspec *pathspec,
208 unsigned refresh_flags);
209 int repo_read_index_unmerged(struct repository *);
211 * Opportunistically update the index but do not complain if we can't.
212 * The lockfile is always committed or rolled back.
214 void repo_update_index_if_able(struct repository *, struct lock_file *);
216 void prepare_repo_settings(struct repository *r);
219 * Return 1 if upgrade repository format to target_version succeeded,
220 * 0 if no upgrade is necessary, and -1 when upgrade is not possible.
222 int upgrade_repository_format(int target_version);
224 #endif /* REPOSITORY_H */