]>
Commit | Line | Data |
---|---|---|
f5918330 | 1 | /* |
359fc2d2 | 2 | * Copyright (C) the libgit2 contributors. All rights reserved. |
f5918330 | 3 | * |
bb742ede VM |
4 | * This file is part of libgit2, distributed under the GNU GPL v2 with |
5 | * a Linking Exception. For full terms see the included COPYING file. | |
f5918330 | 6 | */ |
d12299fe VM |
7 | #ifndef INCLUDE_git_types_h__ |
8 | #define INCLUDE_git_types_h__ | |
9 | ||
b2e60e4e VM |
10 | #include "common.h" |
11 | ||
d12299fe | 12 | /** |
f5918330 | 13 | * @file git2/types.h |
e52e38d3 | 14 | * @brief libgit2 base & compatibility types |
d12299fe VM |
15 | * @ingroup Git |
16 | * @{ | |
17 | */ | |
18 | GIT_BEGIN_DECL | |
19 | ||
e52e38d3 VM |
20 | /** |
21 | * Cross-platform compatibility types for off_t / time_t | |
22 | * | |
23 | * NOTE: This needs to be in a public header so that both the library | |
24 | * implementation and client applications both agree on the same types. | |
25 | * Otherwise we get undefined behavior. | |
26 | * | |
27 | * Use the "best" types that each platform provides. Currently we truncate | |
28 | * these intermediate representations for compatibility with the git ABI, but | |
29 | * if and when it changes to support 64 bit types, our code will naturally | |
30 | * adapt. | |
31 | * NOTE: These types should match those that are returned by our internal | |
32 | * stat() functions, for all platforms. | |
33 | */ | |
37c2d54c | 34 | #include <sys/types.h> |
d0517805 CY |
35 | #ifdef __amigaos4__ |
36 | #include <stdint.h> | |
37 | #endif | |
37c2d54c | 38 | |
e52e38d3 VM |
39 | #if defined(_MSC_VER) |
40 | ||
41 | typedef __int64 git_off_t; | |
87d9869f | 42 | typedef __time64_t git_time_t; |
e52e38d3 VM |
43 | |
44 | #elif defined(__MINGW32__) | |
45 | ||
46 | typedef off64_t git_off_t; | |
7c80c19e | 47 | typedef __time64_t git_time_t; |
e52e38d3 | 48 | |
2c0ec236 | 49 | #elif defined(__HAIKU__) |
e52e38d3 | 50 | |
2c0ec236 AS |
51 | typedef __haiku_std_int64 git_off_t; |
52 | typedef __haiku_std_int64 git_time_t; | |
53 | ||
87d9869f | 54 | #else /* POSIX */ |
e52e38d3 | 55 | |
932d1baf | 56 | /* |
e52e38d3 VM |
57 | * Note: Can't use off_t since if a client program includes <sys/types.h> |
58 | * before us (directly or indirectly), they'll get 32 bit off_t in their client | |
59 | * app, even though /we/ define _FILE_OFFSET_BITS=64. | |
60 | */ | |
56d8ca26 | 61 | typedef int64_t git_off_t; |
ac3d33df | 62 | typedef int64_t git_time_t; /**< time in seconds from epoch */ |
e52e38d3 VM |
63 | |
64 | #endif | |
65 | ||
22a2d3d5 UG |
66 | /** The maximum size of an object */ |
67 | typedef uint64_t git_object_size_t; | |
68 | ||
ac3d33df JK |
69 | #include "buffer.h" |
70 | #include "oid.h" | |
71 | ||
d12299fe VM |
72 | /** Basic type (loose or packed) of any Git object. */ |
73 | typedef enum { | |
ac3d33df JK |
74 | GIT_OBJECT_ANY = -2, /**< Object can be any of the following */ |
75 | GIT_OBJECT_INVALID = -1, /**< Object is invalid. */ | |
76 | GIT_OBJECT_COMMIT = 1, /**< A commit object. */ | |
77 | GIT_OBJECT_TREE = 2, /**< A tree (directory listing) object. */ | |
78 | GIT_OBJECT_BLOB = 3, /**< A file revision object. */ | |
79 | GIT_OBJECT_TAG = 4, /**< An annotated tag object. */ | |
80 | GIT_OBJECT_OFS_DELTA = 6, /**< A delta, base is given by an offset. */ | |
e579e0f7 | 81 | GIT_OBJECT_REF_DELTA = 7 /**< A delta, base is given by object id. */ |
ac3d33df | 82 | } git_object_t; |
d12299fe VM |
83 | |
84 | /** An open object database handle. */ | |
85 | typedef struct git_odb git_odb; | |
86 | ||
87 | /** A custom backend in an ODB */ | |
88 | typedef struct git_odb_backend git_odb_backend; | |
89 | ||
72a3fe42 VM |
90 | /** An object read from the ODB */ |
91 | typedef struct git_odb_object git_odb_object; | |
92 | ||
93 | /** A stream to read/write from the ODB */ | |
94 | typedef struct git_odb_stream git_odb_stream; | |
95 | ||
09cc0b92 ET |
96 | /** A stream to write a packfile to the ODB */ |
97 | typedef struct git_odb_writepack git_odb_writepack; | |
98 | ||
c25aa7cd PP |
99 | /** a writer for multi-pack-index files. */ |
100 | typedef struct git_midx_writer git_midx_writer; | |
101 | ||
d00d5464 ET |
102 | /** An open refs database handle. */ |
103 | typedef struct git_refdb git_refdb; | |
104 | ||
105 | /** A custom backend for refs */ | |
106 | typedef struct git_refdb_backend git_refdb_backend; | |
107 | ||
c25aa7cd PP |
108 | /** A git commit-graph */ |
109 | typedef struct git_commit_graph git_commit_graph; | |
110 | ||
111 | /** a writer for commit-graph files. */ | |
112 | typedef struct git_commit_graph_writer git_commit_graph_writer; | |
113 | ||
d12299fe VM |
114 | /** |
115 | * Representation of an existing git repository, | |
116 | * including all its object contents | |
117 | */ | |
118 | typedef struct git_repository git_repository; | |
119 | ||
d3bc09e8 PS |
120 | /** Representation of a working tree */ |
121 | typedef struct git_worktree git_worktree; | |
122 | ||
d12299fe VM |
123 | /** Representation of a generic object in a repository */ |
124 | typedef struct git_object git_object; | |
125 | ||
e52e38d3 | 126 | /** Representation of an in-progress walk through the commits in a repo */ |
d12299fe VM |
127 | typedef struct git_revwalk git_revwalk; |
128 | ||
129 | /** Parsed representation of a tag object. */ | |
130 | typedef struct git_tag git_tag; | |
131 | ||
132 | /** In-memory representation of a blob object. */ | |
133 | typedef struct git_blob git_blob; | |
134 | ||
135 | /** Parsed representation of a commit object. */ | |
136 | typedef struct git_commit git_commit; | |
137 | ||
138 | /** Representation of each one of the entries in a tree object. */ | |
139 | typedef struct git_tree_entry git_tree_entry; | |
140 | ||
141 | /** Representation of a tree object. */ | |
142 | typedef struct git_tree git_tree; | |
143 | ||
0ad6efa1 VM |
144 | /** Constructor for in-memory trees */ |
145 | typedef struct git_treebuilder git_treebuilder; | |
146 | ||
d12299fe VM |
147 | /** Memory representation of an index file. */ |
148 | typedef struct git_index git_index; | |
149 | ||
ac3d33df JK |
150 | /** An iterator for entries in the index. */ |
151 | typedef struct git_index_iterator git_index_iterator; | |
152 | ||
e7f89b46 | 153 | /** An iterator for conflicts in the index. */ |
0e0108f7 ET |
154 | typedef struct git_index_conflict_iterator git_index_conflict_iterator; |
155 | ||
b0b527e0 | 156 | /** Memory representation of a set of config files */ |
5d4cd003 CMN |
157 | typedef struct git_config git_config; |
158 | ||
b0b527e0 | 159 | /** Interface to access a configuration file */ |
54b2a37a | 160 | typedef struct git_config_backend git_config_backend; |
c0335005 | 161 | |
27df4275 MS |
162 | /** Representation of a reference log entry */ |
163 | typedef struct git_reflog_entry git_reflog_entry; | |
164 | ||
165 | /** Representation of a reference log */ | |
166 | typedef struct git_reflog git_reflog; | |
167 | ||
bf477ed4 MS |
168 | /** Representation of a git note */ |
169 | typedef struct git_note git_note; | |
170 | ||
0a32dca5 MS |
171 | /** Representation of a git packbuilder */ |
172 | typedef struct git_packbuilder git_packbuilder; | |
173 | ||
638c2ca4 VM |
174 | /** Time in a signature */ |
175 | typedef struct git_time { | |
11e2665e CMN |
176 | git_time_t time; /**< time in seconds from epoch */ |
177 | int offset; /**< timezone offset, in minutes */ | |
eae0bfdc | 178 | char sign; /**< indicator for questionable '-0000' offsets in signature */ |
638c2ca4 VM |
179 | } git_time; |
180 | ||
181 | /** An action signature (e.g. for committers, taggers, etc) */ | |
182 | typedef struct git_signature { | |
11e2665e CMN |
183 | char *name; /**< full name of the author */ |
184 | char *email; /**< email of the author */ | |
185 | git_time when; /**< time when the action happened */ | |
638c2ca4 VM |
186 | } git_signature; |
187 | ||
9282e921 | 188 | /** In-memory representation of a reference. */ |
189 | typedef struct git_reference git_reference; | |
190 | ||
4def7035 CMN |
191 | /** Iterator for references */ |
192 | typedef struct git_reference_iterator git_reference_iterator; | |
193 | ||
ab8d9242 CMN |
194 | /** Transactional interface to references */ |
195 | typedef struct git_transaction git_transaction; | |
196 | ||
18b00406 ET |
197 | /** Annotated commits, the input to merge and rebase. */ |
198 | typedef struct git_annotated_commit git_annotated_commit; | |
9c06b250 | 199 | |
1ee2ef87 ET |
200 | /** Representation of a status collection */ |
201 | typedef struct git_status_list git_status_list; | |
202 | ||
b6b636a7 ET |
203 | /** Representation of a rebase */ |
204 | typedef struct git_rebase git_rebase; | |
4def7035 | 205 | |
9282e921 | 206 | /** Basic type of any Git reference. */ |
207 | typedef enum { | |
ac3d33df JK |
208 | GIT_REFERENCE_INVALID = 0, /**< Invalid reference */ |
209 | GIT_REFERENCE_DIRECT = 1, /**< A reference that points at an object id */ | |
210 | GIT_REFERENCE_SYMBOLIC = 2, /**< A reference that points at another reference */ | |
e579e0f7 | 211 | GIT_REFERENCE_ALL = GIT_REFERENCE_DIRECT | GIT_REFERENCE_SYMBOLIC |
ac3d33df | 212 | } git_reference_t; |
9282e921 | 213 | |
731df570 | 214 | /** Basic type of any Git branch. */ |
215 | typedef enum { | |
216 | GIT_BRANCH_LOCAL = 1, | |
217 | GIT_BRANCH_REMOTE = 2, | |
e579e0f7 | 218 | GIT_BRANCH_ALL = GIT_BRANCH_LOCAL|GIT_BRANCH_REMOTE |
2e2e9785 | 219 | } git_branch_t; |
8f866dae | 220 | |
d854d59e | 221 | /** Valid modes for index and tree entries. */ |
222 | typedef enum { | |
9e2d2f30 AR |
223 | GIT_FILEMODE_UNREADABLE = 0000000, |
224 | GIT_FILEMODE_TREE = 0040000, | |
225 | GIT_FILEMODE_BLOB = 0100644, | |
226 | GIT_FILEMODE_BLOB_EXECUTABLE = 0100755, | |
227 | GIT_FILEMODE_LINK = 0120000, | |
e579e0f7 | 228 | GIT_FILEMODE_COMMIT = 0160000 |
d854d59e | 229 | } git_filemode_t; |
230 | ||
ac3d33df | 231 | /** |
12e18031 CMN |
232 | * A refspec specifies the mapping between remote and local reference |
233 | * names when fetch or pushing. | |
234 | */ | |
9c82357b | 235 | typedef struct git_refspec git_refspec; |
12e18031 CMN |
236 | |
237 | /** | |
238 | * Git's idea of a remote repository. A remote can be anonymous (in | |
e579e0f7 | 239 | * which case it does not have backing configuration entries). |
12e18031 | 240 | */ |
9c82357b | 241 | typedef struct git_remote git_remote; |
12e18031 | 242 | |
058b753c CMN |
243 | /** |
244 | * Interface which represents a transport to communicate with a | |
245 | * remote. | |
246 | */ | |
247 | typedef struct git_transport git_transport; | |
248 | ||
12e18031 CMN |
249 | /** |
250 | * Preparation for a push operation. Can be used to configure what to | |
251 | * push and the level of parallelism of the packfile builder. | |
252 | */ | |
613d5eb9 | 253 | typedef struct git_push git_push; |
9c82357b | 254 | |
12e18031 | 255 | /* documentation in the definition */ |
d6258deb | 256 | typedef struct git_remote_head git_remote_head; |
b3aaa7a7 | 257 | typedef struct git_remote_callbacks git_remote_callbacks; |
9282e921 | 258 | |
0782fc43 CMN |
259 | /** |
260 | * Parent type for `git_cert_hostkey` and `git_cert_x509`. | |
261 | */ | |
22a2d3d5 | 262 | typedef struct git_cert git_cert; |
9b940586 | 263 | |
f9775a37 RB |
264 | /** |
265 | * Opaque structure representing a submodule. | |
266 | */ | |
267 | typedef struct git_submodule git_submodule; | |
268 | ||
269 | /** | |
9b7d02ff | 270 | * Submodule update values |
f9775a37 | 271 | * |
9b7d02ff RB |
272 | * These values represent settings for the `submodule.$name.update` |
273 | * configuration value which says how to handle `git submodule update` for | |
274 | * this submodule. The value is usually set in the ".gitmodules" file and | |
275 | * copied to ".git/config" when the submodule is initialized. | |
276 | * | |
277 | * You can override this setting on a per-submodule basis with | |
278 | * `git_submodule_set_update()` and write the changed value to disk using | |
279 | * `git_submodule_save()`. If you have overwritten the value, you can | |
280 | * revert it by passing `GIT_SUBMODULE_UPDATE_RESET` to the set function. | |
281 | * | |
282 | * The values are: | |
283 | * | |
9b7d02ff RB |
284 | * - GIT_SUBMODULE_UPDATE_CHECKOUT: the default; when a submodule is |
285 | * updated, checkout the new detached HEAD to the submodule directory. | |
286 | * - GIT_SUBMODULE_UPDATE_REBASE: update by rebasing the current checked | |
287 | * out branch onto the commit from the superproject. | |
288 | * - GIT_SUBMODULE_UPDATE_MERGE: update by merging the commit in the | |
289 | * superproject into the current checkout out branch of the submodule. | |
290 | * - GIT_SUBMODULE_UPDATE_NONE: do not update this submodule even when | |
291 | * the commit in the superproject is updated. | |
a5c16f3c RB |
292 | * - GIT_SUBMODULE_UPDATE_DEFAULT: not used except as static initializer |
293 | * when we don't want any particular update rule to be specified. | |
f9775a37 RB |
294 | */ |
295 | typedef enum { | |
f9775a37 | 296 | GIT_SUBMODULE_UPDATE_CHECKOUT = 1, |
a5c16f3c RB |
297 | GIT_SUBMODULE_UPDATE_REBASE = 2, |
298 | GIT_SUBMODULE_UPDATE_MERGE = 3, | |
299 | GIT_SUBMODULE_UPDATE_NONE = 4, | |
300 | ||
301 | GIT_SUBMODULE_UPDATE_DEFAULT = 0 | |
f9775a37 RB |
302 | } git_submodule_update_t; |
303 | ||
304 | /** | |
9b7d02ff RB |
305 | * Submodule ignore values |
306 | * | |
307 | * These values represent settings for the `submodule.$name.ignore` | |
308 | * configuration value which says how deeply to look at the working | |
309 | * directory when getting submodule status. | |
310 | * | |
311 | * You can override this value in memory on a per-submodule basis with | |
312 | * `git_submodule_set_ignore()` and can write the changed value to disk | |
313 | * with `git_submodule_save()`. If you have overwritten the value, you | |
314 | * can revert to the on disk value by using `GIT_SUBMODULE_IGNORE_RESET`. | |
315 | * | |
316 | * The values are: | |
f9775a37 | 317 | * |
c2418f46 | 318 | * - GIT_SUBMODULE_IGNORE_UNSPECIFIED: use the submodule's configuration |
9b7d02ff RB |
319 | * - GIT_SUBMODULE_IGNORE_NONE: don't ignore any change - i.e. even an |
320 | * untracked file, will mark the submodule as dirty. Ignored files are | |
321 | * still ignored, of course. | |
322 | * - GIT_SUBMODULE_IGNORE_UNTRACKED: ignore untracked files; only changes | |
323 | * to tracked files, or the index or the HEAD commit will matter. | |
324 | * - GIT_SUBMODULE_IGNORE_DIRTY: ignore changes in the working directory, | |
325 | * only considering changes if the HEAD of submodule has moved from the | |
326 | * value in the superproject. | |
327 | * - GIT_SUBMODULE_IGNORE_ALL: never check if the submodule is dirty | |
a5c16f3c RB |
328 | * - GIT_SUBMODULE_IGNORE_DEFAULT: not used except as static initializer |
329 | * when we don't want any particular ignore rule to be specified. | |
f9775a37 RB |
330 | */ |
331 | typedef enum { | |
c2418f46 | 332 | GIT_SUBMODULE_IGNORE_UNSPECIFIED = -1, /**< use the submodule's configuration */ |
a5c16f3c | 333 | |
11e2665e CMN |
334 | GIT_SUBMODULE_IGNORE_NONE = 1, /**< any change or untracked == dirty */ |
335 | GIT_SUBMODULE_IGNORE_UNTRACKED = 2, /**< dirty if tracked files change */ | |
336 | GIT_SUBMODULE_IGNORE_DIRTY = 3, /**< only dirty if HEAD moved */ | |
e579e0f7 | 337 | GIT_SUBMODULE_IGNORE_ALL = 4 /**< never dirty */ |
f9775a37 RB |
338 | } git_submodule_ignore_t; |
339 | ||
c0644c3f RB |
340 | /** |
341 | * Options for submodule recurse. | |
342 | * | |
343 | * Represent the value of `submodule.$name.fetchRecurseSubmodules` | |
344 | * | |
c0644c3f RB |
345 | * * GIT_SUBMODULE_RECURSE_NO - do no recurse into submodules |
346 | * * GIT_SUBMODULE_RECURSE_YES - recurse into submodules | |
347 | * * GIT_SUBMODULE_RECURSE_ONDEMAND - recurse into submodules only when | |
348 | * commit not already in local clone | |
349 | */ | |
350 | typedef enum { | |
c0644c3f RB |
351 | GIT_SUBMODULE_RECURSE_NO = 0, |
352 | GIT_SUBMODULE_RECURSE_YES = 1, | |
e579e0f7 | 353 | GIT_SUBMODULE_RECURSE_ONDEMAND = 2 |
c0644c3f RB |
354 | } git_submodule_recurse_t; |
355 | ||
b75f15aa ET |
356 | typedef struct git_writestream git_writestream; |
357 | ||
ac3d33df | 358 | /** A type to write in a streaming fashion, for example, for filters. */ |
b75f15aa | 359 | struct git_writestream { |
ac3d33df JK |
360 | int GIT_CALLBACK(write)(git_writestream *stream, const char *buffer, size_t len); |
361 | int GIT_CALLBACK(close)(git_writestream *stream); | |
362 | void GIT_CALLBACK(free)(git_writestream *stream); | |
b75f15aa | 363 | }; |
fbdc9db3 | 364 | |
ac3d33df JK |
365 | /** Representation of .mailmap file state. */ |
366 | typedef struct git_mailmap git_mailmap; | |
367 | ||
d12299fe VM |
368 | /** @} */ |
369 | GIT_END_DECL | |
370 | ||
371 | #endif |