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
; /**< time in seconds from epoch */
66 /** The maximum size of an object */
67 typedef uint64_t git_object_size_t
;
72 /** Basic type (loose or packed) of any Git object. */
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. */
81 GIT_OBJECT_REF_DELTA
= 7 /**< A delta, base is given by object id. */
84 /** An open object database handle. */
85 typedef struct git_odb git_odb
;
87 /** A custom backend in an ODB */
88 typedef struct git_odb_backend git_odb_backend
;
90 /** An object read from the ODB */
91 typedef struct git_odb_object git_odb_object
;
93 /** A stream to read/write from the ODB */
94 typedef struct git_odb_stream git_odb_stream
;
96 /** A stream to write a packfile to the ODB */
97 typedef struct git_odb_writepack git_odb_writepack
;
99 /** a writer for multi-pack-index files. */
100 typedef struct git_midx_writer git_midx_writer
;
102 /** An open refs database handle. */
103 typedef struct git_refdb git_refdb
;
105 /** A custom backend for refs */
106 typedef struct git_refdb_backend git_refdb_backend
;
108 /** A git commit-graph */
109 typedef struct git_commit_graph git_commit_graph
;
111 /** a writer for commit-graph files. */
112 typedef struct git_commit_graph_writer git_commit_graph_writer
;
115 * Representation of an existing git repository,
116 * including all its object contents
118 typedef struct git_repository git_repository
;
120 /** Representation of a working tree */
121 typedef struct git_worktree git_worktree
;
123 /** Representation of a generic object in a repository */
124 typedef struct git_object git_object
;
126 /** Representation of an in-progress walk through the commits in a repo */
127 typedef struct git_revwalk git_revwalk
;
129 /** Parsed representation of a tag object. */
130 typedef struct git_tag git_tag
;
132 /** In-memory representation of a blob object. */
133 typedef struct git_blob git_blob
;
135 /** Parsed representation of a commit object. */
136 typedef struct git_commit git_commit
;
138 /** Representation of each one of the entries in a tree object. */
139 typedef struct git_tree_entry git_tree_entry
;
141 /** Representation of a tree object. */
142 typedef struct git_tree git_tree
;
144 /** Constructor for in-memory trees */
145 typedef struct git_treebuilder git_treebuilder
;
147 /** Memory representation of an index file. */
148 typedef struct git_index git_index
;
150 /** An iterator for entries in the index. */
151 typedef struct git_index_iterator git_index_iterator
;
153 /** An iterator for conflicts in the index. */
154 typedef struct git_index_conflict_iterator git_index_conflict_iterator
;
156 /** Memory representation of a set of config files */
157 typedef struct git_config git_config
;
159 /** Interface to access a configuration file */
160 typedef struct git_config_backend git_config_backend
;
162 /** Representation of a reference log entry */
163 typedef struct git_reflog_entry git_reflog_entry
;
165 /** Representation of a reference log */
166 typedef struct git_reflog git_reflog
;
168 /** Representation of a git note */
169 typedef struct git_note git_note
;
171 /** Representation of a git packbuilder */
172 typedef struct git_packbuilder git_packbuilder
;
174 /** Time in a signature */
175 typedef struct git_time
{
176 git_time_t time
; /**< time in seconds from epoch */
177 int offset
; /**< timezone offset, in minutes */
178 char sign
; /**< indicator for questionable '-0000' offsets in signature */
181 /** An action signature (e.g. for committers, taggers, etc) */
182 typedef struct git_signature
{
183 char *name
; /**< full name of the author */
184 char *email
; /**< email of the author */
185 git_time when
; /**< time when the action happened */
188 /** In-memory representation of a reference. */
189 typedef struct git_reference git_reference
;
191 /** Iterator for references */
192 typedef struct git_reference_iterator git_reference_iterator
;
194 /** Transactional interface to references */
195 typedef struct git_transaction git_transaction
;
197 /** Annotated commits, the input to merge and rebase. */
198 typedef struct git_annotated_commit git_annotated_commit
;
200 /** Representation of a status collection */
201 typedef struct git_status_list git_status_list
;
203 /** Representation of a rebase */
204 typedef struct git_rebase git_rebase
;
206 /** Basic type of any Git reference. */
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 */
211 GIT_REFERENCE_ALL
= GIT_REFERENCE_DIRECT
| GIT_REFERENCE_SYMBOLIC
214 /** Basic type of any Git branch. */
216 GIT_BRANCH_LOCAL
= 1,
217 GIT_BRANCH_REMOTE
= 2,
218 GIT_BRANCH_ALL
= GIT_BRANCH_LOCAL
|GIT_BRANCH_REMOTE
221 /** Valid modes for index and tree entries. */
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,
228 GIT_FILEMODE_COMMIT
= 0160000
232 * A refspec specifies the mapping between remote and local reference
233 * names when fetch or pushing.
235 typedef struct git_refspec git_refspec
;
238 * Git's idea of a remote repository. A remote can be anonymous (in
239 * which case it does not have backing configuration entries).
241 typedef struct git_remote git_remote
;
244 * Interface which represents a transport to communicate with a
247 typedef struct git_transport git_transport
;
250 * Preparation for a push operation. Can be used to configure what to
251 * push and the level of parallelism of the packfile builder.
253 typedef struct git_push git_push
;
255 /* documentation in the definition */
256 typedef struct git_remote_head git_remote_head
;
257 typedef struct git_remote_callbacks git_remote_callbacks
;
260 * Parent type for `git_cert_hostkey` and `git_cert_x509`.
262 typedef struct git_cert git_cert
;
265 * Opaque structure representing a submodule.
267 typedef struct git_submodule git_submodule
;
270 * Submodule update values
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.
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.
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.
292 * - GIT_SUBMODULE_UPDATE_DEFAULT: not used except as static initializer
293 * when we don't want any particular update rule to be specified.
296 GIT_SUBMODULE_UPDATE_CHECKOUT
= 1,
297 GIT_SUBMODULE_UPDATE_REBASE
= 2,
298 GIT_SUBMODULE_UPDATE_MERGE
= 3,
299 GIT_SUBMODULE_UPDATE_NONE
= 4,
301 GIT_SUBMODULE_UPDATE_DEFAULT
= 0
302 } git_submodule_update_t
;
305 * Submodule ignore values
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.
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`.
318 * - GIT_SUBMODULE_IGNORE_UNSPECIFIED: use the submodule's configuration
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
328 * - GIT_SUBMODULE_IGNORE_DEFAULT: not used except as static initializer
329 * when we don't want any particular ignore rule to be specified.
332 GIT_SUBMODULE_IGNORE_UNSPECIFIED
= -1, /**< use the submodule's configuration */
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 */
337 GIT_SUBMODULE_IGNORE_ALL
= 4 /**< never dirty */
338 } git_submodule_ignore_t
;
341 * Options for submodule recurse.
343 * Represent the value of `submodule.$name.fetchRecurseSubmodules`
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
351 GIT_SUBMODULE_RECURSE_NO
= 0,
352 GIT_SUBMODULE_RECURSE_YES
= 1,
353 GIT_SUBMODULE_RECURSE_ONDEMAND
= 2
354 } git_submodule_recurse_t
;
356 typedef struct git_writestream git_writestream
;
358 /** A type to write in a streaming fashion, for example, for filters. */
359 struct git_writestream
{
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
);
365 /** Representation of .mailmap file state. */
366 typedef struct git_mailmap git_mailmap
;