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 //Declaration name in C language 127 enum 128 { 129 GIT_OBJECT_ANY = .git_object_t.GIT_OBJECT_ANY, 130 GIT_OBJECT_INVALID = .git_object_t.GIT_OBJECT_INVALID, 131 GIT_OBJECT_COMMIT = .git_object_t.GIT_OBJECT_COMMIT, 132 GIT_OBJECT_TREE = .git_object_t.GIT_OBJECT_TREE, 133 GIT_OBJECT_BLOB = .git_object_t.GIT_OBJECT_BLOB, 134 GIT_OBJECT_TAG = .git_object_t.GIT_OBJECT_TAG, 135 GIT_OBJECT_OFS_DELTA = .git_object_t.GIT_OBJECT_OFS_DELTA, 136 GIT_OBJECT_REF_DELTA = .git_object_t.GIT_OBJECT_REF_DELTA, 137 } 138 139 /** 140 * An open object database handle. 141 */ 142 struct git_odb; 143 144 /** 145 * A custom backend in an ODB 146 */ 147 alias git_odb_backend = libgit2_d.sys.odb_backend.git_odb_backend; 148 149 /** 150 * An object read from the ODB 151 */ 152 struct git_odb_object; 153 154 /** 155 * A stream to read/write from the ODB 156 */ 157 alias git_odb_stream = libgit2_d.odb_backend.git_odb_stream; 158 159 /** 160 * A stream to write a packfile to the ODB 161 */ 162 alias git_odb_writepack = libgit2_d.odb_backend.git_odb_writepack; 163 164 /** 165 * An open refs database handle. 166 */ 167 struct git_refdb; 168 169 /** 170 * A custom backend for refs 171 */ 172 alias git_refdb_backend = libgit2_d.sys.refdb_backend.git_refdb_backend; 173 174 /** 175 * Representation of an existing git repository, 176 * including all its object contents 177 */ 178 struct git_repository; 179 180 /** 181 * Representation of a working tree 182 */ 183 struct git_worktree; 184 185 /** 186 * Representation of a generic object in a repository 187 */ 188 struct git_object; 189 190 /** 191 * Representation of an in-progress walk through the commits in a repo 192 */ 193 struct git_revwalk; 194 195 /** 196 * Parsed representation of a tag object. 197 */ 198 struct git_tag; 199 200 /** 201 * In-memory representation of a blob object. 202 */ 203 struct git_blob; 204 205 /** 206 * Parsed representation of a commit object. 207 */ 208 struct git_commit; 209 210 /** 211 * Representation of each one of the entries in a tree object. 212 */ 213 struct git_tree_entry; 214 215 /** 216 * Representation of a tree object. 217 */ 218 struct git_tree; 219 220 /** 221 * Constructor for in-memory trees 222 */ 223 struct git_treebuilder; 224 225 /** 226 * Memory representation of an index file. 227 */ 228 struct git_index; 229 230 /** 231 * An iterator for entries in the index. 232 */ 233 struct git_index_iterator; 234 235 /** 236 * An iterator for conflicts in the index. 237 */ 238 struct git_index_conflict_iterator; 239 240 /** 241 * Memory representation of a set of config files 242 */ 243 struct git_config; 244 245 /** 246 * Interface to access a configuration file 247 */ 248 alias git_config_backend = libgit2_d.sys.config.git_config_backend; 249 250 /** 251 * Representation of a reference log entry 252 */ 253 struct git_reflog_entry; 254 255 /** 256 * Representation of a reference log 257 */ 258 struct git_reflog; 259 260 /** 261 * Representation of a git note 262 */ 263 struct git_note; 264 265 /** 266 * Representation of a git packbuilder 267 */ 268 struct git_packbuilder; 269 270 /** 271 * Time in a signature 272 */ 273 struct git_time 274 { 275 /** 276 * time in seconds from epoch 277 */ 278 .git_time_t time; 279 280 /** 281 * timezone offset, in minutes 282 */ 283 int offset; 284 285 /** 286 * indicator for questionable '-0000' offsets in signature 287 */ 288 char sign; 289 } 290 291 /** 292 * An action signature (e.g. for committers, taggers, etc) 293 */ 294 struct git_signature 295 { 296 /** 297 * full name of the author 298 */ 299 char* name; 300 301 /** 302 * email of the author 303 */ 304 char* email; 305 306 /** 307 * time when the action happened 308 */ 309 .git_time when; 310 } 311 312 /** 313 * In-memory representation of a reference. 314 */ 315 struct git_reference; 316 317 /** 318 * Iterator for references 319 */ 320 alias git_reference_iterator = libgit2_d.sys.refdb_backend.git_reference_iterator; 321 322 /** 323 * Transactional interface to references 324 */ 325 struct git_transaction; 326 327 /** 328 * Annotated commits, the input to merge and rebase. 329 */ 330 struct git_annotated_commit; 331 332 /** 333 * Representation of a status collection 334 */ 335 struct git_status_list; 336 337 /** 338 * Representation of a rebase 339 */ 340 struct git_rebase; 341 342 /** 343 * Basic type of any Git reference. 344 */ 345 enum git_reference_t 346 { 347 /** 348 * Invalid reference 349 */ 350 GIT_REFERENCE_INVALID = 0, 351 352 /** 353 * A reference that points at an object id 354 */ 355 GIT_REFERENCE_DIRECT = 1, 356 357 /** 358 * A reference that points at another reference 359 */ 360 GIT_REFERENCE_SYMBOLIC = 2, 361 362 GIT_REFERENCE_ALL = GIT_REFERENCE_DIRECT | GIT_REFERENCE_SYMBOLIC, 363 } 364 365 //Declaration name in C language 366 enum 367 { 368 GIT_REFERENCE_INVALID = .git_reference_t.GIT_REFERENCE_INVALID, 369 GIT_REFERENCE_DIRECT = .git_reference_t.GIT_REFERENCE_DIRECT, 370 GIT_REFERENCE_SYMBOLIC = .git_reference_t.GIT_REFERENCE_SYMBOLIC, 371 GIT_REFERENCE_ALL = .git_reference_t.GIT_REFERENCE_ALL, 372 } 373 374 /** 375 * Basic type of any Git branch. 376 */ 377 enum git_branch_t 378 { 379 GIT_BRANCH_LOCAL = 1, 380 GIT_BRANCH_REMOTE = 2, 381 GIT_BRANCH_ALL = GIT_BRANCH_LOCAL | GIT_BRANCH_REMOTE, 382 } 383 384 //Declaration name in C language 385 enum 386 { 387 GIT_BRANCH_LOCAL = .git_branch_t.GIT_BRANCH_LOCAL, 388 GIT_BRANCH_REMOTE = .git_branch_t.GIT_BRANCH_REMOTE, 389 GIT_BRANCH_ALL = .git_branch_t.GIT_BRANCH_ALL, 390 } 391 392 /** 393 * Valid modes for index and tree entries. 394 */ 395 enum git_filemode_t 396 { 397 GIT_FILEMODE_UNREADABLE = std.conv.octal!(0000000), 398 GIT_FILEMODE_TREE = std.conv.octal!(40000), 399 GIT_FILEMODE_BLOB = std.conv.octal!(100644), 400 GIT_FILEMODE_BLOB_EXECUTABLE = std.conv.octal!(100755), 401 GIT_FILEMODE_LINK = std.conv.octal!(120000), 402 GIT_FILEMODE_COMMIT = std.conv.octal!(160000), 403 } 404 405 //Declaration name in C language 406 enum 407 { 408 GIT_FILEMODE_UNREADABLE = .git_filemode_t.GIT_FILEMODE_UNREADABLE, 409 GIT_FILEMODE_TREE = .git_filemode_t.GIT_FILEMODE_TREE, 410 GIT_FILEMODE_BLOB = .git_filemode_t.GIT_FILEMODE_BLOB, 411 GIT_FILEMODE_BLOB_EXECUTABLE = .git_filemode_t.GIT_FILEMODE_BLOB_EXECUTABLE, 412 GIT_FILEMODE_LINK = .git_filemode_t.GIT_FILEMODE_LINK, 413 GIT_FILEMODE_COMMIT = .git_filemode_t.GIT_FILEMODE_COMMIT, 414 } 415 416 /** 417 * A refspec specifies the mapping between remote and local reference 418 * names when fetch or pushing. 419 */ 420 struct git_refspec; 421 422 /** 423 * Git's idea of a remote repository. A remote can be anonymous (in 424 * which case it does not have backing configuration entires). 425 */ 426 struct git_remote; 427 428 /** 429 * Interface which represents a transport to communicate with a 430 * remote. 431 */ 432 alias git_transport = libgit2_d.sys.transport.git_transport; 433 434 /** 435 * Preparation for a push operation. Can be used to configure what to 436 * push and the level of parallelism of the packfile builder. 437 */ 438 struct git_push; 439 440 /* documentation in the definition */ 441 alias git_remote_head = libgit2_d.net.git_remote_head; 442 alias git_remote_callbacks = libgit2_d.remote.git_remote_callbacks; 443 444 /** 445 * Parent type for `git_cert_hostkey` and `git_cert_x509`. 446 */ 447 alias git_cert = libgit2_d.cert.git_cert; 448 449 /** 450 * Opaque structure representing a submodule. 451 */ 452 struct git_submodule; 453 454 /** 455 * Submodule update values 456 * 457 * These values represent settings for the `submodule.$name.update` 458 * configuration value which says how to handle `git submodule update` for 459 * this submodule. The value is usually set in the ".gitmodules" file and 460 * copied to ".git/config" when the submodule is initialized. 461 * 462 * You can override this setting on a per-submodule basis with 463 * `git_submodule_set_update()` and write the changed value to disk using 464 * `git_submodule_save()`. If you have overwritten the value, you can 465 * revert it by passing `GIT_SUBMODULE_UPDATE_RESET` to the set function. 466 * 467 * The values are: 468 * 469 * - GIT_SUBMODULE_UPDATE_CHECKOUT: the default; when a submodule is 470 * updated, checkout the new detached HEAD to the submodule directory. 471 * - GIT_SUBMODULE_UPDATE_REBASE: update by rebasing the current checked 472 * out branch onto the commit from the superproject. 473 * - GIT_SUBMODULE_UPDATE_MERGE: update by merging the commit in the 474 * superproject into the current checkout out branch of the submodule. 475 * - GIT_SUBMODULE_UPDATE_NONE: do not update this submodule even when 476 * the commit in the superproject is updated. 477 * - GIT_SUBMODULE_UPDATE_DEFAULT: not used except as static initializer 478 * when we don't want any particular update rule to be specified. 479 */ 480 enum git_submodule_update_t 481 { 482 GIT_SUBMODULE_UPDATE_CHECKOUT = 1, 483 GIT_SUBMODULE_UPDATE_REBASE = 2, 484 GIT_SUBMODULE_UPDATE_MERGE = 3, 485 GIT_SUBMODULE_UPDATE_NONE = 4, 486 487 GIT_SUBMODULE_UPDATE_DEFAULT = 0, 488 } 489 490 //Declaration name in C language 491 enum 492 { 493 GIT_SUBMODULE_UPDATE_CHECKOUT = .git_submodule_update_t.GIT_SUBMODULE_UPDATE_CHECKOUT, 494 GIT_SUBMODULE_UPDATE_REBASE = .git_submodule_update_t.GIT_SUBMODULE_UPDATE_REBASE, 495 GIT_SUBMODULE_UPDATE_MERGE = .git_submodule_update_t.GIT_SUBMODULE_UPDATE_MERGE, 496 GIT_SUBMODULE_UPDATE_NONE = .git_submodule_update_t.GIT_SUBMODULE_UPDATE_NONE, 497 498 GIT_SUBMODULE_UPDATE_DEFAULT = .git_submodule_update_t.GIT_SUBMODULE_UPDATE_DEFAULT, 499 } 500 501 /** 502 * Submodule ignore values 503 * 504 * These values represent settings for the `submodule.$name.ignore` 505 * configuration value which says how deeply to look at the working 506 * directory when getting submodule status. 507 * 508 * You can override this value in memory on a per-submodule basis with 509 * `git_submodule_set_ignore()` and can write the changed value to disk 510 * with `git_submodule_save()`. If you have overwritten the value, you 511 * can revert to the on disk value by using `GIT_SUBMODULE_IGNORE_RESET`. 512 * 513 * The values are: 514 * 515 * - GIT_SUBMODULE_IGNORE_UNSPECIFIED: use the submodule's configuration 516 * - GIT_SUBMODULE_IGNORE_NONE: don't ignore any change - i.e. even an 517 * untracked file, will mark the submodule as dirty. Ignored files are 518 * still ignored, of course. 519 * - GIT_SUBMODULE_IGNORE_UNTRACKED: ignore untracked files; only changes 520 * to tracked files, or the index or the HEAD commit will matter. 521 * - GIT_SUBMODULE_IGNORE_DIRTY: ignore changes in the working directory, 522 * only considering changes if the HEAD of submodule has moved from the 523 * value in the superproject. 524 * - GIT_SUBMODULE_IGNORE_ALL: never check if the submodule is dirty 525 * - GIT_SUBMODULE_IGNORE_DEFAULT: not used except as static initializer 526 * when we don't want any particular ignore rule to be specified. 527 */ 528 enum git_submodule_ignore_t 529 { 530 /** 531 * use the submodule's configuration 532 */ 533 GIT_SUBMODULE_IGNORE_UNSPECIFIED = -1, 534 535 /** 536 * any change or untracked == dirty 537 */ 538 GIT_SUBMODULE_IGNORE_NONE = 1, 539 540 /** 541 * dirty if tracked files change 542 */ 543 GIT_SUBMODULE_IGNORE_UNTRACKED = 2, 544 545 /** 546 * only dirty if HEAD moved 547 */ 548 GIT_SUBMODULE_IGNORE_DIRTY = 3, 549 550 /** 551 * never dirty 552 */ 553 GIT_SUBMODULE_IGNORE_ALL = 4, 554 } 555 556 //Declaration name in C language 557 enum 558 { 559 GIT_SUBMODULE_IGNORE_UNSPECIFIED = .git_submodule_ignore_t.GIT_SUBMODULE_IGNORE_UNSPECIFIED, 560 GIT_SUBMODULE_IGNORE_NONE = .git_submodule_ignore_t.GIT_SUBMODULE_IGNORE_NONE, 561 GIT_SUBMODULE_IGNORE_UNTRACKED = .git_submodule_ignore_t.GIT_SUBMODULE_IGNORE_UNTRACKED, 562 GIT_SUBMODULE_IGNORE_DIRTY = .git_submodule_ignore_t.GIT_SUBMODULE_IGNORE_DIRTY, 563 GIT_SUBMODULE_IGNORE_ALL = .git_submodule_ignore_t.GIT_SUBMODULE_IGNORE_ALL, 564 } 565 566 /** 567 * Options for submodule recurse. 568 * 569 * Represent the value of `submodule.$name.fetchRecurseSubmodules` 570 * 571 * * GIT_SUBMODULE_RECURSE_NO - do no recurse into submodules 572 * * GIT_SUBMODULE_RECURSE_YES - recurse into submodules 573 * * GIT_SUBMODULE_RECURSE_ONDEMAND - recurse into submodules only when 574 * commit not already in local clone 575 */ 576 enum git_submodule_recurse_t 577 { 578 GIT_SUBMODULE_RECURSE_NO = 0, 579 GIT_SUBMODULE_RECURSE_YES = 1, 580 GIT_SUBMODULE_RECURSE_ONDEMAND = 2, 581 } 582 583 //Declaration name in C language 584 enum 585 { 586 GIT_SUBMODULE_RECURSE_NO = .git_submodule_recurse_t.GIT_SUBMODULE_RECURSE_NO, 587 GIT_SUBMODULE_RECURSE_YES = .git_submodule_recurse_t.GIT_SUBMODULE_RECURSE_YES, 588 GIT_SUBMODULE_RECURSE_ONDEMAND = .git_submodule_recurse_t.GIT_SUBMODULE_RECURSE_ONDEMAND, 589 } 590 591 /** 592 * A type to write in a streaming fashion, for example, for filters. 593 */ 594 struct git_writestream 595 { 596 int function(.git_writestream* stream, const (char)* buffer, size_t len) write; 597 int function(.git_writestream* stream) close; 598 void function(.git_writestream* stream) free; 599 } 600 601 /** 602 * Representation of .mailmap file state. 603 */ 604 struct git_mailmap; 605 606 /** @} */