2 * Copyright (C) the libgit2 contributors. All rights reserved.
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.
7 #ifndef INCLUDE_git_types_h__
8 #define INCLUDE_git_types_h__
14 * @brief libgit2 base & compatibility types
21 * Cross-platform compatibility types for off_t / time_t
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.
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
31 * NOTE: These types should match those that are returned by our internal
32 * stat() functions, for all platforms.
34 #include <sys/types.h>
41 typedef __int64 git_off_t
;
42 typedef __time64_t git_time_t
;
44 #elif defined(__MINGW32__)
46 typedef off64_t git_off_t
;
47 typedef __time64_t git_time_t
;
49 #elif defined(__HAIKU__)
51 typedef __haiku_std_int64 git_off_t
;
52 typedef __haiku_std_int64 git_time_t
;
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.
61 typedef int64_t git_off_t
;
62 typedef int64_t git_time_t
;
66 /** Basic type (loose or packed) of any Git object. */
68 GIT_OBJ_ANY
= -2, /**< Object can be any of the following */
69 GIT_OBJ_BAD
= -1, /**< Object is invalid. */
70 GIT_OBJ__EXT1
= 0, /**< Reserved for future use. */
71 GIT_OBJ_COMMIT
= 1, /**< A commit object. */
72 GIT_OBJ_TREE
= 2, /**< A tree (directory listing) object. */
73 GIT_OBJ_BLOB
= 3, /**< A file revision object. */
74 GIT_OBJ_TAG
= 4, /**< An annotated tag object. */
75 GIT_OBJ__EXT2
= 5, /**< Reserved for future use. */
76 GIT_OBJ_OFS_DELTA
= 6, /**< A delta, base is given by an offset. */
77 GIT_OBJ_REF_DELTA
= 7, /**< A delta, base is given by object id. */
80 /** An open object database handle. */
81 typedef struct git_odb git_odb
;
83 /** A custom backend in an ODB */
84 typedef struct git_odb_backend git_odb_backend
;
86 /** An object read from the ODB */
87 typedef struct git_odb_object git_odb_object
;
89 /** A stream to read/write from the ODB */
90 typedef struct git_odb_stream git_odb_stream
;
92 /** A stream to write a packfile to the ODB */
93 typedef struct git_odb_writepack git_odb_writepack
;
95 /** An open refs database handle. */
96 typedef struct git_refdb git_refdb
;
98 /** A custom backend for refs */
99 typedef struct git_refdb_backend git_refdb_backend
;
102 * Representation of an existing git repository,
103 * including all its object contents
105 typedef struct git_repository git_repository
;
107 /** Representation of a generic object in a repository */
108 typedef struct git_object git_object
;
110 /** Representation of an in-progress walk through the commits in a repo */
111 typedef struct git_revwalk git_revwalk
;
113 /** Parsed representation of a tag object. */
114 typedef struct git_tag git_tag
;
116 /** In-memory representation of a blob object. */
117 typedef struct git_blob git_blob
;
119 /** Parsed representation of a commit object. */
120 typedef struct git_commit git_commit
;
122 /** Representation of each one of the entries in a tree object. */
123 typedef struct git_tree_entry git_tree_entry
;
125 /** Representation of a tree object. */
126 typedef struct git_tree git_tree
;
128 /** Constructor for in-memory trees */
129 typedef struct git_treebuilder git_treebuilder
;
131 /** Memory representation of an index file. */
132 typedef struct git_index git_index
;
134 /** An iterator for conflicts in the index. */
135 typedef struct git_index_conflict_iterator git_index_conflict_iterator
;
137 /** Memory representation of a set of config files */
138 typedef struct git_config git_config
;
140 /** Interface to access a configuration file */
141 typedef struct git_config_backend git_config_backend
;
143 /** Representation of a reference log entry */
144 typedef struct git_reflog_entry git_reflog_entry
;
146 /** Representation of a reference log */
147 typedef struct git_reflog git_reflog
;
149 /** Representation of a git note */
150 typedef struct git_note git_note
;
152 /** Representation of a git packbuilder */
153 typedef struct git_packbuilder git_packbuilder
;
155 /** Time in a signature */
156 typedef struct git_time
{
157 git_time_t time
; /**< time in seconds from epoch */
158 int offset
; /**< timezone offset, in minutes */
161 /** An action signature (e.g. for committers, taggers, etc) */
162 typedef struct git_signature
{
163 char *name
; /**< full name of the author */
164 char *email
; /**< email of the author */
165 git_time when
; /**< time when the action happened */
168 /** In-memory representation of a reference. */
169 typedef struct git_reference git_reference
;
171 /** Iterator for references */
172 typedef struct git_reference_iterator git_reference_iterator
;
174 /** Transactional interface to references */
175 typedef struct git_transaction git_transaction
;
177 /** Merge heads, the input to merge */
178 typedef struct git_merge_head git_merge_head
;
181 typedef struct git_merge_result git_merge_result
;
183 /** Representation of a status collection */
184 typedef struct git_status_list git_status_list
;
187 /** Basic type of any Git reference. */
189 GIT_REF_INVALID
= 0, /**< Invalid reference */
190 GIT_REF_OID
= 1, /**< A reference which points at an object id */
191 GIT_REF_SYMBOLIC
= 2, /**< A reference which points at another reference */
192 GIT_REF_LISTALL
= GIT_REF_OID
|GIT_REF_SYMBOLIC
,
195 /** Basic type of any Git branch. */
197 GIT_BRANCH_LOCAL
= 1,
198 GIT_BRANCH_REMOTE
= 2,
199 GIT_BRANCH_ALL
= GIT_BRANCH_LOCAL
|GIT_BRANCH_REMOTE
,
202 /** Valid modes for index and tree entries. */
204 GIT_FILEMODE_UNREADABLE
= 0000000,
205 GIT_FILEMODE_TREE
= 0040000,
206 GIT_FILEMODE_BLOB
= 0100644,
207 GIT_FILEMODE_BLOB_EXECUTABLE
= 0100755,
208 GIT_FILEMODE_LINK
= 0120000,
209 GIT_FILEMODE_COMMIT
= 0160000,
212 typedef struct git_refspec git_refspec
;
213 typedef struct git_remote git_remote
;
214 typedef struct git_push git_push
;
216 typedef struct git_remote_head git_remote_head
;
217 typedef struct git_remote_callbacks git_remote_callbacks
;
220 * This is passed as the first argument to the callback to allow the
221 * user to see the progress.
223 * - total_objects: number of objects in the packfile being downloaded
224 * - indexed_objects: received objects that have been hashed
225 * - received_objects: objects which have been downloaded
226 * - local_objects: locally-available objects that have been injected
227 * in order to fix a thin pack.
228 * - received-bytes: size of the packfile received up to now
230 typedef struct git_transfer_progress
{
231 unsigned int total_objects
;
232 unsigned int indexed_objects
;
233 unsigned int received_objects
;
234 unsigned int local_objects
;
235 unsigned int total_deltas
;
236 unsigned int indexed_deltas
;
237 size_t received_bytes
;
238 } git_transfer_progress
;
241 * Type for progress callbacks during indexing. Return a value less than zero
242 * to cancel the transfer.
244 * @param stats Structure containing information about the state of the transfer
245 * @param payload Payload provided by caller
247 typedef int (*git_transfer_progress_cb
)(const git_transfer_progress
*stats
, void *payload
);
250 * Type for messages delivered by the transport. Return a negative value
251 * to cancel the network operation.
253 * @param str The message from the transport
254 * @param len The length of the message
255 * @param payload Payload provided by the caller
257 typedef int (*git_transport_message_cb
)(const char *str
, int len
, void *payload
);
260 * Type of host certificate structure that is passed to the check callback
262 typedef enum git_cert_t
{
264 * The `data` argument to the callback will be a pointer to
265 * the DER-encoded data.
269 * The `data` argument to the callback will be a pointer to a
270 * `git_cert_hostkey` structure.
272 GIT_CERT_HOSTKEY_LIBSSH2
,
276 * Parent type for `git_cert_hostkey` and `git_cert_x509`.
280 * Type of certificate. A `GIT_CERT_` value.
282 git_cert_t cert_type
;
286 * Callback for the user's custom certificate checks.
288 * @param type The type of certificate or host info, SSH or X.509
289 * @param data The data for the certificate or host info
290 * @param len The size of the certificate or host info
291 * @param valid Whether the libgit2 checks (OpenSSL or WinHTTP) think
292 * this certificate is valid
293 * @param payload Payload provided by the caller
295 typedef int (*git_transport_certificate_check_cb
)(git_cert
*cert
, int valid
, void *payload
);
298 * Opaque structure representing a submodule.
300 typedef struct git_submodule git_submodule
;
303 * Submodule update values
305 * These values represent settings for the `submodule.$name.update`
306 * configuration value which says how to handle `git submodule update` for
307 * this submodule. The value is usually set in the ".gitmodules" file and
308 * copied to ".git/config" when the submodule is initialized.
310 * You can override this setting on a per-submodule basis with
311 * `git_submodule_set_update()` and write the changed value to disk using
312 * `git_submodule_save()`. If you have overwritten the value, you can
313 * revert it by passing `GIT_SUBMODULE_UPDATE_RESET` to the set function.
317 * - GIT_SUBMODULE_UPDATE_RESET: reset to the on-disk value.
318 * - GIT_SUBMODULE_UPDATE_CHECKOUT: the default; when a submodule is
319 * updated, checkout the new detached HEAD to the submodule directory.
320 * - GIT_SUBMODULE_UPDATE_REBASE: update by rebasing the current checked
321 * out branch onto the commit from the superproject.
322 * - GIT_SUBMODULE_UPDATE_MERGE: update by merging the commit in the
323 * superproject into the current checkout out branch of the submodule.
324 * - GIT_SUBMODULE_UPDATE_NONE: do not update this submodule even when
325 * the commit in the superproject is updated.
326 * - GIT_SUBMODULE_UPDATE_DEFAULT: not used except as static initializer
327 * when we don't want any particular update rule to be specified.
330 GIT_SUBMODULE_UPDATE_RESET
= -1,
332 GIT_SUBMODULE_UPDATE_CHECKOUT
= 1,
333 GIT_SUBMODULE_UPDATE_REBASE
= 2,
334 GIT_SUBMODULE_UPDATE_MERGE
= 3,
335 GIT_SUBMODULE_UPDATE_NONE
= 4,
337 GIT_SUBMODULE_UPDATE_DEFAULT
= 0
338 } git_submodule_update_t
;
341 * Submodule ignore values
343 * These values represent settings for the `submodule.$name.ignore`
344 * configuration value which says how deeply to look at the working
345 * directory when getting submodule status.
347 * You can override this value in memory on a per-submodule basis with
348 * `git_submodule_set_ignore()` and can write the changed value to disk
349 * with `git_submodule_save()`. If you have overwritten the value, you
350 * can revert to the on disk value by using `GIT_SUBMODULE_IGNORE_RESET`.
354 * - GIT_SUBMODULE_IGNORE_RESET: reset to the on-disk value.
355 * - GIT_SUBMODULE_IGNORE_NONE: don't ignore any change - i.e. even an
356 * untracked file, will mark the submodule as dirty. Ignored files are
357 * still ignored, of course.
358 * - GIT_SUBMODULE_IGNORE_UNTRACKED: ignore untracked files; only changes
359 * to tracked files, or the index or the HEAD commit will matter.
360 * - GIT_SUBMODULE_IGNORE_DIRTY: ignore changes in the working directory,
361 * only considering changes if the HEAD of submodule has moved from the
362 * value in the superproject.
363 * - GIT_SUBMODULE_IGNORE_ALL: never check if the submodule is dirty
364 * - GIT_SUBMODULE_IGNORE_DEFAULT: not used except as static initializer
365 * when we don't want any particular ignore rule to be specified.
368 GIT_SUBMODULE_IGNORE_RESET
= -1, /**< reset to on-disk value */
370 GIT_SUBMODULE_IGNORE_NONE
= 1, /**< any change or untracked == dirty */
371 GIT_SUBMODULE_IGNORE_UNTRACKED
= 2, /**< dirty if tracked files change */
372 GIT_SUBMODULE_IGNORE_DIRTY
= 3, /**< only dirty if HEAD moved */
373 GIT_SUBMODULE_IGNORE_ALL
= 4, /**< never dirty */
375 GIT_SUBMODULE_IGNORE_DEFAULT
= 0
376 } git_submodule_ignore_t
;
379 * Options for submodule recurse.
381 * Represent the value of `submodule.$name.fetchRecurseSubmodules`
383 * * GIT_SUBMODULE_RECURSE_RESET - reset to the on-disk value
384 * * GIT_SUBMODULE_RECURSE_NO - do no recurse into submodules
385 * * GIT_SUBMODULE_RECURSE_YES - recurse into submodules
386 * * GIT_SUBMODULE_RECURSE_ONDEMAND - recurse into submodules only when
387 * commit not already in local clone
390 GIT_SUBMODULE_RECURSE_RESET
= -1,
392 GIT_SUBMODULE_RECURSE_NO
= 0,
393 GIT_SUBMODULE_RECURSE_YES
= 1,
394 GIT_SUBMODULE_RECURSE_ONDEMAND
= 2,
395 } git_submodule_recurse_t
;