1 /*
2  * Copyright (C) the libgit2 contributors. All rights reserved.
3  *
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.
6  */
7 module libgit2_d.types;
8 
9 
10 private static import core.sys.posix.sys.types;
11 private static import libgit2_d.cert;
12 private static import libgit2_d.net;
13 private static import libgit2_d.odb_backend;
14 private static import libgit2_d.remote;
15 private static import libgit2_d.sys.config;
16 private static import libgit2_d.sys.odb_backend;
17 private static import libgit2_d.sys.refdb_backend;
18 private static import libgit2_d.sys.transport;
19 private static import std.conv;
20 
21 /**
22  * @file git2/types.h
23  * @brief libgit2 base & compatibility types
24  * @ingroup Git
25  * @{
26  */
27 extern (C):
28 nothrow @nogc:
29 public:
30 
31 /**
32  * Cross-platform compatibility types for off_t / time_t
33  *
34  * NOTE: This needs to be in a public header so that both the library
35  * implementation and client applications both agree on the same types.
36  * Otherwise we get undefined behavior.
37  *
38  * Use the "best" types that each platform provides. Currently we truncate
39  * these intermediate representations for compatibility with the git ABI, but
40  * if and when it changes to support 64 bit types, our code will naturally
41  * adapt.
42  * NOTE: These types should match those that are returned by our internal
43  * stat() functions, for all platforms.
44  */
45 version (none) {
46 	//_MSC_VER
47 	alias git_off_t = long;
48 	alias git_time_t = __time64_t;
49 } else version (MinGW) {
50 	//__MINGW32__
51 	alias git_off_t = core.sys.posix.sys.types.off64_t;
52 	alias git_time_t = __time64_t;
53 } else version (Haiku) {
54 	static assert(0);
55 	//alias git_off_t = __haiku_std_int64;
56 	//alias git_time_t = __haiku_std_int64;
57 } else {
58 	/* POSIX */
59 	/*
60 	 * Note: Can't use off_t since if a client program includes <sys/types.h>
61 	 * before us (directly or indirectly), they'll get 32 bit off_t in their client
62 	 * app, even though /we/ define _FILE_OFFSET_BITS=64.
63 	 */
64 	alias git_off_t = long;
65 
66 	/**
67 	 * time in seconds from epoch
68 	 */
69 	alias git_time_t = long;
70 }
71 
72 /**
73  * The maximum size of an object
74  */
75 alias git_object_size_t = ulong;
76 
77 //public import libgit2_d.buffer;
78 //public import libgit2_d.oid;
79 
80 /**
81  * Basic type (loose or packed) of any Git object.
82  */
83 enum git_object_t
84 {
85 	/**
86 	 * Object can be any of the following
87 	 */
88 	GIT_OBJECT_ANY = -2,
89 
90 	/**
91 	 * Object is invalid.
92 	 */
93 	GIT_OBJECT_INVALID = -1,
94 
95 	/**
96 	 * A commit object.
97 	 */
98 	GIT_OBJECT_COMMIT = 1,
99 
100 	/**
101 	 * A tree (directory listing) object.
102 	 */
103 	GIT_OBJECT_TREE = 2,
104 
105 	/**
106 	 * A file revision object.
107 	 */
108 	GIT_OBJECT_BLOB = 3,
109 
110 	/**
111 	 * An annotated tag object.
112 	 */
113 	GIT_OBJECT_TAG = 4,
114 
115 	/**
116 	 * A delta, base is given by an offset.
117 	 */
118 	GIT_OBJECT_OFS_DELTA = 6,
119 
120 	/**
121 	 * A delta, base is given by object id.
122 	 */
123 	GIT_OBJECT_REF_DELTA = 7,
124 }
125 
126 /**
127  * An open object database handle.
128  */
129 struct git_odb;
130 
131 /**
132  * A custom backend in an ODB
133  */
134 alias git_odb_backend = libgit2_d.sys.odb_backend.git_odb_backend;
135 
136 /**
137  * An object read from the ODB
138  */
139 struct git_odb_object;
140 
141 /**
142  * A stream to read/write from the ODB
143  */
144 alias git_odb_stream = libgit2_d.odb_backend.git_odb_stream;
145 
146 /**
147  * A stream to write a packfile to the ODB
148  */
149 alias git_odb_writepack = libgit2_d.odb_backend.git_odb_writepack;
150 
151 /**
152  * An open refs database handle.
153  */
154 struct git_refdb;
155 
156 /**
157  * A custom backend for refs
158  */
159 alias git_refdb_backend = libgit2_d.sys.refdb_backend.git_refdb_backend;
160 
161 /**
162  * Representation of an existing git repository,
163  * including all its object contents
164  */
165 struct git_repository;
166 
167 /**
168  * Representation of a working tree
169  */
170 struct git_worktree;
171 
172 /**
173  * Representation of a generic object in a repository
174  */
175 struct git_object;
176 
177 /**
178  * Representation of an in-progress walk through the commits in a repo
179  */
180 struct git_revwalk;
181 
182 /**
183  * Parsed representation of a tag object.
184  */
185 struct git_tag;
186 
187 /**
188  * In-memory representation of a blob object.
189  */
190 struct git_blob;
191 
192 /**
193  * Parsed representation of a commit object.
194  */
195 struct git_commit;
196 
197 /**
198  * Representation of each one of the entries in a tree object.
199  */
200 struct git_tree_entry;
201 
202 /**
203  * Representation of a tree object.
204  */
205 struct git_tree;
206 
207 /**
208  * Constructor for in-memory trees
209  */
210 struct git_treebuilder;
211 
212 /**
213  * Memory representation of an index file.
214  */
215 struct git_index;
216 
217 /**
218  * An iterator for entries in the index.
219  */
220 struct git_index_iterator;
221 
222 /**
223  * An iterator for conflicts in the index.
224  */
225 struct git_index_conflict_iterator;
226 
227 /**
228  * Memory representation of a set of config files
229  */
230 struct git_config;
231 
232 /**
233  * Interface to access a configuration file
234  */
235 alias git_config_backend = libgit2_d.sys.config.git_config_backend;
236 
237 /**
238  * Representation of a reference log entry
239  */
240 struct git_reflog_entry;
241 
242 /**
243  * Representation of a reference log
244  */
245 struct git_reflog;
246 
247 /**
248  * Representation of a git note
249  */
250 struct git_note;
251 
252 /**
253  * Representation of a git packbuilder
254  */
255 struct git_packbuilder;
256 
257 /**
258  * Time in a signature
259  */
260 struct git_time
261 {
262 	/**
263 	 * time in seconds from epoch
264 	 */
265 	.git_time_t time;
266 
267 	/**
268 	 * timezone offset, in minutes
269 	 */
270 	int offset;
271 
272 	/**
273 	 * indicator for questionable '-0000' offsets in signature
274 	 */
275 	char sign;
276 }
277 
278 /**
279  * An action signature (e.g. for committers, taggers, etc)
280  */
281 struct git_signature
282 {
283 	/**
284 	 * full name of the author
285 	 */
286 	char* name;
287 
288 	/**
289 	 * email of the author
290 	 */
291 	char* email;
292 
293 	/**
294 	 * time when the action happened
295 	 */
296 	.git_time when;
297 }
298 
299 /**
300  * In-memory representation of a reference.
301  */
302 struct git_reference;
303 
304 /**
305  * Iterator for references
306  */
307 alias git_reference_iterator = libgit2_d.sys.refdb_backend.git_reference_iterator;
308 
309 /**
310  * Transactional interface to references
311  */
312 struct git_transaction;
313 
314 /**
315  * Annotated commits, the input to merge and rebase.
316  */
317 struct git_annotated_commit;
318 
319 /**
320  * Representation of a status collection
321  */
322 struct git_status_list;
323 
324 /**
325  * Representation of a rebase
326  */
327 struct git_rebase;
328 
329 /**
330  * Basic type of any Git reference.
331  */
332 enum git_reference_t
333 {
334 	/**
335 	 * Invalid reference
336 	 */
337 	GIT_REFERENCE_INVALID = 0,
338 
339 	/**
340 	 * A reference that points at an object id
341 	 */
342 	GIT_REFERENCE_DIRECT = 1,
343 
344 	/**
345 	 * A reference that points at another reference
346 	 */
347 	GIT_REFERENCE_SYMBOLIC = 2,
348 
349 	GIT_REFERENCE_ALL = GIT_REFERENCE_DIRECT | GIT_REFERENCE_SYMBOLIC,
350 }
351 
352 /**
353  * Basic type of any Git branch.
354  */
355 enum git_branch_t
356 {
357 	GIT_BRANCH_LOCAL = 1,
358 	GIT_BRANCH_REMOTE = 2,
359 	GIT_BRANCH_ALL = GIT_BRANCH_LOCAL | GIT_BRANCH_REMOTE,
360 }
361 
362 /**
363  * Valid modes for index and tree entries.
364  */
365 enum git_filemode_t
366 {
367 	GIT_FILEMODE_UNREADABLE = std.conv.octal!(0000000),
368 	GIT_FILEMODE_TREE = std.conv.octal!(40000),
369 	GIT_FILEMODE_BLOB = std.conv.octal!(100644),
370 	GIT_FILEMODE_BLOB_EXECUTABLE = std.conv.octal!(100755),
371 	GIT_FILEMODE_LINK = std.conv.octal!(120000),
372 	GIT_FILEMODE_COMMIT = std.conv.octal!(160000),
373 }
374 
375 /**
376  * A refspec specifies the mapping between remote and local reference
377  * names when fetch or pushing.
378  */
379 struct git_refspec;
380 
381 /**
382  * Git's idea of a remote repository. A remote can be anonymous (in
383  * which case it does not have backing configuration entires).
384  */
385 struct git_remote;
386 
387 /**
388  * Interface which represents a transport to communicate with a
389  * remote.
390  */
391 alias git_transport = libgit2_d.sys.transport.git_transport;
392 
393 /**
394  * Preparation for a push operation. Can be used to configure what to
395  * push and the level of parallelism of the packfile builder.
396  */
397 struct git_push;
398 
399 /* documentation in the definition */
400 alias git_remote_head = libgit2_d.net.git_remote_head;
401 alias git_remote_callbacks = libgit2_d.remote.git_remote_callbacks;
402 
403 /**
404  * Parent type for `git_cert_hostkey` and `git_cert_x509`.
405  */
406 alias git_cert = libgit2_d.cert.git_cert;
407 
408 /**
409  * Opaque structure representing a submodule.
410  */
411 struct git_submodule;
412 
413 /**
414  * Submodule update values
415  *
416  * These values represent settings for the `submodule.$name.update`
417  * configuration value which says how to handle `git submodule update` for
418  * this submodule.  The value is usually set in the ".gitmodules" file and
419  * copied to ".git/config" when the submodule is initialized.
420  *
421  * You can override this setting on a per-submodule basis with
422  * `git_submodule_set_update()` and write the changed value to disk using
423  * `git_submodule_save()`.  If you have overwritten the value, you can
424  * revert it by passing `GIT_SUBMODULE_UPDATE_RESET` to the set function.
425  *
426  * The values are:
427  *
428  * - GIT_SUBMODULE_UPDATE_CHECKOUT: the default; when a submodule is
429  *   updated, checkout the new detached HEAD to the submodule directory.
430  * - GIT_SUBMODULE_UPDATE_REBASE: update by rebasing the current checked
431  *   out branch onto the commit from the superproject.
432  * - GIT_SUBMODULE_UPDATE_MERGE: update by merging the commit in the
433  *   superproject into the current checkout out branch of the submodule.
434  * - GIT_SUBMODULE_UPDATE_NONE: do not update this submodule even when
435  *   the commit in the superproject is updated.
436  * - GIT_SUBMODULE_UPDATE_DEFAULT: not used except as static initializer
437  *   when we don't want any particular update rule to be specified.
438  */
439 enum git_submodule_update_t
440 {
441 	GIT_SUBMODULE_UPDATE_CHECKOUT = 1,
442 	GIT_SUBMODULE_UPDATE_REBASE = 2,
443 	GIT_SUBMODULE_UPDATE_MERGE = 3,
444 	GIT_SUBMODULE_UPDATE_NONE = 4,
445 
446 	GIT_SUBMODULE_UPDATE_DEFAULT = 0,
447 }
448 
449 /**
450  * Submodule ignore values
451  *
452  * These values represent settings for the `submodule.$name.ignore`
453  * configuration value which says how deeply to look at the working
454  * directory when getting submodule status.
455  *
456  * You can override this value in memory on a per-submodule basis with
457  * `git_submodule_set_ignore()` and can write the changed value to disk
458  * with `git_submodule_save()`.  If you have overwritten the value, you
459  * can revert to the on disk value by using `GIT_SUBMODULE_IGNORE_RESET`.
460  *
461  * The values are:
462  *
463  * - GIT_SUBMODULE_IGNORE_UNSPECIFIED: use the submodule's configuration
464  * - GIT_SUBMODULE_IGNORE_NONE: don't ignore any change - i.e. even an
465  *   untracked file, will mark the submodule as dirty.  Ignored files are
466  *   still ignored, of course.
467  * - GIT_SUBMODULE_IGNORE_UNTRACKED: ignore untracked files; only changes
468  *   to tracked files, or the index or the HEAD commit will matter.
469  * - GIT_SUBMODULE_IGNORE_DIRTY: ignore changes in the working directory,
470  *   only considering changes if the HEAD of submodule has moved from the
471  *   value in the superproject.
472  * - GIT_SUBMODULE_IGNORE_ALL: never check if the submodule is dirty
473  * - GIT_SUBMODULE_IGNORE_DEFAULT: not used except as static initializer
474  *   when we don't want any particular ignore rule to be specified.
475  */
476 enum git_submodule_ignore_t
477 {
478 	/**
479 	 * use the submodule's configuration
480 	 */
481 	GIT_SUBMODULE_IGNORE_UNSPECIFIED = -1,
482 
483 	/**
484 	 * any change or untracked == dirty
485 	 */
486 	GIT_SUBMODULE_IGNORE_NONE = 1,
487 
488 	/**
489 	 * dirty if tracked files change
490 	 */
491 	GIT_SUBMODULE_IGNORE_UNTRACKED = 2,
492 
493 	/**
494 	 * only dirty if HEAD moved
495 	 */
496 	GIT_SUBMODULE_IGNORE_DIRTY = 3,
497 
498 	/**
499 	 * never dirty
500 	 */
501 	GIT_SUBMODULE_IGNORE_ALL = 4,
502 }
503 
504 /**
505  * Options for submodule recurse.
506  *
507  * Represent the value of `submodule.$name.fetchRecurseSubmodules`
508  *
509  * * GIT_SUBMODULE_RECURSE_NO    - do no recurse into submodules
510  * * GIT_SUBMODULE_RECURSE_YES   - recurse into submodules
511  * * GIT_SUBMODULE_RECURSE_ONDEMAND - recurse into submodules only when
512  *                                    commit not already in local clone
513  */
514 enum git_submodule_recurse_t
515 {
516 	GIT_SUBMODULE_RECURSE_NO = 0,
517 	GIT_SUBMODULE_RECURSE_YES = 1,
518 	GIT_SUBMODULE_RECURSE_ONDEMAND = 2,
519 }
520 
521 /**
522  * A type to write in a streaming fashion, for example, for filters.
523  */
524 struct git_writestream
525 {
526 	int function(.git_writestream* stream, const (char)* buffer, size_t len) write;
527 	int function(.git_writestream* stream) close;
528 	void function(.git_writestream* stream) free;
529 }
530 
531 /**
532  * Representation of .mailmap file state.
533  */
534 struct git_mailmap;
535 
536 /** @} */