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