]>
Commit | Line | Data |
---|---|---|
359efeff BW |
1 | #ifndef REPOSITORY_H |
2 | #define REPOSITORY_H | |
3 | ||
3b256228 | 4 | struct config_set; |
1e0ea5c4 | 5 | struct fsmonitor_settings; |
90c62155 | 6 | struct git_hash_algo; |
639e30b5 | 7 | struct index_state; |
3a95f31d | 8 | struct lock_file; |
e1ff0a32 | 9 | struct pathspec; |
90c62155 | 10 | struct raw_object_store; |
bf12fcdf | 11 | struct submodule_cache; |
ef7dc2e9 | 12 | struct promisor_remote_config; |
fd3cb050 | 13 | struct remote_state; |
3b256228 | 14 | |
ad0fb659 | 15 | enum untracked_cache_setting { |
3050b6df ÆAB |
16 | UNTRACKED_CACHE_KEEP, |
17 | UNTRACKED_CACHE_REMOVE, | |
18 | UNTRACKED_CACHE_WRITE, | |
ad0fb659 DS |
19 | }; |
20 | ||
aaf633c2 | 21 | enum fetch_negotiation_setting { |
714edc62 | 22 | FETCH_NEGOTIATION_CONSECUTIVE, |
3050b6df ÆAB |
23 | FETCH_NEGOTIATION_SKIPPING, |
24 | FETCH_NEGOTIATION_NOOP, | |
aaf633c2 DS |
25 | }; |
26 | ||
7211b9e7 DS |
27 | struct repo_settings { |
28 | int initialized; | |
29 | ||
30 | int core_commit_graph; | |
a92d8523 | 31 | int commit_graph_generation_version; |
b66d8475 | 32 | int commit_graph_read_changed_paths; |
7211b9e7 | 33 | int gc_write_commit_graph; |
50f26bd0 | 34 | int fetch_write_commit_graph; |
c21919f1 ÆAB |
35 | int command_requires_full_index; |
36 | int sparse_index; | |
dbcf6116 | 37 | int pack_read_reverse_index; |
b0afdce5 | 38 | int pack_use_bitmap_boundary_traversal; |
7211b9e7 | 39 | |
9c7d1b05 DS |
40 | /* |
41 | * Does this repository have core.useReplaceRefs=true (on by | |
42 | * default)? This provides a repository-scoped version of this | |
43 | * config, though it could be disabled process-wide via some Git | |
44 | * builtins or the --no-replace-objects option. See | |
45 | * replace_refs_enabled() for more details. | |
46 | */ | |
47 | int read_replace_refs; | |
48 | ||
1e0ea5c4 JH |
49 | struct fsmonitor_settings *fsmonitor; /* lazily loaded */ |
50 | ||
7211b9e7 | 51 | int index_version; |
17194b19 | 52 | int index_skip_hash; |
ad0fb659 | 53 | enum untracked_cache_setting core_untracked_cache; |
7211b9e7 DS |
54 | |
55 | int pack_use_sparse; | |
aaf633c2 | 56 | enum fetch_negotiation_setting fetch_negotiation_algorithm; |
18e449f8 DS |
57 | |
58 | int core_multi_pack_index; | |
7211b9e7 DS |
59 | }; |
60 | ||
759f3407 ÆAB |
61 | struct repo_path_cache { |
62 | char *squash_msg; | |
63 | char *merge_msg; | |
64 | char *merge_rr; | |
65 | char *merge_mode; | |
66 | char *merge_head; | |
67 | char *merge_autostash; | |
68 | char *auto_merge; | |
69 | char *fetch_head; | |
70 | char *shallow; | |
71 | }; | |
72 | ||
359efeff BW |
73 | struct repository { |
74 | /* Environment */ | |
75 | /* | |
76 | * Path to the git directory. | |
77 | * Cannot be NULL after initialization. | |
78 | */ | |
79 | char *gitdir; | |
80 | ||
81 | /* | |
82 | * Path to the common git directory. | |
83 | * Cannot be NULL after initialization. | |
84 | */ | |
85 | char *commondir; | |
86 | ||
87 | /* | |
90c62155 | 88 | * Holds any information related to accessing the raw object content. |
359efeff | 89 | */ |
90c62155 | 90 | struct raw_object_store *objects; |
7bc0dcaa | 91 | |
99bf115c SB |
92 | /* |
93 | * All objects in this repository that have been parsed. This structure | |
94 | * owns all objects it references, so users of "struct object *" | |
95 | * generally do not need to free them; instead, when a repository is no | |
96 | * longer used, call parsed_object_pool_clear() on this structure, which | |
97 | * is called by the repositories repo_clear on its desconstruction. | |
98 | */ | |
99 | struct parsed_object_pool *parsed_objects; | |
100 | ||
02204610 JK |
101 | /* |
102 | * The store in which the refs are held. This should generally only be | |
103 | * accessed via get_main_ref_store(), as that will lazily initialize | |
104 | * the ref object. | |
105 | */ | |
106 | struct ref_store *refs_private; | |
64a74161 | 107 | |
102de880 SB |
108 | /* |
109 | * Contains path to often used file names. | |
110 | */ | |
759f3407 | 111 | struct repo_path_cache cached_paths; |
102de880 | 112 | |
359efeff BW |
113 | /* |
114 | * Path to the repository's graft file. | |
115 | * Cannot be NULL after initialization. | |
116 | */ | |
117 | char *graft_file; | |
118 | ||
119 | /* | |
120 | * Path to the current worktree's index file. | |
121 | * Cannot be NULL after initialization. | |
122 | */ | |
123 | char *index_file; | |
124 | ||
125 | /* | |
126 | * Path to the working directory. | |
127 | * A NULL value indicates that there is no working directory. | |
128 | */ | |
129 | char *worktree; | |
130 | ||
96dc883b BW |
131 | /* |
132 | * Path from the root of the top-level superproject down to this | |
133 | * repository. This is only non-NULL if the repository is initialized | |
134 | * as a submodule of another repository. | |
135 | */ | |
136 | char *submodule_prefix; | |
137 | ||
7211b9e7 DS |
138 | struct repo_settings settings; |
139 | ||
3b256228 BW |
140 | /* Subsystems */ |
141 | /* | |
142 | * Repository's config which contains key-value pairs from the usual | |
143 | * set of config files (i.e. repo specific .git/config, user wide | |
144 | * ~/.gitconfig, XDG config file and the global /etc/gitconfig) | |
145 | */ | |
146 | struct config_set *config; | |
147 | ||
bf12fcdf BW |
148 | /* Repository's submodule config as defined by '.gitmodules' */ |
149 | struct submodule_cache *submodule_cache; | |
150 | ||
639e30b5 BW |
151 | /* |
152 | * Repository's in-memory index. | |
153 | * 'repo_read_index()' can be used to populate 'index'. | |
154 | */ | |
155 | struct index_state *index; | |
156 | ||
fd3cb050 GC |
157 | /* Repository's remotes and associated structures. */ |
158 | struct remote_state *remote_state; | |
159 | ||
78a67668 | 160 | /* Repository's current hash algorithm, as serialized on disk. */ |
161 | const struct git_hash_algo *hash_algo; | |
162 | ||
ee4512ed JH |
163 | /* A unique-id for tracing purposes. */ |
164 | int trace2_repo_id; | |
165 | ||
6abada18 JK |
166 | /* True if commit-graph has been disabled within this process. */ |
167 | int commit_graph_disabled; | |
168 | ||
ebaf3bcf JT |
169 | /* Configurations related to promisor remotes. */ |
170 | char *repository_format_partial_clone; | |
ef7dc2e9 | 171 | struct promisor_remote_config *promisor_remote_config; |
ebaf3bcf | 172 | |
359efeff | 173 | /* Configurations */ |
3867f6d6 | 174 | int repository_format_worktree_config; |
359efeff BW |
175 | |
176 | /* Indicate if a repository has a different 'commondir' from 'gitdir' */ | |
177 | unsigned different_commondir:1; | |
178 | }; | |
179 | ||
180 | extern struct repository *the_repository; | |
bc47f16d EN |
181 | #ifdef USE_THE_INDEX_VARIABLE |
182 | extern struct index_state the_index; | |
183 | #endif | |
359efeff | 184 | |
00a3da2a NTND |
185 | /* |
186 | * Define a custom repository layout. Any field can be NULL, which | |
187 | * will default back to the path according to the default layout. | |
188 | */ | |
357a03eb NTND |
189 | struct set_gitdir_args { |
190 | const char *commondir; | |
191 | const char *object_dir; | |
192 | const char *graft_file; | |
193 | const char *index_file; | |
7bc0dcaa | 194 | const char *alternate_db; |
ecd81dfc | 195 | int disable_ref_updates; |
357a03eb NTND |
196 | }; |
197 | ||
c2ec4175 NTND |
198 | void repo_set_gitdir(struct repository *repo, const char *root, |
199 | const struct set_gitdir_args *extra_args); | |
200 | void repo_set_worktree(struct repository *repo, const char *path); | |
201 | void repo_set_hash_algo(struct repository *repo, int algo); | |
202 | void initialize_the_repository(void); | |
1e8697b5 | 203 | RESULT_MUST_BE_USED |
c2ec4175 | 204 | int repo_init(struct repository *r, const char *gitdir, const char *worktree); |
d5498e08 SB |
205 | |
206 | /* | |
8eb8dcf9 JT |
207 | * Initialize the repository 'subrepo' as the submodule at the given path. If |
208 | * the submodule's gitdir cannot be found at <path>/.git, this function calls | |
209 | * submodule_from_path() to try to find it. treeish_name is only used if | |
210 | * submodule_from_path() needs to be called; see its documentation for more | |
211 | * information. | |
212 | * Return 0 upon success and a non-zero value upon failure. | |
d5498e08 | 213 | */ |
8eb8dcf9 | 214 | struct object_id; |
1e8697b5 | 215 | RESULT_MUST_BE_USED |
d5498e08 | 216 | int repo_submodule_init(struct repository *subrepo, |
c2ec4175 | 217 | struct repository *superproject, |
8eb8dcf9 JT |
218 | const char *path, |
219 | const struct object_id *treeish_name); | |
c2ec4175 | 220 | void repo_clear(struct repository *repo); |
359efeff | 221 | |
3f138775 BW |
222 | /* |
223 | * Populates the repository's index from its index_file, an index struct will | |
224 | * be allocated if needed. | |
225 | * | |
226 | * Return the number of index entries in the populated index or a value less | |
15beaaa3 | 227 | * than zero if an error occurred. If the repository's index has already been |
3f138775 BW |
228 | * populated then the number of entries will simply be returned. |
229 | */ | |
c2ec4175 | 230 | int repo_read_index(struct repository *repo); |
3a95f31d NTND |
231 | int repo_hold_locked_index(struct repository *repo, |
232 | struct lock_file *lf, | |
233 | int flags); | |
639e30b5 | 234 | |
e1ff0a32 | 235 | int repo_read_index_unmerged(struct repository *); |
1b0d968b NTND |
236 | /* |
237 | * Opportunistically update the index but do not complain if we can't. | |
238 | * The lockfile is always committed or rolled back. | |
239 | */ | |
240 | void repo_update_index_if_able(struct repository *, struct lock_file *); | |
241 | ||
7211b9e7 | 242 | void prepare_repo_settings(struct repository *r); |
639e30b5 | 243 | |
16af5f1a XL |
244 | /* |
245 | * Return 1 if upgrade repository format to target_version succeeded, | |
246 | * 0 if no upgrade is necessary, and -1 when upgrade is not possible. | |
247 | */ | |
248 | int upgrade_repository_format(int target_version); | |
249 | ||
359efeff | 250 | #endif /* REPOSITORY_H */ |