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