The Birdfont Source Code


All Repositories / birdfont.git / blob – RSS feed

libgit2.vapi

This file is a part of the Birdfont project.

Contributing

Send patches or pull requests to johan.mattsson.m@gmail.com.
Clone this repository: git clone https://github.com/johanmattssonm/birdfont.git

Revisions

View the latest version of libgit2.vapi.
Update overview items
1 /* 2 * libgit2 Vala binding 3 * 4 * Homepage: http://libgit2.github.com/ 5 * VAPI Homepage: https://github.com/apmasell/vapis/blob/master/libgit2.vapi 6 * VAPI Maintainer: Andre Masella <andre@masella.name> 7 * 8 * This file is part of libgit2, distributed under the GNU GPL v2 with 9 * a Linking Exception. For full terms see the included COPYING file. 10 */ 11 12 /** 13 * Library to access the contents of git repositories 14 * 15 * libgit2 can access and manipulate the contents of git repositories. To begin, create an instance of a {@link Git.Repository} like so: 16 * {{{ 17 * Git.Repository? repo; 18 * if (Git.Repository.open(out repo, "/path/to/repo") != Git.Error.OK) { 19 * stderr.printf("Could not open repository because: %s\n", Git.ErrorInfo.get_last().message); 20 * return false; 21 * } 22 * }}} 23 * Then use the methods of //repo// to access the repository. 24 */ 25 [CCode(cheader_filename = "git2.h")] 26 namespace Git { 27 namespace Configuration { 28 /** 29 * Generic backend that implements the interface to 30 * access a configuration file 31 */ 32 [CCode(cname = "git_config_backend", has_type_id = false, default_value = "GIT_CONFIG_BACKEND_INIT")] 33 public struct backend { 34 [CCode(cname = "GIT_CONFIG_BACKEND_VERSION")] 35 public const uint VERSION; 36 public uint version; 37 public unowned Config cfg; 38 public Delete @delete; 39 [CCode(cname = "foreach")] 40 public ForEach for_each; 41 public Free free; 42 public Get @get; 43 [CCode(cname = "get_multivar")] 44 public GetMulti get_multi; 45 [CCode(cname = "refersh")] 46 public Refresh refresh; 47 public Open open; 48 public Set @set; 49 public SetMulti set_multi; 50 } 51 52 [CCode(cname = "git_config_file_delete_cb", has_type_id = false, has_target = false)] 53 public delegate int Delete(backend backend, string key); 54 [CCode(cname = "git_config_file_foreach_cb", has_type_id = false, has_target = false)] 55 public delegate int ForEach(backend backend, string regex, ConfigForEach config_for_each); 56 [CCode(cname = "git_config_file_free_cb", has_type_id = false, has_target = false)] 57 public delegate void Free(backend backend); 58 [CCode(cname = "git_config_file_get_cb", has_type_id = false, has_target = false)] 59 public delegate int Get(backend backend, string key, out string value); 60 [CCode(cname = "git_config_file_get_mulivar_cb", has_type_id = false, has_target = false)] 61 public delegate int GetMulti(backend backend, string key, string? regexp, Setter func); 62 [CCode(cname = "git_config_file_refresh", has_type_id = false, has_target = false)] 63 public delegate Error Refresh(backend backend); 64 [CCode(cname = "git_config_file_set_cb", has_type_id = false, has_target = false)] 65 public delegate int Setter(string val); 66 [CCode(cname = "git_config_file_open_cb", has_type_id = false, has_target = false)] 67 public delegate int Open(backend backend); 68 [CCode(cname = "git_config_file_set_cb", has_type_id = false, has_target = false)] 69 public delegate int Set(backend backend, string key, string value); 70 [CCode(cname = "git_config_file_set_multivar_cb", has_type_id = false, has_target = false)] 71 public delegate int SetMulti(backend backend, string name, string regexp, string val); 72 } 73 namespace Database { 74 /** 75 * An open object database handle 76 */ 77 [CCode(cname = "git_odb", free_function = "git_odb_close", has_type_id = false)] 78 [Compact] 79 public class Handle { 80 /** 81 * Create a new object database with no backends. 82 * 83 * Before the ODB can be used for read/writing, a custom database 84 * backend must be manually added using {@link Handle.add_backend}. 85 * 86 * @param db location to store the database pointer, if opened. Set to null if the open failed. 87 */ 88 [CCode(cname = "git_odb_new")] 89 public static Error create(out Handle? db); 90 91 /** 92 * Create a new object database and automatically add 93 * the two default backends. 94 * 95 * Automatically added are: 96 * - {@link backend.create_loose}: read and write loose object files 97 * from disk, assuming //objects_dir// as the Objects folder 98 * 99 * - {@link backend.create_pack}: read objects from packfiles, 100 * assuming //objects_dir// as the Objects folder which 101 * contains a //pack// folder with the corresponding data 102 * 103 * @param db location to store the database pointer, if opened. 104 * Set to null if the open failed. 105 * @param objects_dir path of the backends' //objects// directory. 106 */ 107 [CCode(cname = "git_odb_open")] 108 public static Error open(out Handle db, string objects_dir); 109 110 /** 111 * Add a custom backend to an existing Object DB; this 112 * backend will work as an alternate. 113 * 114 * Alternate backends are always checked for objects ''after'' 115 * all the main backends have been exhausted. 116 * 117 * The backends are checked in relative ordering, based on the 118 * value of the //priority// parameter. 119 * 120 * Writing is disabled on alternate backends. 121 * 122 * @param backend the backend instance 123 * @param priority Value for ordering the backends queue 124 */ 125 [CCode(cname = "git_odb_add_alternate")] 126 public Error add_alternate(backend backend, int priority); 127 128 /** 129 * Add a custom backend to an existing Object DB 130 * 131 * The backends are checked in relative ordering, based on the 132 * value of the //priority// parameter. 133 * @param backend the backend instance 134 * @param priority Value for ordering the backends queue 135 */ 136 [CCode(cname = "git_odb_add_backend")] 137 public Error add_backend(backend backend, int priority); 138 139 /** 140 * Determine if the given object can be found in the object database. 141 * 142 * @param id the object to search for. 143 */ 144 [CCode(cname = "git_odb_exists")] 145 public bool contains(object_id id); 146 147 /** 148 * Create a "fake" repository to wrap an object database 149 * 150 * Create a repository object to wrap an object database to be used with 151 * the API when all you have is an object database. This doesn't have any 152 * paths associated with it, so use with care. 153 */ 154 [CCode(cname = "git_repository_wrap_odb", instance_pos = -1)] 155 public Error create_repository(out Repository? repository); 156 157 /** 158 * List all objects available in the database 159 * 160 * The callback will be called for each object available in the 161 * database. Note that the objects are likely to be returned in the index 162 * order, which would make accessing the objects in that order inefficient. 163 */ 164 [CCode(cname = "git_odb_foreach")] 165 public Error for_each(ObjectIdForEach object_for_each); 166 167 /** 168 * Read an object from the database. 169 * 170 * This method queries all available ODB backends 171 * trying to read the given id. 172 * 173 * @param obj pointer where to store the read object 174 * @param id identity of the object to read. 175 */ 176 [CCode(cname = "git_odb_read", instance_pos = 1.2)] 177 public Error read(out Object obj, object_id id); 178 179 /** 180 * Read an object from the database, given a prefix 181 * of its identifier. 182 * 183 * This method queries all available ODB backends 184 * trying to match the //len// first hexadecimal 185 * characters of the //short_id//. 186 * The remaining //({@link object_id.HEX_SIZE}-len)*4// bits of 187 * //short_id// must be 0s. 188 * //len// must be at least {@link object_id.MIN_PREFIX_LENGTH}, 189 * and the prefix must be long enough to identify 190 * a unique object in all the backends; the 191 * method will fail otherwise. 192 * 193 * The returned object is reference counted and 194 * internally cached, so it should be closed 195 * by the user once it's no longer in use. 196 * 197 * @param obj pointer where to store the read object 198 * @param short_id a prefix of the id of the object to read. 199 * @param len the length of the prefix 200 */ 201 [CCode(cname = "git_odb_read_prefix", instance_pos = 1.2)] 202 public Error read_by_prefix(out Object obj, object_id short_id, size_t len); 203 204 /** 205 * Read the header of an object from the database, without 206 * reading its full contents. 207 * 208 * The header includes the length and the type of an object. 209 * 210 * Note that most backends do not support reading only the header 211 * of an object, so the whole object will be read and then the 212 * header will be returned. 213 * 214 * @param len the length of the object 215 * @param type the type of the object 216 * @param id identity of the object to read. 217 */ 218 [CCode(cname = "git_odb_read_header", instance_pos = 2.3)] 219 public Error read_header(out size_t len, out ObjectType type, object_id id); 220 221 /** 222 * Refresh the object database to load newly added files. 223 * 224 * If the object databases have changed on disk while the library is 225 * running, this function will force a reload of the underlying indexes. 226 * 227 * Use this function when you're confident that an external application 228 * has tampered with the ODB. 229 * 230 * Note that it is not necessary to call this function at all. The 231 * library will automatically attempt to refresh the ODB when a lookup 232 * fails, to see if the looked up object exists on disk but hasn't been 233 * loaded yet. 234 */ 235 [CCode(cname = "git_odb_refresh")] 236 public Error refresh(); 237 238 /** 239 * Open a stream to write an object into the ODB 240 * 241 * The type and final length of the object must be specified 242 * when opening the stream. 243 * 244 * The returned stream will be of type {@link StreamMode.WRONLY} and 245 * will have the following methods: 246 * 247 * * {@link stream.write}: write //n// bytes into the stream 248 * * {@link stream.finalize_write}: close the stream and store the object in the ODB 249 * 250 * The streaming write won't be effective until {@link stream.finalize_write} 251 * is called and returns without an error 252 * 253 * @param stream where to store the stream 254 * @param size final size of the object that will be written 255 * @param type type of the object that will be written 256 */ 257 [CCode(cname = "git_odb_open_wstream", instance_pos = 1.2)] 258 public Error open_write_stream(out stream stream, size_t size, ObjectType type); 259 260 /** 261 * Open a stream to read an object from the ODB 262 * 263 * Note that most backends do ''not'' support streaming reads 264 * because they store their objects as compressed/delta'ed blobs. 265 * 266 * It's recommended to use {@link Handle.read} instead, which is 267 * assured to work on all backends. 268 * 269 * The returned stream will be of type {@link StreamMode.RDONLY} and 270 * will have the following methods: 271 * 272 * * {@link stream.read}: read //n// bytes from the stream 273 * 274 * @param stream where to store the stream 275 * @param id id of the object the stream will read from 276 */ 277 [CCode(cname = "git_odb_open_rstream")] 278 public Error open_read_stream(out stream stream, object_id id); 279 280 /** 281 * Write an object directly into the ODB 282 * 283 * This method writes a full object straight into the ODB. 284 * For most cases, it is preferred to write objects through a write 285 * stream, which is both faster and less memory intensive, specially 286 * for big objects. 287 * 288 * This method is provided for compatibility with custom backends 289 * which are not able to support streaming writes 290 * 291 * @param id pointer to store the id result of the write 292 * @param data buffer with the data to store 293 * @param type type of the data to store 294 */ 295 [CCode(cname = "git_odb_write", instance_pos = 1.2)] 296 public Error write(object_id id, [CCode(array_length_Type = "size_t")] uint8[] data, ObjectType type); 297 } 298 299 /** 300 * An object read from the database 301 */ 302 [CCode(cname = "git_odb_object", free_function = "git_odb_object_free", has_type_id = false)] 303 [Compact] 304 public class Object { 305 306 /** 307 * The data of an ODB object 308 * 309 * This is the uncompressed, raw data as read from the ODB, 310 * without the leading header. 311 */ 312 public uint8[] data { 313 [CCode(cname = "git_odb_object_data", array_length_cexpr = "git_odb_object_size")] 314 get; 315 } 316 317 /** 318 * The id of an ODB object 319 */ 320 public object_id? id { 321 [CCode(cname = "git_odb_object_id")] 322 get; 323 } 324 325 /** 326 * The type of an ODB object 327 */ 328 public ObjectType type { 329 [CCode(cname = "git_odb_object_type")] 330 get; 331 } 332 } 333 334 /** 335 * A custom backend in an ODB 336 */ 337 [CCode(cname = "git_odb_backend", has_type_id = false, default_value = "GIT_ODB_BACKEND_INIT")] 338 public struct backend { 339 [CCode(cname = "GIT_ODB_BACKEND_VERSION")] 340 public const uint VERSION; 341 public uint version; 342 public unowned Handle odb; 343 344 public BackendExists exists; 345 public BackendFree free; 346 [CCode(cname = "foreach")] 347 public BackendForEach for_each; 348 public BackendRead read; 349 public BackendReadHeader read_header; 350 public BackendReadPrefix read_prefix; 351 [CCode(cname = "readstream")] 352 public BackendReadStream read_stream; 353 public BackendWrite write; 354 public BackendWritePack write_pack; 355 [CCode(cname = "writestream")] 356 public BackendWriteStream write_stream; 357 358 [CCode(cname = "git_odb_backend_loose")] 359 public static Error create_loose(out backend backend, string objects_dir); 360 [CCode(cname = "git_odb_backend_one_pack")] 361 public static Error create_one_pack(out backend backend, string index_file); 362 [CCode(cname = "git_odb_backend_pack")] 363 public static Error create_pack(out backend backend, string objects_dir); 364 [CCode(cname = "git_odb_backend_malloc", simple_generics = true)] 365 public T malloc<T>(size_t len); 366 } 367 368 /** 369 * A stream to read/write from the ODB 370 */ 371 [CCode(cname = "git_odb_stream", has_type_id = false)] 372 public struct stream { 373 public unowned backend? backend; 374 375 public StreamMode mode; 376 377 public StreamFinalizeWrite finalize_write; 378 public StreamFree free; 379 public StreamRead read; 380 public StreamWrite write; 381 } 382 /** 383 * A stream to write a pack file to the ODB 384 */ 385 [CCode(cname = "git_odb_writepack", has_type_id = false)] 386 public struct write_pack { 387 public unowned backend? backend; 388 [CCode(cname = "add")] 389 public WritePackAdd add; 390 [CCode(cname = "commit")] 391 public WritePackCommit commit; 392 [CCode(cname = "free")] 393 public WritePackFree free; 394 } 395 /** 396 * Streaming mode 397 */ 398 [CCode(cname = "git_odb_streammode", cprefix = "GIT_STREAM_", has_type_id = false)] 399 public enum StreamMode { 400 RDONLY, 401 WRONLY, 402 RW 403 } 404 [CCode(has_target = false, has_type_id = false)] 405 public delegate bool BackendExists(backend self, object_id id); 406 [CCode(has_target = false, has_type_id = false)] 407 public delegate void BackendFree(backend self); 408 [CCode(has_target = false, has_type_id = false)] 409 public delegate Error BackendForEach(backend self, ObjectIdForEach cb); 410 /** 411 * Read each return to libgit2 a buffer which will be freed later. 412 * 413 * The buffer should be allocated using the function {@link backend.malloc} to 414 * ensure that it can be safely freed later. 415 */ 416 [CCode(has_target = false, has_type_id = false)] 417 public delegate Error BackendRead([CCode(array_length_type = "size_t")] out uint8[] data, out ObjectType type, backend self, object_id id); 418 /** 419 * Find a unique object given a prefix 420 * 421 * The id given must be so that the remaining 422 * ({@link object_id.HEX_SIZE} - len)*4 bits are 0s. 423 */ 424 [CCode(has_target = false, has_type_id = false)] 425 public delegate Error BackendReadHeader(out size_t size, out ObjectType type, backend self, object_id id); 426 [CCode(has_target = false, has_type_id = false)] 427 public delegate Error BackendReadPrefix(out object_id id, [CCode(array_length_type = "size_t")] out uint8[] data, out ObjectType type, backend self, object_id id_prefix, size_t len); 428 [CCode(has_target = false, has_type_id = false)] 429 public delegate Error BackendReadStream(out stream stream, backend self, object_id id); 430 [CCode(has_target = false, has_type_id = false)] 431 public delegate Error BackendWrite(out object_id id, backend self, [CCode(array_length_type = "size_t")] out uint8[] data, ObjectType type); 432 [CCode(has_target = false, has_type_id = false)] 433 public delegate Error BackendWriteStream(out stream stream, backend self, size_t size, ObjectType type); 434 [CCode(has_target = false, has_type_id = false)] 435 public delegate int BackendWritePack(out write_pack write_pack, backend self, TransferProgress progress); 436 437 [CCode(has_target = false, has_type_id = false)] 438 public delegate Error StreamFinalizeWrite(out object_id id, stream stream); 439 [CCode(has_target = false, has_type_id = false)] 440 public delegate void StreamFree(stream stream); 441 [CCode(has_target = false, has_type_id = false)] 442 public delegate int StreamRead(stream stream, [CCode(array_length_type = "size_t")] uint8[] buffer); 443 [CCode(has_target = false, has_type_id = false)] 444 public delegate int StreamWrite(stream stream, [CCode(array_length_type = "size_t")] uint8[] buffer); 445 446 [CCode(has_target = false)] 447 public delegate int WritePackAdd(write_pack write_pack, [CCode(array_length_type = "size_t")] uint8[] data, transfer_progress stats); 448 [CCode(has_target = false)] 449 public delegate int WritePackCommit(write_pack write_pack, transfer_progress stats); 450 [CCode(has_target = false)] 451 public delegate void WritePackFree(write_pack write_pack); 452 } 453 namespace Threads { 454 /** 455 * Init the threading system. 456 * 457 * If libgit2 has been built with GIT_THREADS 458 * on, this function must be called once before 459 * any other library functions. 460 * 461 * If libgit2 has been built without GIT_THREADS 462 * support, this function is a no-op. 463 */ 464 [CCode(cname = "git_threads_init")] 465 public Error init(); 466 467 /** 468 * Shutdown the threading system. 469 * 470 * If libgit2 has been built with GIT_THREADS 471 * on, this function must be called before shutting 472 * down the library. 473 * 474 * If libgit2 has been built without GIT_THREADS 475 * support, this function is a no-op. 476 */ 477 [CCode(cname = "git_threads_shutdown")] 478 public void shutdown(); 479 } 480 namespace Version { 481 [CCode(cname = "LIBGIT2_VERSION")] 482 public const string VERSION; 483 [CCode(cname = "LIBGIT2_VER_MAJOR")] 484 public const int MAJOR; 485 [CCode(cname = "LIBGIT2_VER_MINOR")] 486 public const int MINOR; 487 [CCode(cname = "LIBGIT2_VER_REVISION")] 488 public const int REVISION; 489 /** 490 * Return the version of the libgit2 library 491 * being currently used. 492 * 493 * @param major Store the major version number 494 * @param minor Store the minor version number 495 * @param rev Store the revision (patch) number 496 */ 497 [CCode(cname = "git_libgit2_version")] 498 public void get_version(out int major, out int minor, out int rev); 499 } 500 501 /* 502 * Attribute management routines 503 */ 504 [CCode(cname = "git_repository", cheader_filename = "git2/attr.h", has_type_id = false)] 505 public class Attr { 506 [CCode(cname = "git_attr_t", cprefix = "GIT_ATTR_", has_type_id = false)] 507 public enum AttrType { 508 [CCode(cname = "GIT_ATTR_UNSPECIFIED_T")] 509 UNSPECIFIED, 510 [CCode(cname = "GIT_ATTR_TRUE_T")] 511 TRUE, 512 [CCode(cname = "GIT_ATTR_FALSE_T")] 513 FALSE, 514 [CCode(cname = "GIT_ATTR_VALUE_T")] 515 VALUE; 516 /** 517 * Return the value type for a given attribute. 518 * 519 * This can be either {@link TRUE}, {@link FALSE}, {@link UNSPECIFIED} 520 * (if the attribute was not set at all), or {@link VALUE}, if the 521 * attribute was set to an actual string. 522 * 523 * If the attribute has a {@link VALUE} string, it can be accessed 524 * normally as a string. 525 */ 526 [CCode(cname = "git_attr_value")] 527 public static AttrType from(string attr); 528 } 529 530 /** 531 * Checks if an attribute is set on. 532 * 533 * In core git parlance, this the value for "Set" attributes. 534 */ 535 [CCode(cname = "GIT_ATTR_TRUE")] 536 public static bool is_true(string? attr); 537 /** 538 * Checks if an attribute is set off. 539 * 540 * In core git parlance, this is the value for attributes that are "Unset" 541 * (not to be confused with values that a "Unspecified"). 542 */ 543 [CCode(cname = "GIT_ATTR_FALSE")] 544 public static bool is_false(string? attr); 545 /** 546 * Checks if an attribute is set to a value (as opposied to TRUE, FALSE or 547 * UNSPECIFIED). 548 */ 549 [CCode(cname = "GIT_ATTR_SET_TO_VALUE")] 550 public static bool is_set(string? attr); 551 /* 552 * Checks if an attribute is unspecified. This may be due to the attribute 553 * not being mentioned at all or because the attribute was explicitly set 554 * unspecified via the `!` operator. 555 */ 556 [CCode(cname = "GIT_ATTR_UNSPECIFIED")] 557 public static bool is_unspecified(string? attr); 558 559 /** 560 * Add a macro definition. 561 * 562 * Macros will automatically be loaded from the top level .gitattributes 563 * file of the repository (plus the build-in "binary" macro). This 564 * function allows you to add others. For example, to add the default 565 * macro, you would call: 566 * {{{ 567 * repo.attributes.add_macro("binary", "-diff -crlf"); 568 * }}} 569 */ 570 [CCode(cname = "git_attr_add_macro")] 571 public Error add_macro(string name, string val); 572 573 /** 574 * Lookup attribute for path returning string caller must free 575 */ 576 [CCode(cname = "git_attr_get")] 577 public Error lookup(AttrCheck flags, string path, string name, out unowned string? val); 578 579 /** 580 * Lookup list of attributes for path, populating array of strings 581 * 582 * Use this if you have a known list of attributes that you want to 583 * look up in a single call. This is somewhat more efficient than 584 * calling {@link lookup} multiple times. 585 * 586 * For example, you might write: 587 * {{{ 588 * string attrs[] = { "crlf", "diff", "foo" }; 589 * string results[]; 590 * repo.attributes.lookup_many(AttrCheck.FILE_THEN_INDEX, "my/fun/file.c", attrs, out values); 591 * }}} 592 * Then you could loop through the 3 values to get the settings for 593 * the three attributes you asked about. 594 * 595 * @param path The path inside the repo to check attributes. This does not 596 * have to exist, but if it does not, then it will be treated as a plain 597 * file (i.e. not a directory). 598 * @param names The attribute names. 599 * @param values The values of the attributes. 600 */ 601 [CCode(cname = "_vala_git_attr_get_many")] 602 public Error lookup_many(AttrCheck flags, string path, string[] names, out string[] values) { 603 unstr[] temp = new unstr[names.length]; 604 var e = _lookup_many(flags, path, names, temp); 605 values = new string[names.length]; 606 for (var it = 0; it < temp.length; it++) { 607 values[it] = temp[it].dup(); 608 } 609 return e; 610 } 611 612 [CCode(cname = "git_attr_get_many")] 613 private Error _lookup_many(AttrCheck flags, string path, [CCode(array_length_pos = 2.1, array_length_type = "size_t")] string[] names, void* values); 614 615 /** 616 * Perform an operation on each attribute of a path. 617 * @param path The path inside the repo to check attributes. This does not 618 * have to exist, but if it does not, then it will be treated as a plain 619 * file (i.e. not a directory). 620 * @param attribute_for_each The function that will be invoked on each 621 * attribute and attribute value. The name parameter will be the name of 622 * the attribute and the value will be the value it is set to, including 623 * possibly null if the attribute is explicitly set to UNSPECIFIED using 624 * the ! sign. This will be invoked only once per attribute name, even if 625 * there are multiple rules for a given file. The highest priority rule 626 * will be used. 627 */ 628 [CCode(cname = "git_attr_foreach")] 629 public Error for_each(AttrCheck flags, string path, AttributeForEach attribute_for_each); 630 631 /** 632 * Flush the gitattributes cache. 633 * 634 * Call this if you have reason to believe that the attributes files 635 * on disk no longer match the cached contents of memory. This will cause 636 * the attributes files to be reloaded the next time that an attribute 637 * access function is called. 638 */ 639 [CCode(cname = "git_attr_cache_flush")] 640 public void flush(); 641 } 642 643 /** 644 * In-memory representation of a blob object. 645 */ 646 [CCode(cname = "git_blob", free_function = "git_blob_free", has_type_id = false)] 647 [Compact] 648 public class Blob : Object { 649 [CCode(array_length = false, cname = "git_blob_rawcontent")] 650 private unowned uint8[]? _get_content(); 651 652 /** 653 * Get a read-only buffer with the raw content of a blob. 654 * 655 * A pointer to the raw content of a blob is returned. 656 * The pointer may be invalidated at a later time. 657 */ 658 public uint8[]? content { 659 get { 660 unowned uint8[]? content = _get_content(); 661 if (content != null) { 662 ((!)content).length = (int) size; 663 } 664 return content; 665 } 666 } 667 /** 668 * The id of a blob. 669 */ 670 public object_id? id { 671 [CCode(cname = "git_blob_id")] 672 get; 673 } 674 /** 675 * Determine if the blob content is most certainly binary or not. 676 * 677 * The heuristic used to guess if a file is binary is taken from core git: 678 * Searching for NUL bytes and looking for a reasonable ratio of printable 679 * to non-printable characters among the first 4000 bytes. 680 */ 681 public bool is_binary { 682 [CCode(cname = "git_blob_is_binary")] 683 get; 684 } 685 686 /** 687 * Get the size in bytes of the contents of a blob 688 */ 689 public size_t size { 690 [CCode(cname = "git_blob_rawsize")] 691 get; 692 } 693 /** 694 * Directly run a text diff on two blobs. 695 * 696 * Compared to a file, a blob lacks some contextual information. As such, the 697 * {@link diff_file} parameters of the callbacks will be filled accordingly to the following: 698 * mode will be set to 0, path will be null. When dealing with a null blob, object id 699 * will be set to 0. 700 * 701 * When at least one of the blobs being dealt with is binary, the {@link diff_delta} binary 702 * attribute will be set to true and no call to the hunk nor line will be made. 703 * 704 * We do run a binary content check on the two blobs and if either of the 705 * blobs looks like binary data, {@link diff_delta.flags} will {@link DiffFlag.BINARY} 706 * and no call to the {@link DiffHunk} nor {@link DiffData} will be made 707 * (unless you pass {@link DiffFlags.FORCE_TEXT} of course). 708 */ 709 [CCode(cname = "git_diff_blobs", simple_generics = true)] 710 public Error diff<T>(Blob new_blob, diff_options options, DiffFile<T> file, DiffHunk<T> hunk, DiffData<T> line, T context); 711 /** 712 * Directly run a diff between a blob and a buffer. 713 * 714 * As with {@link diff}, comparing a blob and buffer lacks some context, so 715 * the {@link diff_file} parameters to the callbacks will be faked. 716 */ 717 [CCode(cname = "git_diff_blob_to_buffer", simple_generics = true)] 718 public Error diff_buffer<T>([CCode(array_length_type = "size_t")] uint8[] buffer, diff_options options, DiffFile<T> file, DiffHunk<T> hunk, DiffData<T> line, T context); 719 } 720 721 /** 722 * Parsed representation of a commit object. 723 */ 724 [CCode(cname = "git_commit", free_function = "git_commit_free", has_type_id = false)] 725 [Compact] 726 public class Commit : Object { 727 /** 728 * The author of a commit. 729 */ 730 public Signature author { 731 [CCode(cname = "git_commit_author")] 732 get; 733 } 734 735 /** 736 * The committer of a commit. 737 */ 738 public Signature committer { 739 [CCode(cname = "git_commit_committer")] 740 get; 741 } 742 743 /** 744 * The id of a commit. 745 */ 746 public object_id? id { 747 [CCode(cname = "git_commit_id")] 748 get; 749 } 750 751 /** 752 * The full message of a commit. 753 */ 754 public string message { 755 [CCode(cname = "git_commit_message")] 756 get; 757 } 758 759 /** 760 * The encoding for the message of a commit, as a string representing a 761 * standard encoding name. 762 * 763 * The encoding may be null if the encoding header in the commit is 764 * missing; in that case UTF-8 is assumed. 765 */ 766 public string? message_encoding { 767 [CCode(cname = "git_commit_message_encoding")] 768 get; 769 } 770 771 /** 772 * The parent(s) of this commit 773 * 774 * Typically, commits have a single parent, but merges can have many. 775 */ 776 public Parents parents { 777 [CCode(cname = "")] 778 get; 779 } 780 781 /** 782 * Get the commit time (i.e., committer time) of a commit. 783 */ 784 public int64 time { 785 [CCode(cname = "git_commit_time")] 786 get; 787 } 788 789 /** 790 * Get the commit timezone offset (i.e., committer's preferred timezone) in minutes from UTC of a commit. 791 */ 792 public int time_offset { 793 [CCode(cname = "git_commit_time_offset")] 794 get; 795 } 796 797 /** 798 * Get the id of the tree pointed to by a commit. 799 * 800 * This differs from {@link lookup_tree} in that no attempts 801 * are made to fetch an object from the ODB. 802 */ 803 public object_id? tree_id { 804 [CCode(cname = "git_commit_tree_oid")] 805 get; 806 } 807 /** 808 * Get the commit object that is an ancestor of the named commit object, 809 * following only the first parents. 810 * 811 * @param ancestor the ancestor received, if any 812 * @param n the requested generation, or 0 for a copy of the commit. 813 */ 814 [CCode(cname = "git_commit_nth_gen_ancestor", instance_pos = 1.2)] 815 public Error get_ancestor(out Commit? ancestor, uint n); 816 817 /** 818 * The message of a commit converted to UTF-8. 819 */ 820 public string? get_message_utf8() throws GLib.ConvertError { 821 return this.message_encoding == null ? this.message : GLib.convert(this.message, this.message.length, "utf-8", (!) this.message_encoding); 822 } 823 824 /** 825 * Get the tree pointed to by a commit. 826 */ 827 [CCode(cname = "git_commit_tree", instance_pos = -1)] 828 public Error lookup_tree(out Tree tree); 829 } 830 831 /** 832 * Memory representation of a set of config files 833 */ 834 [CCode(cname = "git_config", free_function = "git_config_free", has_type_id = false)] 835 [Compact] 836 public class Config { 837 /** 838 * Allocate a new configuration object 839 * 840 * This object is empty, so you have to add a file to it before you can do 841 * anything with it. 842 * 843 * @param config the new configuration 844 */ 845 [CCode(cname = "git_config_new")] 846 public static Error create(out Config config); 847 848 /** 849 * Locate the path to the global configuration file 850 * 851 * The user or global configuration file is usually located in 852 * //$HOME/.gitconfig//. 853 * 854 * This method will try to guess the full path to that file, if the file 855 * exists. The returned path may be used on any call to load the global 856 * configuration file. 857 * 858 * @param config_path Buffer store the path 859 * @return {@link Error.OK} if a global configuration file has been found. 860 */ 861 [CCode(cname = "git_config_find_global")] 862 public static Error find_global([CCode(array_length_type = "size_t")] char[] config_path); 863 /** 864 * Locate the path to the global xdg compatible configuration file 865 * 866 * The xdg compatible configuration file is usually located in 867 * //$HOME/.config/git/config//. 868 * 869 * This method will try to guess the full path to that file, if the file 870 * exists. 871 * @param config_path Buffer store the path 872 * @return {@link Error.OK} if an XDG configuration file has been found. 873 */ 874 [CCode(cname = "git_config_find_xdg")] 875 public static Error find_xdg([CCode(array_length_type = "size_t")] char[] config_path); 876 877 /** 878 * Locate the path to the system configuration file 879 * 880 * If /etc/gitconfig doesn't exist, it will look for 881 * %PROGRAMFILES%\Git\etc\gitconfig. 882 * @param config_path Buffer of {@link PATH_MAX} length to store the path 883 * @return {@link Error.OK} if a system configuration file has been found. Its path will be stored in //buffer//. 884 */ 885 [CCode(cname = "git_config_find_system")] 886 public static Error find_system([CCode(array_length_type = "size_t")] char[] config_path); 887 888 889 /** 890 * Maps a string value to an integer constant 891 */ 892 [CCode(cname = "git_config_lookup_map_value")] 893 public static Error lookup_map_value(out int result, [CCode(array_length_type = "size_t")] config_var_map[] map, string name); 894 895 /** 896 * Create a new config instance containing a single on-disk file 897 * 898 * This method is a simple utility wrapper for the following sequence of 899 * calls: 900 * * {@link create} 901 * * {@link add_filename} 902 * 903 * @param cfg the configuration instance to create 904 * @param path path to the on-disk file to open 905 */ 906 [CCode(cname = "git_config_open_ondisk")] 907 public static Error open(out Config? cfg, string path); 908 909 /** 910 * Open the global and system configuration files 911 * 912 * Utility wrapper that calls {@link find_global}, {@link find_xdg}, and 913 * {@link find_system} and opens the located file, if it exists. 914 * 915 * @param config where to store the config instance 916 */ 917 [CCode(cname = "git_config_open_default")] 918 public static Error open_default(out Config? config); 919 920 /** 921 * Build a single-level focused config object from a multi-level one. 922 * 923 * The returned config object can be used to perform get/set/delete 924 * operations on a single specific level. 925 * 926 * Getting several times the same level from the same parent multi-level 927 * config will return different config instances, but containing the same 928 * config_file instance. 929 * 930 * @param parent Multi-level config to search for the given level 931 * @param level Configuration level to search for 932 */ 933 [CCode(cname = "git_config_open_level")] 934 public static Error open_level(out Config? config, Config parent, ConfigLevel level); 935 936 /** 937 * Parse a string value as a bool. 938 * 939 * Valid values for true are: 'true', 'yes', 'on', 1 or any number 940 * different from 0 941 * 942 * Valid values for false are: 'false', 'no', 'off', 0 943 */ 944 [CCode(cname = "git_config_parse_bool")] 945 public static Error bool(out bool result, string @value); 946 947 /** 948 * Parse a string value as an int32. 949 * 950 * An optional value suffix of 'k', 'm', or 'g' will cause the value to be 951 * multiplied by 1024, 1048576, or 1073741824 prior to output. 952 */ 953 [CCode(cname = "git_config_parse_int32")] 954 public static Error parse_int32(out int32 result, string @value); 955 956 /** 957 * Parse a string value as an int64. 958 * 959 * An optional value suffix of 'k', 'm', or 'g' will cause the value to be 960 * multiplied by 1024, 1048576, or 1073741824 prior to output. 961 */ 962 [CCode(cname = "git_config_parse_int64")] 963 public static Error parse_int64(out int64 result, string @value); 964 965 /** 966 * Add a generic config file instance to an existing config 967 * 968 * Further queries on this config object will access each of the config 969 * file instances in order (instances with a higher priority will be 970 * accessed first). 971 * 972 * @param backend the configuration file (backend) to add 973 * @param level the priority level of the backend 974 * @param force if a config file already exists for the given priority level, replace it 975 */ 976 [CCode(cname = "git_config_add_backend")] 977 public Error add_backend(Configuration.backend backend, ConfigLevel level, bool force); 978 979 /** 980 * Add an on-disk config file instance to an existing config 981 * 982 * The on-disk file pointed at by path will be opened and parsed; it's 983 * expected to be a native Git config file following the default Git config 984 * syntax (see man git-config). 985 * 986 * Further queries on this config object will access each of the config 987 * file instances in order (instances with a higher priority will be 988 * accessed first). 989 * 990 * @param path path to the configuration file (backend) to add 991 * @param level the priority the backend should have 992 */ 993 [CCode(cname = "git_config_add_file_ondisk")] 994 public Error add_filename(string path, ConfigLevel level, bool force); 995 996 /** 997 * Delete a config variable 998 * 999 * @param name the variable to delete 1000 */ 1001 [CCode(cname = "git_config_delete_entry")] 1002 public Error delete(string name); 1003 1004 /** 1005 * Perform an operation on each config variable. 1006 * 1007 * The callback receives the normalized name and value of each variable in 1008 * the config backend. As soon as one of the callback functions returns 1009 * something other than 0, this function returns that value. 1010 * 1011 * @param config_for_each the function to call on each variable 1012 */ 1013 [CCode(cname = "git_config_foreach")] 1014 public int for_each(ConfigForEach config_for_each); 1015 /** 1016 * Perform an operation on each config variable matching a regular expression. 1017 * 1018 * This behaviors like {@link for_each} with an additional filter of a 1019 * regular expression that filters which config keys are passed to the 1020 * callback. 1021 * 1022 * @param regexp regular expression to match against config names 1023 * @param config_for_each the function to call on each variable 1024 * @return 0 or the return value of the callback which didn't return 0 1025 */ 1026 [CCode(cname = "git_config_foreach_match")] 1027 public int for_each_match(string regexp, ConfigForEach config_for_each); 1028 1029 /** 1030 * Get the value of a boolean config variable. 1031 * 1032 * @param name the variable's name 1033 * @param value where the value should be stored 1034 */ 1035 [CCode(cname = "git_config_get_bool")] 1036 public Error get_bool(string name, out bool value); 1037 1038 /** 1039 * Get the entry of a config variable. 1040 * @param name the variable's name 1041 */ 1042 [CCode(cname = "git_config_get_entry", instance_pos = 1.1)] 1043 public Error get_entry(out unowned config_entry? entry, string name); 1044 1045 /** 1046 * Get the value of an integer config variable. 1047 * 1048 * @param name the variable's name 1049 * @param value where the value should be stored 1050 */ 1051 [CCode(cname = "git_config_get_int")] 1052 public Error get_int32(string name, out int32 value); 1053 1054 /** 1055 * Get the value of a long integer config variable. 1056 * 1057 * @param name the variable's name 1058 * @param value where the value should be stored 1059 */ 1060 [CCode(cname = "git_config_get_int64")] 1061 public Error get_int64(string name, out int64 value); 1062 1063 /** 1064 * Get each value of a multivar. 1065 * 1066 * The callback will be called on each variable found 1067 * 1068 * @param name the variable's name 1069 * @param regexp regular expression to filter which variables we're interested in. Use NULL to indicate all 1070 * @param fn the function to be called on each value of the variable 1071 */ 1072 [CCode(cname = "git_config_get_multivar")] 1073 public Error get_multivar(string name, string? regexp, Configuration.Setter fn); 1074 1075 /** 1076 * Get the value of a string config variable. 1077 * 1078 * @param name the variable's name 1079 * @param value the variable's value 1080 */ 1081 public Error get_string(string name, out unowned string value); 1082 1083 /** 1084 * Reload changed config files 1085 * 1086 * A config file may be changed on disk out from under the in-memory config 1087 * object. This function causes us to look for files that have been 1088 * modified since we last loaded them and refresh the config with the 1089 * latest information. 1090 */ 1091 [CCode(cname = "git_config_refresh")] 1092 public Error refresh(); 1093 /** 1094 * Set the value of a boolean config variable. 1095 * 1096 * @param name the variable's name 1097 * @param value the value to store 1098 */ 1099 [CCode(cname = "git_config_set_bool")] 1100 public Error set_bool(string name, bool value); 1101 1102 /** 1103 * Set the value of an integer config variable. 1104 * 1105 * @param name the variable's name 1106 * @param value integer value for the variable 1107 */ 1108 [CCode(cname = "git_config_set_int32")] 1109 public Error set_int32(string name, int32 value); 1110 1111 /** 1112 * Set the value of a long integer config variable. 1113 * 1114 * @param name the variable's name 1115 * @param value Long integer value for the variable 1116 */ 1117 [CCode(cname = "git_config_set_long64")] 1118 public Error set_int64(string name, int64 value); 1119 1120 /** 1121 * Set a multivar 1122 * 1123 * @param name the variable's name 1124 * @param regexp a regular expression to indicate which values to replace 1125 * @param value the new value. 1126 */ 1127 [CCode(cname = "git_config_set_multivar")] 1128 public Error set_multivar(string name, string regexp, string @value); 1129 /** 1130 * Set the value of a string config variable. 1131 * 1132 * A copy of the string is made and the user is free to use it 1133 * afterwards. 1134 * 1135 * @param name the variable's name 1136 * @param value the string to store. 1137 */ 1138 [CCode(cname = "git_config_set_string")] 1139 public Error set_string(string name, string value); 1140 /** 1141 * Query the value of a config variable and return it mapped to an integer 1142 * constant. 1143 * 1144 * This is a helper method to easily map different possible values to a 1145 * variable to integer constants that easily identify them. 1146 * 1147 * A mapping array looks as follows: 1148 * {{{ 1149 * var autocrlf_mapping = Git.config_var_map[] { 1150 * {Git.ConfigVar.FALSE, null, GIT_AUTO_CRLF_FALSE}, 1151 * {Git.ConfigVar.TRUE, null, GIT_AUTO_CRLF_TRUE}, 1152 * {Git.ConfigVar.STRING, "input", GIT_AUTO_CRLF_INPUT}, 1153 * {Git.ConfigVar.STRING, "default", GIT_AUTO_CRLF_DEFAULT}}; 1154 * }}} 1155 * 1156 * On any "false" value for the variable (e.g. "false", "FALSE", "no"), the 1157 * mapping will store `GIT_AUTO_CRLF_FALSE` in the `out` parameter. 1158 * 1159 * The same thing applies for any "true" value such as "true", "yes" or "1", storing 1160 * the `GIT_AUTO_CRLF_TRUE` variable. 1161 * 1162 * Otherwise, if the value matches the string "input" (with case insensitive comparison), 1163 * the given constant will be stored in `out`, and likewise for "default". 1164 * 1165 * If not a single match can be made to store in `out`, an error code will be 1166 * returned. 1167 * 1168 * @param name name of the config variable to lookup 1169 * @param map array of objects specifying the possible mappings 1170 * @param result place to store the result of the mapping 1171 */ 1172 [CCode(cname = "git_config_get_mapped", instance_pos = 1.1)] 1173 public Error get_mapped(out int result, string name, [CCode(array_length_type = "size_t")] config_var_map[] map); 1174 1175 } 1176 /** 1177 * The diff list object that contains all individual file deltas. 1178 */ 1179 [CCode(cname = "git_diff_list", free_function = "git_diff_list_free")] 1180 [Compact] 1181 public class DiffList { 1182 /** 1183 * How many diff records are there in a diff list. 1184 */ 1185 public size_t num_deltas { 1186 [CCode(cname = "git_diff_num_deltas")] 1187 get; 1188 } 1189 /** 1190 * Query how many diff records are there in a diff list. 1191 * @param delta_t A delta type to filter the count, or -1 for all records 1192 * @return Count of number of deltas matching delta_t type 1193 */ 1194 [CCode(cname = "git_diff_num_deltas_of_type")] 1195 public size_t get_count(DeltaType delta_t = DeltaType.ALL); 1196 /** 1197 * Return the diff delta and patch for an entry in the diff list. 1198 * 1199 * For an unchanged file or a binary file, no patch will be created, and 1200 * the {@link diff_delta.flags} will contain {@link DiffFlag.BINARY}. 1201 * 1202 * @param patch contains the text diffs for the delta. 1203 * @param delta Output parameter for the delta object 1204 * @param idx Index into diff list 1205 */ 1206 [CCode(cname = "git_diff_get_patch", instance_pos = 2.1)] 1207 public Error get_patch(out Patch? patch, out unowned diff_delta? delta, size_t idx); 1208 /** 1209 * Merge one diff list into another. 1210 * 1211 * This merges items from the "from" list into the current list. The 1212 * resulting diff list will have all items that appear in either list. 1213 * If an item appears in both lists, then it will be "merged" to appear 1214 * as if the old version was from the "onto" list and the new version 1215 * is from the "from" list (with the exception that if the item has a 1216 * pending DELETE in the middle, then it will show as deleted). 1217 * 1218 * @param from Diff to merge. 1219 */ 1220 [CCode(cname = "git_diff_merge")] 1221 public Error merge(DiffList from); 1222 1223 /** 1224 * Iterate over a diff list issuing callbacks. 1225 * 1226 * If the hunk and/or line callbacks are not null, then this will calculate 1227 * text diffs for all files it thinks are not binary. If those are both 1228 * null, then this will not bother with the text diffs, so it can be 1229 * efficient. 1230 */ 1231 [CCode(cname = "git_diff_foreach", simple_generics = true)] 1232 public Error foreach<T>(DiffFile<T>? file, DiffHunk<T> hunk, DiffLine<T>? line, T context); 1233 1234 /** 1235 * Iterate over a diff generating text output like "git diff --name-status". 1236 */ 1237 [CCode(cname = "git_diff_print_compact")] 1238 public Error print_compact(DiffOutput print); 1239 1240 /** 1241 * Iterate over a diff generating text output like "git diff". 1242 * 1243 * This is a super easy way to generate a patch from a diff. 1244 */ 1245 [CCode(cname = "git_diff_print_patch")] 1246 public Error print_patch(DiffOutput print); 1247 /** 1248 * Transform a diff list marking file renames, copies, etc. 1249 * 1250 * This modifies a diff list in place, replacing old entries that look like 1251 * renames or copies with new entries reflecting those changes. This also 1252 * will, if requested, break modified files into add/remove pairs if the 1253 * amount of change is above a threshold. 1254 * 1255 * @param options Control how detection should be run, null for defaults 1256 */ 1257 [CCode(cname = "git_diff_find_similar")] 1258 public Error find_similar(find_options? options = null); 1259 } 1260 1261 [CCode(cname = "git_error", has_type_id = false, free_function = "")] 1262 public class ErrorInfo { 1263 /** 1264 * The explanation of the error. 1265 */ 1266 public string message; 1267 /** 1268 * The error code. 1269 */ 1270 [CCode(cname = "klass")] 1271 public ErrClass @class; 1272 /** 1273 * Return a detailed error string with the latest error 1274 * that occurred in the library in this thread. 1275 */ 1276 [CCode(cname = "giterr_last")] 1277 public static unowned ErrorInfo? get_last(); 1278 1279 /** 1280 * Clear the last library error for this thread. 1281 */ 1282 [CCode(cname = "giterr_clear")] 1283 public static void clear(); 1284 } 1285 1286 1287 /** 1288 * Object ID Shortener object 1289 */ 1290 [CCode(cname = "git_oid_shorten", free_function = "git_oid_shorten_free", has_type_id = false)] 1291 [Compact] 1292 public class IdShortener { 1293 /** 1294 * Create a new id shortener. 1295 * 1296 * The id shortener is used to process a list of ids in text form and 1297 * return the shortest length that would uniquely identify all of them. 1298 * 1299 * (e.g., look at the result of //git log --abbrev//) 1300 * 1301 * @param min_length The minimal length for all identifiers, which will be used even if shorter ids would still be unique. 1302 */ 1303 [CCode(cname = "git_oid_shorten_new")] 1304 public IdShortener(size_t min_length); 1305 1306 /** 1307 * Add a new id to set of shortened ids and calculate the minimal length to 1308 * uniquely identify all the ids in the set. 1309 * 1310 * The id is expected to be a 40-char hexadecimal string. 1311 * 1312 * For performance reasons, there is a hard-limit of how many ids can be 1313 * added to a single set (around ~22000, assuming a mostly randomized 1314 * distribution), which should be enough for any kind of program, and keeps 1315 * the algorithm fast and memory-efficient. 1316 * 1317 * Attempting to add more than those ids will result in a {@link ErrClass.NOMEMORY} error 1318 * 1319 * @param text_id an id in text form 1320 * @return the minimal length to uniquely identify all ids added so far to the set; or an error code (<0) if an error occurs. 1321 */ 1322 [CCode(cname = "git_oid_shorten_add")] 1323 public int add(string text_id); 1324 } 1325 1326 /** 1327 * Memory representation of an index file. 1328 */ 1329 [CCode(cname = "git_index", free_function = "git_index_free", has_type_id = false)] 1330 [Compact] 1331 public class Index { 1332 /** 1333 * Index capabilities flags. 1334 */ 1335 public IndexCapability capability { 1336 [CCode(cname = "git_index_caps")] 1337 get; 1338 [CCode(cname = "git_index_set_caps")] 1339 set; 1340 } 1341 1342 /** 1343 * Does the index contains entries representing file conflicts? 1344 */ 1345 public bool has_conflicts { 1346 [CCode(cname = "git_index_has_conflicts")] 1347 get; 1348 } 1349 1350 public ReucIndex reuc { 1351 [CCode(cname = "")] 1352 get; 1353 } 1354 1355 /** 1356 * The repository this index relates to 1357 */ 1358 public Repository owner { 1359 [CCode(cname = "git_index_owner")] 1360 get; 1361 } 1362 1363 /** 1364 * The count of entries currently in the index 1365 */ 1366 public uint size { 1367 [CCode(cname = "git_index_entrycount")] 1368 get; 1369 } 1370 1371 /** 1372 * Create an in-memory index object. 1373 * 1374 * This index object cannot be read/written to the filesystem, 1375 * but may be used to perform in-memory index operations. 1376 * 1377 * The index must be freed once it's no longer in use. 1378 */ 1379 [CCode(cname = "git_index_new")] 1380 public static Error create(out Index? index); 1381 /** 1382 * Create a new bare Git index object as a memory representation of the Git 1383 * index file in the index path, without a repository to back it. 1384 * 1385 * Since there is no ODB or working directory behind this index, any index 1386 * methods which rely on these (e.g., {@link add}) will fail. 1387 * 1388 * If you need to access the index of an actual repository, use {@link Repository.get_index}. 1389 * 1390 * @param index where to put the new index 1391 * @param index_path the path to the index file in disk 1392 */ 1393 public static Error open(out Index index, string index_path); 1394 1395 /** 1396 * Add or update an index entry from an in-memory struct 1397 * 1398 * A full copy (including the path string) of the given source will be 1399 * inserted on the index. 1400 * 1401 * @param entry new entry object 1402 */ 1403 [CCode(cname = "git_index_add")] 1404 public Error add(IndexEntry entry); 1405 1406 /** 1407 * Add (append) an index entry from a file on disk 1408 * 1409 * A new entry will always be inserted into the index; if the index already 1410 * contains an entry for such path, the old entry will ''not'' be replaced. 1411 * 1412 * The file path must be relative to the repository's working folder and 1413 * must be readable. 1414 * 1415 * This method will fail in bare index instances. 1416 * 1417 * This forces the file to be added to the index, not looking at gitignore 1418 * rules. 1419 * 1420 * If this file currently is the result of a merge conflict, this file will 1421 * no longer be marked as conflicting. The data about the conflict will be 1422 * moved to the "resolve undo" (REUC) section. 1423 * 1424 * @param path filename to add 1425 */ 1426 [CCode(cname = "git_index_add_bypath")] 1427 public Error add_path(string path); 1428 1429 /** 1430 * Clear the contents (all the entries) of an index object. 1431 * 1432 * This clears the index object in memory; changes must be manually written 1433 * to disk for them to take effect. 1434 */ 1435 [CCode(cname = "git_index_clear")] 1436 public void clear(); 1437 1438 /** 1439 * Add or update index entries to represent a conflict 1440 * 1441 * The entries are the entries from the tree included in the merge. Any 1442 * entry may be null to indicate that that file was not present in the 1443 * trees during the merge. For example, the ancestor entry may be null to 1444 * indicate that a file was added in both branches and must be resolved. 1445 * 1446 * @param ancestor_entry the entry data for the ancestor of the conflict 1447 * @param our_entry the entry data for our side of the merge conflict 1448 * @param their_entry the entry data for their side of the merge conflict 1449 */ 1450 [CCode(cname = "git_index_conflict_add")] 1451 public Error conflict_add(IndexEntry? ancestor_entry, IndexEntry? our_entry, IndexEntry? their_entry); 1452 1453 /** 1454 * Get the index entries that represent a conflict of a single file. 1455 * 1456 * The values of this entry can be modified (except the paths) 1457 * and the changes will be written back to disk on the next 1458 * write() call. 1459 * 1460 * @param ancestor Pointer to store the ancestor entry 1461 * @param our Pointer to store the our entry 1462 * @param their Pointer to store the their entry 1463 * @param path path to search 1464 */ 1465 [CCode(cname = "git_index_conflict_get", instance_pos = 3.1)] 1466 public Error conflict_get(out unowned IndexEntry? ancestor, out unowned IndexEntry? our, out unowned IndexEntry? their, string path); 1467 1468 /** 1469 * Remove all conflicts in the index (entries with a stage greater than 0.) 1470 */ 1471 [CCode(cname = "git_index_conflict_cleanup")] 1472 public void conflict_cleanup(); 1473 /** 1474 * Removes the index entries that represent a conflict of a single file. 1475 * 1476 * @param path to search 1477 */ 1478 [CCode(cname = "git_index_conflict_remove")] 1479 public Error conflict_remove(string path); 1480 1481 /** 1482 * Find the first index of any entries which point to given path in the Git 1483 * index. 1484 * 1485 * @param at_pos the address to which the position of the reuc entry is written (optional) 1486 * @param path path to search 1487 */ 1488 [CCode(cname = "git_index_find", instance_pos = 1.1)] 1489 public Error find(out size_t at_pos, string path); 1490 1491 /** 1492 * Get a pointer to one of the entries in the index 1493 * 1494 * This entry can be modified, and the changes will be written back to disk 1495 * on the next {@link write} call. 1496 * 1497 * @param n the position of the entry 1498 * @return the entry; null if out of bounds 1499 */ 1500 [CCode(cname = "git_index_get_byindex")] 1501 public unowned IndexEntry? get(size_t n); 1502 1503 /** 1504 * Get a pointer to one of the entries in the index 1505 * 1506 * The values of this entry can be modified (except the path) and the 1507 * changes will be written back to disk on the next {@link write} call. 1508 * 1509 * @param path path to search 1510 * @param stage stage to search 1511 */ 1512 [CCode(cname = "git_index_get_bypath")] 1513 public unowned IndexEntry? get_by_path(string path, int stage); 1514 1515 /** 1516 * Remove all entries with equal path except last added 1517 */ 1518 [CCode(cname = "git_index_uniq")] 1519 public void make_unique(); 1520 1521 /** 1522 * Update the contents of an existing index object in memory by reading 1523 * from the hard disk. 1524 */ 1525 [CCode(cname = "git_index_read")] 1526 public Error read(); 1527 1528 /** 1529 * Read a tree into the index file with stats 1530 * 1531 * The current index contents will be replaced by the specified tree. 1532 * 1533 * @param tree tree to read 1534 */ 1535 [CCode(cname = "git_index_read_tree")] 1536 public Error read_tree(Tree tree); 1537 1538 /** 1539 * Remove an entry from the index 1540 */ 1541 [CCode(cname = "git_index_remove")] 1542 public Error remove(string path, int stage); 1543 /** 1544 * Remove all entries from the index under a given directory 1545 * 1546 * @param dir container directory path 1547 * @param stage stage to search 1548 */ 1549 [CCode(cname = "git_index_remove_directory")] 1550 public Error remove_directory(string dir, int stage); 1551 1552 /** 1553 * Remove an index entry corresponding to a file on disk 1554 * 1555 * The file path must be relative to the repository's working folder. It 1556 * may exist. 1557 * 1558 * If this file currently is the result of a merge conflict, this file will 1559 * no longer be marked as conflicting. The data about the conflict will be 1560 * moved to the "resolve undo" (REUC) section. 1561 * 1562 * @param path filename to remove 1563 */ 1564 [CCode(cname = "git_index_remove_bypath")] 1565 public Error remove_path(string path); 1566 1567 /** 1568 * Write an existing index object from memory back to disk using an atomic 1569 * file lock. 1570 */ 1571 [CCode(cname = "git_index_write")] 1572 public Error write(); 1573 1574 /** 1575 * Write the index as a tree 1576 * 1577 * This method will scan the index and write a representation of its 1578 * current state back to disk; it recursively creates 1579 * tree objects for each of the subtrees stored in the index, but only 1580 * returns the OID of the root tree. This is the OID that can be used e.g. 1581 * to create a commit. 1582 * 1583 * The index instance cannot be bare, and needs to be associated to an 1584 * existing repository. 1585 * 1586 * The index must not contain any file in conflict. 1587 */ 1588 [CCode(cname = "git_index_write_tree", instance_pos = -1)] 1589 public Error write_tree(out object_id id); 1590 1591 /** 1592 * Write the index as a tree to the given repository 1593 * 1594 * This method will do the same as {@link write_tree}, but letting the user 1595 * choose the repository where the tree will be written. 1596 * 1597 * The index must not contain any file in conflict. 1598 * 1599 * @param id Pointer where to store OID of the the written tree 1600 * @param repo Repository where to write the tree 1601 */ 1602 [CCode(cname = "git_index_write_tree_to", instance_pos = 1.1)] 1603 public Error write_tree_to(out object_id id, Repository repo); 1604 1605 } 1606 1607 [CCode(cname = "git_indexer_stream", free_function = "git_indexer_stream_free", has_type_id = false)] 1608 public class IndexerStream { 1609 /** 1610 * The packfile's hash 1611 * 1612 * A packfile's name is derived from the sorted hashing of all object 1613 * names. This is only correct after the index has been finalized. 1614 */ 1615 public object_id? hash { 1616 [CCode(cname = "git_indexer_stream_hash")] 1617 get; 1618 } 1619 /** 1620 * Create a new streaming indexer instance 1621 * 1622 * @param indexer_stream where to store the indexer instance 1623 * @param path to the directory where the packfile should be stored 1624 */ 1625 [CCode(cname = "git_indexer_stream_new")] 1626 public static Error open(out IndexerStream indexer_stream, string path, TransferProgress transfer); 1627 1628 /** 1629 * Add data to the indexer 1630 * 1631 * @param data the data to add 1632 * @param stats stat storage 1633 */ 1634 [CCode(cname = "git_indexer_stream_add")] 1635 public Error add([CCode(array_length_type = "size_t")] uint8[] data, transfer_progress stats); 1636 1637 /** 1638 * Finalize the pack and index 1639 * 1640 * Resolve any pending deltas and write out the index file 1641 */ 1642 [CCode(cname = "git_indexer_stream_finalize")] 1643 public Error finalize(transfer_progress stats); 1644 } 1645 1646 /** 1647 * Memory representation of a file entry in the index. 1648 */ 1649 [CCode(cname = "git_index_entry", has_type_id = false)] 1650 [Compact] 1651 public class IndexEntry { 1652 public Attributes flags; 1653 public index_time ctime; 1654 public index_time mtime; 1655 public int64 file_size; 1656 [CCode(cname = "oid")] 1657 public object_id id; 1658 public string path; 1659 public uint16 flags_extended; 1660 public uint dev; 1661 public uint gid; 1662 public uint ino; 1663 public uint mode; 1664 public uint uid; 1665 1666 /** 1667 * The stage number from a git index entry 1668 */ 1669 public int stage { 1670 [CCode(cname = "git_index_entry_stage")] 1671 get; 1672 } 1673 } 1674 /** 1675 * A note attached to an object 1676 */ 1677 [CCode(cname = "git_note", free_function = "git_note_free", has_type_id = false)] 1678 [Compact] 1679 public class Note { 1680 /** 1681 * The message for this note 1682 */ 1683 public string message { 1684 [CCode(cname = "git_note_message")] 1685 get; 1686 } 1687 1688 /** 1689 * The note object OID 1690 */ 1691 public object_id? id { 1692 [CCode(cname = "git_note_oid")] 1693 get; 1694 } 1695 } 1696 [CCode(cname = "git_note_iterator ", free_function = "git_note_iterator_free", has_type_id = false)] 1697 [Compact] 1698 public class NoteIterator { 1699 /** 1700 * Returns the current item and advance the iterator internally to the next 1701 * value. 1702 */ 1703 [CCode(cname = "git_note_next", instance_pos = -1)] 1704 public Error next(out object_id note_id, out object_id annotated_id); 1705 } 1706 /** 1707 * Representation of a generic object in a repository 1708 */ 1709 [CCode(cname = "git_object", free_function = "git_object_free", has_type_id = false)] 1710 [Compact] 1711 public class Object { 1712 /** 1713 * The id (SHA1) of a repository object 1714 */ 1715 public object_id? id { 1716 [CCode(cname = "git_object_id")] 1717 get; 1718 } 1719 1720 /** 1721 * The object type of an object 1722 */ 1723 public ObjectType type { 1724 [CCode(cname = "git_object_type")] 1725 get; 1726 } 1727 1728 /** 1729 * The repository that owns this object 1730 */ 1731 public Repository repository { 1732 [CCode(cname = "git_object_owner")] 1733 get; 1734 } 1735 /** 1736 * Recursively peel an object until an object of the specified type is met 1737 * 1738 * @param target_type The type of the requested object 1739 */ 1740 [CCode(cname = "git_object_peel", instance_pos = 1.1)] 1741 public Error peel(out Object? peeled, ObjectType target_type); 1742 } 1743 1744 [Compact] 1745 [CCode(cname = "git_packbuilder", free_function = "git_packbuilder_free", has_type_id = false)] 1746 public class PackBuilder { 1747 1748 /** 1749 * The total number of objects the packbuilder will write out 1750 */ 1751 public uint32 count { 1752 [CCode(cname = "packbuilder_object_count")] 1753 get; 1754 } 1755 /** 1756 * The number of objects the packbuilder has already written out 1757 */ 1758 public uint32 written { 1759 [CCode(cname = "git_packbuilder_written")] 1760 get; 1761 } 1762 1763 /** 1764 * Set number of threads to spawn 1765 * 1766 * By default, libgit2 won't spawn any threads at all; when set to 0, 1767 * libgit2 will autodetect the number of CPUs. 1768 * 1769 * @param n Number of threads to spawn 1770 * @return number of actual threads to be used 1771 */ 1772 [CCode(cname = "git_packbuilder_set_threads")] 1773 public uint set_threads(uint n); 1774 1775 /** 1776 * Insert a single object 1777 * 1778 * For an optimal pack it's mandatory to insert objects in recency order, 1779 * commits followed by trees and blobs. 1780 * 1781 * @param id The oid of the commit 1782 * @param name The name 1783 */ 1784 [CCode(cname = "git_packbuilder_insert")] 1785 public Error insert(object_id id, string? name); 1786 /** 1787 * Insert a root tree object 1788 * 1789 * This will add the tree as well as all referenced trees and blobs. 1790 * 1791 * @param id The oid of the root tree 1792 */ 1793 [CCode(cname = "git_packbuilder_insert_tree")] 1794 public Error insert_tree(object_id id); 1795 1796 /** 1797 * Write the new pack and the corresponding index to path 1798 * 1799 * @param path Directory to store the new pack and index 1800 */ 1801 [CCode(cname = "git_packbuilder_write")] 1802 public Error write(string path); 1803 1804 /** 1805 * Create the new pack and pass each object to the callback 1806 */ 1807 [CCode(cname = "git_packbuilder_foreach")] 1808 public Error for_each(PackBuilderForEach pack_builder_for_each); 1809 } 1810 /** 1811 * The list of parents of a commit 1812 */ 1813 [Compact] 1814 [CCode(cname = "git_commit", has_type_id = false)] 1815 public class Parents { 1816 /** 1817 * Get the number of parents of this commit 1818 */ 1819 public uint size { 1820 [CCode(cname = "git_commit_parentcount")] 1821 get; 1822 } 1823 1824 /** 1825 * Get the id of a specified parent for a commit. 1826 * 1827 * This is different from {@link Parents.lookup}, which will attempt 1828 * to load the parent commit from the ODB. 1829 * 1830 * @param n the position of the parent 1831 * @return the id of the parent, null on error. 1832 */ 1833 [CCode(cname = "git_commit_parent_id")] 1834 public unowned object_id? get(uint n); 1835 1836 /** 1837 * Get the specified parent of the commit. 1838 * 1839 * @param parent where to store the parent commit 1840 * @param n the position of the parent 1841 */ 1842 [CCode(cname = "git_commit_parent", instance_pos = 1.2)] 1843 public Error lookup(out Commit parent, uint n); 1844 } 1845 [CCode(cname = "git_diff_patch ", free_function = "git_diff_patch_free", has_type_id = false)] 1846 [Compact] 1847 public class Patch { 1848 /** 1849 * The delta associated with a patch 1850 */ 1851 public diff_delta? delta { 1852 [CCode(cname = "git_diff_patch_delta")] 1853 get; 1854 } 1855 /** 1856 * The number of hunks in a patch 1857 */ 1858 public size_t num_hunks { 1859 [CCode(cname = "git_diff_patch_num_hunks")] 1860 get; 1861 } 1862 /** 1863 * Get the information about a hunk in a patch 1864 * 1865 * Given a patch and a hunk index into the patch, this returns detailed 1866 * information about that hunk. Any of the output pointers can be passed 1867 * as NULL if you don't care about that particular piece of information. 1868 * 1869 * @param range Range of the hunk 1870 * @param header Header string for hunk. Unlike the content for each line, 1871 * this will be NUL-terminated 1872 * @param lines_in_hunk Count of total lines in this hunk 1873 * @param hunk_idx Input index of hunk to get information about 1874 */ 1875 [CCode(cname = "git_diff_patch_get_hunk", instance_pos = 3.1)] 1876 public Error get_hunk(out unowned diff_range? range, [CCode(array_length_type = "size_t")] out unowned uint8[]? header, out size_t lines_in_hunk, size_t hunk_idx); 1877 /** 1878 * Get data about a line in a hunk of a patch. 1879 * 1880 * Given a patch, a hunk index, and a line index in the hunk, this will 1881 * return a lot of details about that line. If you pass a hunk index 1882 * larger than the number of hunks or a line index larger than the number 1883 * of lines in the hunk, this will return -1. 1884 * 1885 * @param old_lineno Line number in old file or -1 if line is added 1886 * @param new_lineno Line number in new file or -1 if line is deleted 1887 * @param hunk_idx The index of the hunk 1888 * @param line_of_hunk The index of the line in the hunk 1889 */ 1890 [CCode(cname = "git_diff_patch_get_line_in_hunk", instance_pos = 4.1)] 1891 public Error get_line_in_hunk(out DiffLineType line_origin, [CCode(array_length_type = "size_t")] out unowned uint8[]? content, out int old_lineno, out int new_lineno, size_t hunk_idx, size_t line_of_hunk); 1892 /** 1893 * Get line counts of each type in a patch. 1894 * 1895 * This helps imitate a '''diff --numstat''' type of output. For that 1896 * purpose, you only need the total additions and total_deletions values, 1897 * but we include the total context line count in case you want the total 1898 * number of lines of diff output that will be generated. 1899 * 1900 * @param total_context Count of context lines in output. 1901 * @param total_additions Count of addition lines in output. 1902 * @param total_deletions Count of deletion lines in output. 1903 * @return Number of lines in hunk or -1 if invalid hunk index 1904 */ 1905 [CCode(cname = "git_diff_patch_line_stats", instance_pos = -1)] 1906 public int get_line_stats(out size_t total_context, out size_t total_additions, out size_t total_deletions); 1907 1908 /** 1909 * Get the number of lines in a hunk. 1910 * 1911 * @param hunk_idx Index of the hunk 1912 * @return Number of lines in hunk or -1 if invalid hunk index 1913 */ 1914 [CCode(cname = "git_diff_patch_num_lines_in_hunk")] 1915 public int num_lines_in_hunk(size_t hunk_idx); 1916 1917 /** 1918 * Serialize the patch to text via callback. 1919 */ 1920 [CCode(cname = "git_diff_patch_print")] 1921 public Error patch_print(DiffOutput print); 1922 1923 /** 1924 * Get the content of a patch as a single diff text. 1925 */ 1926 [CCode(cname = "git_diff_patch_to_str", instance_pos = -1)] 1927 public Error to_str(out string str); 1928 1929 public string? to_string() { 1930 string? str; 1931 return to_str(out str) == Error.OK ? str : null; 1932 } 1933 } 1934 [Compact] 1935 [CCode(cname = "git_push", free_function = "git_push_free", has_type_id = false)] 1936 public class Push { 1937 /** 1938 * Check if remote side successfully unpacked 1939 */ 1940 public bool unpack_ok { 1941 [CCode(cname = "git_push_unpack_ok")] 1942 get; 1943 } 1944 1945 /** 1946 * Add a refspec to be pushed 1947 */ 1948 [CCode(cname = "git_push_add_refspec")] 1949 public Error add_refspec(string refspec); 1950 1951 /** 1952 * Actually push all given refspecs 1953 * 1954 * To check if the push was successful (i.e. all remote references have 1955 * been updated as requested), you need to call both {@link unpack_ok} and 1956 * {@link for_each}. The remote repository might have refused to update 1957 * some or all of the references. 1958 */ 1959 [CCode(cname = "git_push_finish")] 1960 public Error finish(); 1961 /** 1962 * Iterate over each status. 1963 * 1964 * For each of the updated references, we receive a status report in the 1965 * form of '''ok refs/heads/master''' or '''ng refs/heads/master ///msg///'''. 1966 * If the message is not null, this means the reference has not been 1967 * updated for the given reason. 1968 * 1969 */ 1970 [CCode(cname = "git_push_status_foreach")] 1971 public Error for_each(PushForEach push_for_each); 1972 /** 1973 * Set options on a push object 1974 * 1975 * @param opts The options to set on the push object 1976 */ 1977 [CCode(cname = "git_push_set_options")] 1978 public Error set_options(push_options opts); 1979 /** 1980 * Update remote tips after a push 1981 */ 1982 [CCode(cname = "git_push_update_tips")] 1983 public Error update_tips(); 1984 } 1985 [CCode(cname = "git_refdb", has_type_id = false, free_function = "git_refdb_free")] 1986 public class RefDb { 1987 /** 1988 * Create a new reference. Either an oid or a symbolic target must be 1989 * specified. 1990 * 1991 * @param name the reference name 1992 * @param id the object id for a direct reference 1993 * @param symbolic the target for a symbolic reference 1994 */ 1995 [CCode(cname = "git_reference__alloc")] 1996 public Reference? alloc(string name, object_id id, string symbolic); 1997 1998 /** 1999 * Suggests that the given refdb compress or optimize its references. 2000 * 2001 * This mechanism is implementation specific. For on-disk reference 2002 * databases, for example, this may pack all loose references. 2003 */ 2004 [CCode(cname = "git_refdb_compress")] 2005 public Error compress(); 2006 2007 /** 2008 * Sets the custom backend to an existing reference DB 2009 */ 2010 [CCode(cname = "git_refdb_set_backend")] 2011 public Error set_backend(owned refdb_backend backend); 2012 } 2013 /** 2014 * In-memory representation of a reference. 2015 */ 2016 [CCode(cname = "git_reference", free_function = "git_reference_free", has_type_id = false)] 2017 [Compact] 2018 public class Reference { 2019 /** 2020 * Check if a reflog exists for the specified reference. 2021 */ 2022 public bool has_log { 2023 [CCode(cname = "git_reference_has_log")] 2024 get; 2025 } 2026 /** 2027 * Check if a reference is a local branch. 2028 */ 2029 public bool is_branch { 2030 [CCode(cname = "git_reference_is_branch")] 2031 get; 2032 } 2033 2034 /** 2035 * Determine if the current local branch is pointed at by HEAD. 2036 */ 2037 public bool is_head { 2038 [CCode(cname = "0 != git_branch_is_head")] 2039 get; 2040 } 2041 2042 /** 2043 * If a reference is a remote tracking branch 2044 */ 2045 public bool is_remote { 2046 [CCode(cname = "git_reference_is_remote")] 2047 get; 2048 } 2049 2050 /** 2051 * The full name of a reference 2052 */ 2053 public string name { 2054 [CCode(cname = "git_reference_name")] 2055 get; 2056 } 2057 2058 /** 2059 * The repository where a reference resides 2060 */ 2061 public Repository repository { 2062 [CCode(cname = "git_reference_owner")] 2063 get; 2064 } 2065 2066 /** 2067 * The full name to the reference pointed by this reference 2068 * 2069 * Only available if the reference is symbolic 2070 */ 2071 public string? symbolic_target { 2072 [CCode(cname = "git_reference_symbolic_target")] 2073 get; 2074 } 2075 2076 /** 2077 * The id pointed to by a reference. 2078 * 2079 * Only available if the reference is direct (i.e., not symbolic) 2080 */ 2081 public object_id? target { 2082 [CCode(cname = "git_reference_target")] 2083 get; 2084 } 2085 2086 /** 2087 * The type of a reference 2088 * 2089 * Either direct, {@link ReferenceType.ID}, or symbolic, {@link ReferenceType.SYMBOLIC} 2090 */ 2091 public ReferenceType type { 2092 [CCode(cname = "git_reference_type")] 2093 get; 2094 } 2095 /** 2096 * Ensure the reference name is well-formed. 2097 * 2098 * Valid reference names must follow one of two patterns: 2099 * 2100 * 1. Top-level names must contain only capital letters and underscores, 2101 * and must begin and end with a letter. (e.g. "HEAD", "ORIG_HEAD"). 2102 * 2. Names prefixed with "refs/" can be almost anything. You must avoid 2103 * the characters '~', '^', ':', '\\', '?', '[', and '*', and the 2104 * sequences ".." and "@{" which have special meaning to revparse. 2105 */ 2106 [CCode(cname = "git_reference_is_valid_name")] 2107 public static bool is_valid_name(string refname); 2108 2109 /** 2110 * Delete an existing branch reference. 2111 */ 2112 [CCode(cname = "git_branch_delete")] 2113 public static Error delete_branch(owned Reference reference); 2114 /** 2115 * Normalize the reference name by removing any leading slash (/) 2116 * characters and collapsing runs of adjacent slashes between name 2117 * components into a single slash. 2118 * 2119 * Once normalized, if the reference name is valid, it will be returned in 2120 * the user allocated buffer. 2121 2122 * @param buffer The buffer where the normalized name will be stored. 2123 * @param name name to be checked. 2124 * @param flags Flags to determine the options to be applied while checking 2125 * the validatity of the name. 2126 */ 2127 [CCode(cname = "git_reference_normalize_name")] 2128 public static Error normalize_name([CCode(array_length_type = "size_t")] uint8[] buffer, string name, ReferenceFormat flags); 2129 2130 /** 2131 * Compare two references. 2132 * 2133 * @return 0 if the same, else a stable but meaningless ordering. 2134 */ 2135 [CCode(cname = "git_reference_cmp")] 2136 public int compare(Reference other); 2137 2138 /** 2139 * Delete an existing reference 2140 * 2141 * This method works for both direct and symbolic references. 2142 * 2143 * The reference will be immediately removed on disk. 2144 */ 2145 [CCode(cname = "git_reference_delete")] 2146 public void @delete(); 2147 2148 /** 2149 * Delete the reflog for the given reference 2150 */ 2151 [CCode(cname = "git_reflog_delete")] 2152 public Error delete_reflog(); 2153 2154 /** 2155 * Return the name of the given local or remote branch. 2156 * 2157 * The name of the branch matches the definition of the name for 2158 * {@link Repository.lookup_branch}. That is, if the returned name is 2159 * looked up then the reference is returned that was given to this 2160 * function. 2161 * 2162 * @param name where the pointer of branch name is stored; 2163 * this is valid as long as the ref is not freed. 2164 */ 2165 [CCode(cname = "git_branch_name", instance_pos = -1)] 2166 public Error get_branch_name(out unowned string name); 2167 2168 /** 2169 * Read the reflog for the given reference 2170 * 2171 * @param reflog where to put the reflog 2172 */ 2173 [CCode(cname = "git_reflog_read", instance_pos = -1)] 2174 public Error get_reflog(out ReferenceLog? reflog); 2175 /** 2176 * Return the reference supporting the remote tracking branch, given a 2177 * reference branch. 2178 * 2179 * The input reference has to be located in the '''refs/heads''' namespace. 2180 * 2181 */ 2182 [CCode(cname = "git_reference_remote_tracking_from_branch", instance_pos = -1)] 2183 public Error get_remote_tracking_from_branch(out Reference tracking_ref); 2184 /** 2185 * Return the reference supporting the remote tracking branch, given a 2186 * local branch reference. 2187 */ 2188 [CCode(cname = "git_branch_tracking", instance_pos = -1)] 2189 public Error get_tracking(out Reference? tracking); 2190 2191 /** 2192 * Move/rename an existing branch reference. 2193 * 2194 * @param new_branch_name Target name of the branch once the move 2195 * is performed; this name is validated for consistency. 2196 * 2197 * @param force Overwrite existing branch. 2198 */ 2199 [CCode(cname = "git_branch_move", instance_pos = 1.1)] 2200 public Error move_branch(out Reference? moved, string new_branch_name, bool force); 2201 2202 /** 2203 * Recursively peel an reference until an object of the specified type is 2204 * met. 2205 * 2206 * If you pass {@link ObjectType.ANY} as the target type, then the object 2207 * will be peeled until a non-tag object is met. 2208 * 2209 * @param target_type The type of the requested object 2210 */ 2211 [CCode(cname = "git_reference_peel", instance_pos = 1.1)] 2212 public Error peel(out Object? peeled, ObjectType target_type); 2213 2214 /** 2215 * Rename an existing reference 2216 * 2217 * This method works for both direct and symbolic references. 2218 * The new name will be checked for validity and may be 2219 * modified into a normalized form. 2220 * 2221 * The refernece will be immediately renamed in-memory 2222 * and on disk. 2223 * 2224 * ''IMPORTANT:'' The user needs to write a proper reflog entry if the 2225 * reflog is enabled for the repository. We only rename the reflog if it 2226 * exists. 2227 * 2228 */ 2229 [CCode(cname = "git_reference_rename", instance_pos = 1.1)] 2230 public Error rename(out Reference? renamed_reference, string new_name, bool force); 2231 2232 /** 2233 * Resolve a symbolic reference 2234 * 2235 * Thie method iteratively peels a symbolic reference 2236 * until it resolves to a direct reference to an id. 2237 * 2238 * If a direct reference is passed as an argument, 2239 * that reference is returned immediately 2240 * 2241 * @param resolved the peeled reference 2242 */ 2243 [CCode(cname = "git_reference_resolve", instance_pos = -1)] 2244 public Error resolve(out Reference resolved); 2245 2246 /** 2247 * Create a new reference with the same name as the given reference but a 2248 * different symbolic target. 2249 * 2250 * The reference must be a symbolic reference, otherwise this will fail. 2251 * 2252 * The new reference will be written to disk, overwriting the given 2253 * reference. 2254 * 2255 * @param id the new target id for the reference 2256 */ 2257 [CCode(cname = "git_reference_set_oid", instance_pos = 1.1)] 2258 public Error set_target(out Reference? retargeted, object_id id); 2259 2260 /** 2261 * Set the symbolic target of a reference. 2262 * 2263 * The reference must be a symbolic reference, otherwise this method will 2264 * fail. 2265 * 2266 * The reference will be automatically updated in memory and on disk. 2267 * 2268 * @param target The new target for the reference 2269 */ 2270 [CCode(cname = "git_reference_symbolic_set_target")] 2271 public Error set_symbolic_target(string target); 2272 } 2273 2274 /** 2275 * Representation of a reference log 2276 */ 2277 [CCode(cname = "git_reflog", free_function = "git_reflog_free", has_type_id = false)] 2278 [Compact] 2279 public class ReferenceLog { 2280 /** 2281 * The number of log entries in a reflog 2282 */ 2283 public size_t size { 2284 [CCode(cname = "git_reflog_entrycount")] 2285 get; 2286 } 2287 2288 /** 2289 * Add a new entry to the reflog. 2290 * 2291 * If there is no reflog file for the given reference yet, it will be 2292 * created. 2293 * 2294 * @param id the id the reference is now pointing to 2295 * @param committer the signature of the committer 2296 * @param msg the reflog message 2297 */ 2298 [CCode(cname = "git_reflog_append")] 2299 public Error append(out object_id id, Signature committer, string? msg = null); 2300 2301 /** 2302 * Remove an entry from the reflog by its index 2303 * 2304 * To ensure there's no gap in the log history, when deleting an entry, 2305 * member old_oid of the previous entry (if any) will be updated with the 2306 * value of memeber new_oid of next entry. 2307 * 2308 * @param idx the position of the entry to remove. 2309 * 2310 * @param rewrite_previous_entry true to rewrite the history; 0 otherwise. 2311 * 2312 */ 2313 [CCode(cname = "git_reflog_drop")] 2314 public Error drop(size_t idx, bool rewrite_previous_entry); 2315 2316 /** 2317 * Lookup an entry by its index 2318 * 2319 * @param idx the position to lookup 2320 * @return the entry; null if not found 2321 */ 2322 [CCode(cname = "git_reflog_entry_byindex")] 2323 public unowned ReferenceLogEntry? get(size_t idx); 2324 2325 /** 2326 * Rename the reflog for the given reference 2327 * 2328 * @param new_name the new name of the reference 2329 */ 2330 [CCode(cname = "git_reflog_rename")] 2331 public Error rename(string new_name); 2332 /** 2333 * Write an existing in-memory reflog object back to disk using an atomic 2334 * file lock. 2335 * 2336 * If there is no reflog file for the given reference yet, it will be 2337 * created. 2338 */ 2339 [CCode(cname = "git_reflog_write")] 2340 public Error write(); 2341 } 2342 2343 /** 2344 * Representation of a reference log entry 2345 */ 2346 [CCode(cname = "git_reflog_entry", has_type_id = false)] 2347 [Compact] 2348 public class ReferenceLogEntry { 2349 2350 /** 2351 * The committer of this entry 2352 */ 2353 public Signature commiter { 2354 [CCode(cname = "git_reflog_entry_committer")] 2355 get; 2356 } 2357 2358 /** 2359 * The log message 2360 */ 2361 public string message { 2362 [CCode(cname = "git_reflog_entry_msg")] 2363 get; 2364 } 2365 2366 /** 2367 * The new id at this time 2368 */ 2369 public object_id? new_id { 2370 [CCode(cname = "git_reflog_entry_id_new")] 2371 get; 2372 } 2373 2374 /** 2375 * The old id 2376 */ 2377 public object_id? old_id { 2378 [CCode(cname = "git_reflog_entry_id_old")] 2379 get; 2380 } 2381 } 2382 2383 /** 2384 * Reference to a remote repository 2385 */ 2386 [CCode(cname = "git_remote", free_function = "git_remote_free", has_type_id = false)] 2387 [Compact] 2388 public class Remote { 2389 [CCode(cname = "git_remote_rename_problem_cb")] 2390 public delegate bool RenameProblem(string problematic_refspec); 2391 /** 2392 * The tag auto-follow setting 2393 */ 2394 public AutoTag autotag { 2395 [CCode(cname = "git_remote_autotag")] 2396 get; 2397 [CCode(cname = "git_remote_set_autotag")] 2398 set; 2399 } 2400 2401 /** 2402 * Choose whether to check the server's certificate (applies to HTTPS only) 2403 */ 2404 public bool check_cert { 2405 [CCode(cname = "git_remote_check_cert")] 2406 set; 2407 } 2408 2409 /** 2410 * Whether the remote is connected 2411 * 2412 * Whether the remote's underlying transport is connected to the remote 2413 * host. 2414 */ 2415 public bool is_connected { 2416 [CCode(cname = "git_remote_connected")] 2417 get; 2418 } 2419 2420 /** 2421 * The fetch refspec, if it exists 2422 */ 2423 public ref_spec? fetch_spec { 2424 [CCode(cname = "git_remote_fetchspec")] 2425 get; 2426 [CCode(cname = "git_remote_set_fetchspec")] 2427 set; 2428 } 2429 2430 /** 2431 * The remote's name 2432 */ 2433 public string? name { 2434 [CCode(cname = "git_remote_name")] 2435 get; 2436 } 2437 2438 /** 2439 * The push refspec, if it existsc 2440 */ 2441 public ref_spec? push_spec { 2442 [CCode(cname = "git_remote_pushspec")] 2443 get; 2444 [CCode(cname = "git_remote_set_pushspec")] 2445 set; 2446 } 2447 2448 /** 2449 * The statistics structure that is filled in by the fetch operation. 2450 */ 2451 public transfer_progress stats { 2452 [CCode(cname = "git_remote_stats")] 2453 get; 2454 } 2455 2456 /** 2457 * Update FETCH_HEAD on ever fetch. 2458 */ 2459 public bool update_fetchhead { 2460 [CCode(cname = "git_remote_update_fetchhead")] 2461 get; 2462 [CCode(cname = "git_remote_set_update_fetchhead")] 2463 set; 2464 } 2465 /** 2466 * The remote's URL 2467 */ 2468 public string url { 2469 [CCode(cname = "git_remote_url")] 2470 get; 2471 } 2472 2473 /** 2474 * Ensure the remote name is well-formed. 2475 * 2476 * @param remote_name name to be checked. 2477 */ 2478 [CCode(cname = "git_remote_is_valid_name")] 2479 public static bool is_valid_name(string remote_name); 2480 2481 /** 2482 * Return whether a string is a valid remote URL 2483 * 2484 * @param url the url to check 2485 */ 2486 [CCode(cname = "git_remote_valid_url")] 2487 public static bool is_valid_url(string url); 2488 2489 /** 2490 * Return whether the passed URL is supported by this version of the library. 2491 * 2492 * @param url the url to check 2493 */ 2494 [CCode(cname = "git_remote_supported_url")] 2495 public static bool is_supported_url(string url); 2496 /** 2497 * Create a new push object 2498 */ 2499 [CCode(cname = "git_push_new", instance_pos = -1)] 2500 public Error create_push(out Push? push); 2501 2502 /** 2503 * Open a connection to a remote 2504 * 2505 * The transport is selected based on the URL. The direction argument is 2506 * due to a limitation of the git protocol (over TCP or SSH) which starts 2507 * up a specific binary which can only do the one or the other. 2508 * 2509 * @param direction whether you want to receive or send data 2510 */ 2511 [CCode(cname = "git_remote_connect")] 2512 public Error connect(Direction direction); 2513 2514 /** 2515 * Download the packfile 2516 * 2517 * Negotiate what objects should be downloaded and download the packfile 2518 * with those objects. 2519 */ 2520 [CCode(cname = "git_remote_download")] 2521 public Error download(Progress progress); 2522 2523 /** 2524 * Disconnect from the remote 2525 * 2526 * Close the connection to the remote and free the underlying transport. 2527 */ 2528 [CCode(cname = "git_remote_disconnect")] 2529 public void disconnect(); 2530 2531 /** 2532 * Get a list of refs at the remote 2533 * 2534 * The remote (or more exactly its transport) must be connected. 2535 */ 2536 [CCode(cname = "git_remote_ls", instance_pos = -1)] 2537 public Error list(Head headcb); 2538 2539 /** 2540 * Give the remote a new name 2541 * 2542 * All remote-tracking branches and configuration settings for the remote 2543 * are updated. 2544 * 2545 * The new name will be checked for validity. 2546 * 2547 * A temporary in-memory remote cannot be given a name with this method. 2548 * 2549 * @param new_name the new name the remote should bear 2550 * @param rename_problem Optional callback to notify the consumer of fetch refspecs 2551 * that haven't been automatically updated and need potential manual tweaking. 2552 * @see Repository.create_tag 2553 */ 2554 [CCode(cname = "git_remote_rename")] 2555 public Error rename(string new_name, RenameProblem? rename_problem = null); 2556 /** 2557 * Save a remote to its repository's configuration 2558 * 2559 * One can't save a in-memory remote. Doing so will result in a 2560 * {@link Error.INVALIDSPEC} being returned. 2561 */ 2562 [CCode(cname = "git_remote_save")] 2563 public Error save(); 2564 /** 2565 * Set the callbacks for a remote 2566 */ 2567 [CCode(cname = "git_remote_set_callbacks", simple_generics = true)] 2568 public Error set_callbacks<T>(remote_callbacks<T> callbacks); 2569 2570 /** 2571 * Sets the owning repository for the remote. This is only allowed on 2572 * dangling remotes. 2573 */ 2574 [CCode(cname = "git_remote_set_repository")] 2575 public Error set_repository(Repository repo); 2576 2577 /** 2578 * Sets a credentials acquisition callback for this remote. 2579 * 2580 * If the remote is not available for anonymous access, then you must set 2581 * this callback in order to provide credentials to the transport at the 2582 * time of authentication failure so that retry can be performed. 2583 */ 2584 [CCode(cname = "git_remote_set_cred_acquire_cb")] 2585 public void set_cred_acquire(CredAcquire? cred_acquire); 2586 2587 /** 2588 * Sets a custom transport for the remote. The caller can use this function 2589 * to bypass the automatic discovery of a transport by URL scheme (i.e., 2590 * http, https, git) and supply their own transport to be used 2591 * instead. After providing the transport to a remote using this function, 2592 * the transport object belongs exclusively to that remote, and the remote will 2593 * free it when it is freed with git_remote_free. 2594 * 2595 * @param transport the transport object for the remote to use 2596 */ 2597 [CCode(cname = "git_remote_set_transport")] 2598 public Error set_transport(transport transport); 2599 2600 /** 2601 * Cancel the operation 2602 * 2603 * At certain points in its operation, the network code checks whether the 2604 * operation has been cancelled and if so stops the operation. 2605 */ 2606 [CCode(cname = "git_remote_stop")] 2607 public void stop(); 2608 2609 /** 2610 * Update the tips to the new state 2611 * 2612 * Make sure that you only call this once you've successfully indexed or 2613 * expanded the packfile. 2614 */ 2615 [CCode(cname = "git_remote_update_tips")] 2616 public Error update_tips(Update update); 2617 } 2618 2619 /** 2620 * Representation of an existing git repository, 2621 * including all its object contents 2622 */ 2623 [CCode(cname = "git_repository", free_function = "git_repository_free", has_type_id = false)] 2624 [Compact] 2625 public class Repository { 2626 public Attr attributes { 2627 [CCode(cname = "")] 2628 get; 2629 } 2630 /** 2631 * Check if a repository is bare 2632 */ 2633 public bool is_bare { 2634 [CCode(cname = "git_repository_is_bare")] 2635 get; 2636 } 2637 /** 2638 * Check if a repository's HEAD is detached 2639 * 2640 * A repository's HEAD is detached when it points directly to a commit 2641 * instead of a branch. 2642 */ 2643 public bool is_head_detached { 2644 [CCode(cname = "git_repository_head_detached")] 2645 get; 2646 } 2647 2648 /** 2649 * Check if the current branch is an orphan 2650 * 2651 * An orphan branch is one named from HEAD but which doesn't exist in 2652 * the refs namespace, because it doesn't have any commit to point to. 2653 */ 2654 public bool is_head_orphan { 2655 [CCode(cname = "git_repository_head_orphan")] 2656 get; 2657 } 2658 2659 /** 2660 * Check if a repository is empty 2661 * 2662 * An empty repository has just been initialized and contains no commits. 2663 */ 2664 public bool is_empty { 2665 [CCode(cname = "git_repository_is_empty")] 2666 get; 2667 } 2668 2669 /** 2670 * The path to the repository. 2671 */ 2672 public string? path { 2673 [CCode(cname = "git_repository_path")] 2674 get; 2675 } 2676 /** 2677 * Determines the status of a git repository (i.e., whether an operation 2678 * such as a merge or cherry-pick is in progress). 2679 */ 2680 public State state { 2681 [CCode(cname = "git_repository_state")] 2682 get; 2683 } 2684 2685 /** 2686 * The working directory for this repository 2687 * 2688 * If the repository is bare, this is null. 2689 * 2690 * If this repository is bare, setting its working directory will turn it 2691 * into a normal repository, capable of performing all the common workdir 2692 * operations (checkout, status, index manipulation, etc). 2693 */ 2694 public string? workdir { 2695 [CCode(cname = "git_repository_workdir")] 2696 get; 2697 set { 2698 set_workdir((!)value, true); 2699 } 2700 } 2701 2702 /** 2703 * Clone a remote repository, and checkout the branch pointed to by the remote 2704 * HEAD. 2705 * 2706 * @param origin_url repository to clone from 2707 * @param dest_path local directory to clone to 2708 * @param clone_opts configuration options for the clone. 2709 */ 2710 [CCode(cname = "git_clone")] 2711 public static Error clone(out Repository? repo, string origin_url, string dest_path, clone_opts? clone_opts = null); 2712 2713 /** 2714 * Look for a git repository and copy its path in the given buffer. The lookup start 2715 * from base_path and walk across parent directories if nothing has been found. The 2716 * lookup ends when the first repository is found, or when reaching a directory 2717 * referenced in ceiling_dirs or when the filesystem changes (in case across_fs 2718 * is true). 2719 * 2720 * The method will automatically detect if the repository is bare (if there is 2721 * a repository). 2722 * 2723 * @param repository_path The buffer which will contain the found path. 2724 * 2725 * @param start_path The base path where the lookup starts. 2726 * 2727 * @param across_fs If true, then the lookup will not stop when a filesystem device change 2728 * is detected while exploring parent directories. 2729 * 2730 * @param ceiling_dirs A {@link PATH_LIST_SEPARATOR} separated list of absolute symbolic link free paths. The lookup will stop when any of this paths is reached. Note that the lookup always performs on //start_path// no matter start_path appears in //ceiling_dirs//. //ceiling_dirs// might be null, which is equivalent to an empty string. 2731 */ 2732 public static Error discover([CCode(array_length_type = "size_t")] char[] repository_path, string start_path, bool across_fs = true, string? ceiling_dirs = null); 2733 2734 /** 2735 * Creates a new Git repository in the given folder. 2736 * 2737 * @param repo the repo which will be created or reinitialized 2738 * @param path the path to the repository 2739 * @param is_bare if true, a git repository without a working directory is created at the pointed path. If false, provided path will be considered as the working directory into which the //.git// directory will be created. 2740 */ 2741 [CCode(cname = "git_repository_init")] 2742 public static Error init(out Repository repo, string path, bool is_bare); 2743 /** 2744 * Create a new Git repository in the given folder with extended controls. 2745 * 2746 * This will initialize a new git repository (creating the path if 2747 * requested by flags) and working directory as needed. It will 2748 * auto-detect the case sensitivity of the file system and if the file 2749 * system supports file mode bits correctly. 2750 * 2751 * @param repo_path The path to the repository. 2752 * @param opts Pointer to git_repository_init_options struct. 2753 */ 2754 [CCode(cname = "git_repository_init_ext")] 2755 public static Error init_ext(out Repository? repo, string repo_path, init_options opts); 2756 2757 /** 2758 * Open a git repository. 2759 * 2760 * The path argument must point to an existing git repository 2761 * folder. The repository can be normal (having a //.git// directory) 2762 * or bare (having objects, index, and HEAD directly). 2763 * The method will automatically detect if path is a normal 2764 * or bare repository or fail is path is neither. 2765 * 2766 * @param repository the repo which will be opened 2767 * @param path the path to the repository 2768 */ 2769 [CCode(cname = "git_repository_open")] 2770 public static Error open(out Repository? repository, string path); 2771 2772 /** 2773 * Find and open a repository with extended controls. 2774 */ 2775 [CCode(cname = "git_repository_open_ext")] 2776 public static Error open_ext(out Repository? repository, string start_path, OpenFlags flags, string ceiling_dirs); 2777 /** 2778 * Add ignore rules for a repository. 2779 * 2780 * Excludesfile rules (i.e. .gitignore rules) are generally read from 2781 * .gitignore files in the repository tree or from a shared system file 2782 * only if a "core.excludesfile" config value is set. The library also 2783 * keeps a set of per-repository internal ignores that can be configured 2784 * in-memory and will not persist. This function allows you to add to 2785 * that internal rules list. 2786 * 2787 * @param rules Text of rules, a la the contents of a .gitignore file. It 2788 * is okay to have multiple rules in the text; if so, each rule should be 2789 * terminated with a newline. 2790 */ 2791 [CCode(cname = "git_ignore_add_rule")] 2792 public Error add_ignore(string rules); 2793 /** 2794 * Set up a new git submodule for checkout. 2795 * 2796 * This does '''git submodule add''' up to the fetch and checkout of the 2797 * submodule contents. It preps a new submodule, creates an entry in 2798 * .gitmodules and creates an empty initialized repository either at the 2799 * given path in the working directory or in .git/modules with a gitlink 2800 * from the working directory to the new repo. 2801 * 2802 * To fully emulate '''git submodule add''' call this function, then open 2803 * the submodule repo and perform the clone step as needed. Lastly, call 2804 * {@link Submodule.add_finalize} to wrap up adding the new submodule and 2805 * .gitmodules to the index to be ready to commit. 2806 * 2807 * @param submodule The newly created submodule ready to open for clone 2808 * @param url URL for the submodules remote 2809 * @param path Path at which the submodule should be created 2810 * @param use_gitlink Should workdir contain a gitlink to the repo in 2811 * .git/modules vs. repo directly in workdir. 2812 */ 2813 [CCode(cname = "git_submodule_add_setup", instance_pos = 1.1)] 2814 public Error add_submodule_setup(out Submodule? submodule, string url, string path, bool use_gitlink); 2815 2816 /** 2817 * Remove all the metadata associated with an ongoing git merge, including 2818 * MERGE_HEAD, MERGE_MSG, etc. 2819 */ 2820 [CCode(cname = "git_repository_merge_cleanup")] 2821 public Error cleanup_merge(); 2822 2823 /** 2824 * Clear ignore rules that were explicitly added. 2825 * 2826 * Resets to the default internal ignore rules. This will not turn off 2827 * rules in .gitignore files that actually exist in the filesystem. 2828 * 2829 * The default internal ignores ignore '''.''', '''..''' and '''.git''' entries. 2830 */ 2831 public Error clear_internal_ignores(); 2832 2833 /** 2834 * Updates files in the index and the working tree to match the commit pointed to by HEAD. 2835 * 2836 * @param opts specifies checkout options 2837 */ 2838 [CCode(cname = "git_checkout_head")] 2839 public Error checkout_head(checkout_opts? opts = null); 2840 /** 2841 * Updates files in the working tree to match the content of the index. 2842 * 2843 * @param opts specifies checkout options 2844 * @param index index to be checked out (or null to use repository index) 2845 */ 2846 [CCode(cname = "git_checkout_index")] 2847 public Error checkout_index(Index? index = null, checkout_opts? opts = null); 2848 /** 2849 * Updates files in the index and working tree to match the content of a 2850 * tree. 2851 * 2852 * @param treeish a commit, tag or tree which content will be used to 2853 * update the working directory 2854 * @param opts specifies checkout options 2855 */ 2856 [CCode(cname = "git_checkout_tree")] 2857 public Error checkout_tree(Object treeish, checkout_opts? opts = null); 2858 /** 2859 * Count the number of unique commits between two commit objects 2860 * 2861 * There is no need for branches containing the commits to have any 2862 * upstream relationship, but it helps to think of one as a branch and the 2863 * other as its upstream, the ahead and behind values will be what git 2864 * would report for the branches. 2865 * 2866 * @param ahead number of unique commits in upstream 2867 * @param behind number of unique commits in local 2868 * @param local one of the commits 2869 * @param upstream the other commit 2870 */ 2871 [CCode(cname = "git_graph_ahead_behind", instance_pos = 2.1)] 2872 public Error count_ahead_behind(out size_t ahead, out size_t behind, object_id local, object_id upstream); 2873 /** 2874 * Write an in-memory buffer to the ODB as a blob 2875 * 2876 * @param id return the id of the written blob 2877 * @param buffer data to be written into the blob 2878 */ 2879 [CCode(cname = "git_blob_create_frombuffer", instance_pos = 1.2)] 2880 public Error create_blob_from_buffer(object_id id, [CCode(array_length_type = "size_t")] uint8[] buffer); 2881 /** 2882 * Write a loose blob to the Object Database from a provider of chunks of 2883 * data. 2884 * 2885 * @param id Return the id of the written blob 2886 * @param hint_path will help to determine what git filters should be 2887 * applied to the object before it can be placed to the object database. 2888 */ 2889 [CCode(cname = "git_blob_create_fromchunks", instance_pos = 1.2)] 2890 public Error create_blob_from_chunks(object_id id, string? hint_path, ChunkSource source); 2891 2892 /** 2893 * Read a file from the filesystem and write its content to the Object 2894 * Database as a loose blob 2895 * 2896 * @param id return the id of the written blob 2897 * @param path file from which the blob will be created 2898 */ 2899 [CCode(cname = "git_blob_create_fromdisk", instance_pos = 1.2)] 2900 public Error create_blob_from_disk(out object_id id, string path); 2901 2902 /** 2903 * Read a file from the working folder of a repository 2904 * and write it to the object database as a loose blob 2905 * 2906 * This repository cannot be bare. 2907 * 2908 * @param id return the id of the written blob 2909 * @param path file from which the blob will be created, relative to the repository's working dir 2910 */ 2911 [CCode(cname = "git_blob_create_fromworkdir", instance_pos = 1.2)] 2912 public Error create_blob_from_file(object_id id, string path); 2913 2914 /** 2915 * Create a new branch pointing at a target commit 2916 * 2917 * A new direct reference will be created pointing to this target commit. 2918 * If forced and a reference already exists with the given name, it'll be 2919 * replaced. 2920 * 2921 * @param branch_name Name for the branch; this name is 2922 * validated for consistency. It should also not conflict with 2923 * an already existing branch name. 2924 * 2925 * @param target Object to which this branch should point. This object must 2926 * belong to the given repository and can either be a commit or a tag. When 2927 * a tag is being passed, it should be dereferencable to a commit which oid 2928 * will be used as the target of the branch. 2929 * 2930 * @param force Overwrite existing branch. 2931 */ 2932 [CCode(cname = "git_branch_create", instance_pos = 1.2)] 2933 public Error create_branch(out Reference? branch, string branch_name, Commit target, bool force = false); 2934 2935 /** 2936 * Create a new commit in the repository using {@link Object} 2937 * instances as parameters. 2938 * 2939 * The message will not be cleaned up. 2940 * 2941 * @param id the id of the newly created commit 2942 * 2943 * @param update_ref If not null, name of the reference that will be updated to point to this commit. If the reference is not direct, it will be resolved to a direct reference. Use //"HEAD"// to update the HEAD of the current branch and make it point to this commit. 2944 * @param author Signature representing the author and the author time of this commit 2945 * @param committer Signature representing the committer and the commit time of this commit 2946 * @param message_encoding The encoding for the message in the commit, represented with a standard encoding name (e.g., //"UTF-8"//). If null, no encoding header is written and UTF-8 is assumed. 2947 * @param message Full message for this commit 2948 * @param tree The tree that will be used as the tree for the commit. This tree object must also be owned by this repository. 2949 * @param parents The commits that will be used as the parents for this commit. This array may be empty for the root commit. All the given commits must be owned by this repository. 2950 * @see prettify_message 2951 */ 2952 [CCode(cname = "git_commit_create", instance_pos = 1.2)] 2953 public Error create_commit(object_id id, string? update_ref, Signature author, Signature committer, string? message_encoding, string message, Tree tree, [CCode(array_length_pos = 7.8)] Commit[] parents); 2954 2955 /** 2956 * Create a new commit in the repository using a variable argument list. 2957 * 2958 * The parents for the commit are specified as a variable arguments. Note 2959 * that this is a convenience method which may not be safe to export for 2960 * certain languages or compilers 2961 * 2962 * The message will be cleaned up from excess whitespace it will be made 2963 * sure that the last line ends with a new line. 2964 * 2965 * All other parameters remain the same. 2966 * 2967 * @see create_commit 2968 */ 2969 [CCode(cname = "git_commit_create_v", instance_pos = 1.2)] 2970 public Error create_commit_v(object_id id, string update_ref, Signature author, Signature committer, string message_encoding, string message, Tree tree, int parent_count, ...); 2971 2972 /** 2973 * Create a new lightweight tag pointing at a target object 2974 * 2975 * A new direct reference will be created pointing to this target object. 2976 * If //force// is true and a reference already exists with the given name, 2977 * it'll be replaced. 2978 * 2979 * The message will be cleaned up from excess whitespace 2980 * it will be made sure that the last line ends with a new line. 2981 * 2982 * @param id where to store the id of the newly created tag. If the tag already exists, this parameter will be the id of the existing tag, and the function will return a {@link Error.EXISTS} error code. 2983 * 2984 * @param tag_name Name for the tag; this name is validated for consistency. It should also not conflict with an already existing tag name. 2985 * 2986 * @param target Object to which this tag points. This object must belong to this repository. 2987 * 2988 * @param force Overwrite existing references 2989 * 2990 * @return on success, a proper reference is written in the ///refs/tags// folder, pointing to the provided target object 2991 * @see create_tag 2992 */ 2993 [CCode(cname = "git_tag_create_lightweight", instance_pos = 1.2)] 2994 public Error create_lightweight_tag(object_id id, string tag_name, Object target, bool force); 2995 2996 /** 2997 * Add a note for an object 2998 * 2999 * @param note_id the object id of the note crated 3000 * @param author signature of the notes commit author 3001 * @param committer signature of the notes commit committer 3002 * @param notes_ref ID reference to update (optional); defaults to "refs/notes/commits" 3003 * @param id The ID of the object 3004 * @param note The note to add for the object 3005 * @param force Overwrite existing note 3006 */ 3007 [CCode(cname = "git_note_create", instance_pos = 1.2)] 3008 public Error create_note(out object_id note_id, Signature author, Signature committer, string? notes_ref, object_id id, string note, bool force = false); 3009 3010 /** 3011 * Creates a new iterator for notes. 3012 * 3013 * @param notes_ref canonical name of the reference to use (optional); 3014 * defaults to "refs/notes/commits" 3015 */ 3016 [CCode(cname = "git_note_iterator_new", instance_pos = 1.1)] 3017 public Error create_note_iterator(out NoteIterator? iterator, string? notes_ref = null); 3018 3019 /** 3020 * Initialize a new packbuilder 3021 * 3022 * @param pack_builder The new packbuilder object 3023 */ 3024 [CCode(cname = "git_packbuilder_new", instance_pos = -1)] 3025 public Error create_pack_builder(out PackBuilder? pack_builder); 3026 3027 /** 3028 * Create a new reference database with no backends. 3029 * 3030 * Before the Ref DB can be used for read/writing, a custom database 3031 * backend must be manually set using {@link RefDb.set_backend}. 3032 */ 3033 [CCode(cname = "git_refdb_new", instance_pos = -1)] 3034 public Error create_refdb(out RefDb? refdb); 3035 3036 /** 3037 * Create a new object id reference. 3038 * 3039 * The reference will be created in the repository and written to the disk. 3040 * 3041 * @param reference the newly created reference 3042 * @param name The name of the reference 3043 * @param id The object id pointed to by the reference. 3044 * @param force Overwrite existing references 3045 */ 3046 [CCode(cname = "git_reference_create", instance_pos = 1.2)] 3047 public Error create_reference(out unowned Reference reference, string name, object_id id, bool force); 3048 3049 /** 3050 * Add a remote with the default fetch refspec to the repository's configuration. 3051 * 3052 * This calls {@link Remote.save} before returning. 3053 * 3054 * @param remote the resulting remote 3055 * @param name the remote's name 3056 * @param url the remote's url 3057 */ 3058 [CCode(cname = "git_remote_create", instance_pos = 1.2)] 3059 public Error create_remote(out Remote? remote, string name, string url); 3060 /** 3061 * Create a remote with the given refspec in memory. 3062 * 3063 * You can use this when you have a URL instead of a remote's name. Note 3064 * that in-memory remotes cannot be converted to persisted remotes. 3065 * 3066 * @param remote the newly created remote reference 3067 * @param fetch the fetch refspec to use for this remote; null for defaults 3068 * @param url the remote repository's URL 3069 */ 3070 [CCode(cname = "git_remote_create_inmemory", instance_pos = 1.2)] 3071 public Error create_remote_in_memory(out Remote? remote, string? fetch, string url); 3072 3073 /** 3074 * Create a new symbolic reference. 3075 * 3076 * The reference will be created in the repository and written to the disk. 3077 * 3078 * @param reference the newly created reference 3079 * @param name The name of the reference 3080 * @param target The target of the reference 3081 * @param force Overwrite existing references 3082 */ 3083 [CCode(cname = "git_reference_symbolic_create", instance_pos = 1.2)] 3084 public Error create_symbolic_reference(out unowned Reference reference, string name, string target, bool force); 3085 3086 /** 3087 * Create a new tag in the repository from an object 3088 * 3089 * A new reference will also be created pointing to this tag object. If 3090 * //force// is true and a reference already exists with the given name, 3091 * it'll be replaced. 3092 * 3093 * The tag name will be checked for validity. You must avoid the characters 3094 * ~, ^, :, \, ?, [, and *, and the sequences '''..''' and '''@{''' which 3095 * have special meaning to revparse. 3096 * 3097 * @param id where to store the id of the newly created tag. If the tag already exists, this parameter will be the id of the existing tag, and the function will return a {@link Error.EXISTS} error code. 3098 * @param tag_name Name for the tag; this name is validated for consistency. It should also not conflict with an already existing tag name. 3099 * @param target Object to which this tag points. This object must belong to this repository. 3100 * @param tagger Signature of the tagger for this tag, and of the tagging time 3101 * @param message Full message for this tag 3102 * @param force Overwrite existing references 3103 * @return on success, a tag object is written to the ODB, and a proper reference is written in the ///refs/tags// folder, pointing to it 3104 */ 3105 [CCode(cname = "git_tag_create", instance_pos = 1.2)] 3106 public Error create_tag(object_id id, string tag_name, Object target, Signature tagger, string message, bool force); 3107 3108 /** 3109 * Create a new tag in the repository from a buffer 3110 * 3111 * @param id Pointer where to store the id of the newly created tag 3112 * @param buffer Raw tag data 3113 * @param force Overwrite existing tags 3114 * @see create_tag 3115 */ 3116 [CCode(cname = "git_tag_create_frombuffer", instance_pos = 1.2)] 3117 public Error create_tag_from_buffer(object_id id, string buffer, bool force); 3118 3119 /** 3120 * Delete an existing tag reference. 3121 * 3122 * @param tag_name Name of the tag to be deleted; this name is validated for consistency. 3123 */ 3124 [CCode(cname = "git_tag_delete")] 3125 public Error delete_tag(string tag_name); 3126 3127 /** 3128 * Detach the HEAD. 3129 * 3130 * If the HEAD is already detached and points to a commit, the call is successful. 3131 * 3132 * If the HEAD is already detached and points to a tag, the HEAD is updated 3133 * into making it point to the peeled commit, and the call is successful. 3134 * 3135 * If the HEAD is already detached and points to a non commitish, the HEAD 3136 * is unaletered, and an error is returned. 3137 * 3138 * Otherwise, the HEAD will be detached and point to the peeled commit. 3139 */ 3140 [CCode(cname = "git_repository_detach_head")] 3141 public Error detach_head(); 3142 3143 /** 3144 * Compute a difference between two tree objects. 3145 * 3146 * @param diff The diff that will be allocated. 3147 * @param old_tree A tree to diff from. 3148 * @param new_tree A tree to diff to. 3149 * @param opts Structure with options to influence diff or null for defaults. 3150 */ 3151 [CCode(cname = "git_diff_tree_to_tree", instance_pos = 1.1)] 3152 public Error diff_tree_to_tree(out DiffList? diff, Tree old_tree, Tree new_tree, diff_options? opts = null); 3153 3154 /** 3155 * Compute a difference between a tree and the index. 3156 * 3157 * @param diff The diff that will be allocated. 3158 * @param old_tree A tree object to diff from. 3159 * @param opts Structure with options to influence diff or null for defaults. 3160 */ 3161 [CCode(cname = "git_diff_tree_to_index", instance_pos = 1.1)] 3162 public Error diff_tree_to_index(out DiffList? diff, Tree old_tree, diff_options? opts = null); 3163 3164 /** 3165 * Compute a difference between the working directory and the index. 3166 * 3167 * @param diff A pointer to a git_diff_list pointer that will be allocated. 3168 * @param opts Structure with options to influence diff or null for defaults. 3169 */ 3170 [CCode(cname = "git_diff_index_to_workdir", instance_pos = 1.1)] 3171 public Error diff_index_to_workdir(out DiffList? diff, diff_options? opts = null); 3172 3173 /** 3174 * Compute a difference between the working directory and a tree. 3175 * 3176 * Please note: this is //not// the same as '''git diff //treeish//'''. 3177 * Running '''git diff HEAD''' or the like actually uses information from 3178 * the index, along with the tree and working directory info. 3179 * 3180 * This function returns strictly the differences between the tree and the 3181 * The tree you provide will be used for the {@link diff_delta.old_file} 3182 * side of the delta, and the working directory will be used for the 3183 * {@link diff_delta.new_file} side. 3184 * 3185 * Files contained in the working directory, regardless of the state of 3186 * files in the index. It may come as a surprise, but there is no direct 3187 * equivalent in core git. 3188 * 3189 * This is //not// the same as '''git diff HEAD''' or '''git diff <SHA>'''. 3190 * Those commands diff the tree, the index, and the workdir. To emulate 3191 * those functions, call {@link diff_tree_to_index} and 3192 * {@link diff_index_to_workdir}, then call {@link DiffList.merge} on the 3193 * results. 3194 * 3195 * If this seems confusing, take the case of a file with a staged deletion 3196 * where the file has then been put back into the working dir and modified. 3197 * The tree-to-workdir diff for that file is 'modified', but core git would 3198 * show status 'deleted' since there is a pending deletion in the index. 3199 * 3200 * @param old_tree A tree to diff from. 3201 * @param opts Structure with options to influence diff or NULL for defaults. 3202 */ 3203 [CCode(cname = "git_diff_workdir_to_tree", instance_pos = 1.1)] 3204 public Error diff_tree_to_workdir(out DiffList? diff, Tree old_tree, diff_options? opts = null); 3205 3206 /** 3207 * Remove a single stashed state from the stash list. 3208 * @param index The position within the stash list. 0 points to the 3209 * most recent stashed state. 3210 */ 3211 [CCode(cname = "git_stash_drop")] 3212 public Error drop_stash(size_t index); 3213 3214 /** 3215 * Iterate over each entry in the FETCH_HEAD file. 3216 */ 3217 [CCode(cname = "git_repository_fetchhead_foreach")] 3218 public Error for_each_fetchhead(FetchHeadForEach fetch_head_for_each); 3219 3220 /** 3221 * If a merge is in progress, iterate over each commit ID in the MERGE_HEAD 3222 * file. 3223 */ 3224 [CCode(cname = "git_repository_mergehead_foreach")] 3225 public Error for_each_merge_head(MergeHeadForEach merge_head_for_each); 3226 3227 /** 3228 * Perform an operation on each reference in the repository 3229 * 3230 * The processed references may be filtered by type, or using a bitwise OR 3231 * of several types. Use the magic value {@link ReferenceType.LISTALL} to 3232 * obtain all references, including packed ones. 3233 * 3234 * @param list_flags Filtering flags for the reference listing. 3235 * @param reference_for_each Function which will be called for every listed ref 3236 */ 3237 [CCode(cname = "git_reference_foreach")] 3238 public Error for_each_reference(ReferenceType list_flags, ReferenceForEach reference_for_each); 3239 /** 3240 * Loop over all the references and issue a callback for each one which 3241 * name matches the given glob pattern. 3242 * 3243 * @param list_flags Filtering flags for the reference listing. 3244 * @param reference_for_each to invoke per found reference. 3245 */ 3246 [CCode(cname = "git_reference_foreach_glob")] 3247 public Error for_each_reference_glob(string glob, ReferenceType list_flags, ReferenceForEach reference_for_each); 3248 3249 /** 3250 * Iterate over all submodules of a repository. 3251 */ 3252 [CCode(cname = "git_submodule_foreach")] 3253 public Error for_each_submodule(SubmoduleForEach submodule_for_each); 3254 /** 3255 * Iterate over each tag in the repository. 3256 */ 3257 [CCode(cname = "git_tag_foreach")] 3258 public Error for_each_tag(TagForEach tag_for_each); 3259 3260 /** 3261 * Find a merge base between two commits 3262 * 3263 * @param merge_base the OID of a merge base between 'one' and 'two' 3264 * @param one one of the commits 3265 * @param two the other commit 3266 */ 3267 [CCode(cname = "git_merge_base", instance_pos = 1.2)] 3268 public Error find_merge_base(out object_id merge_base, object_id one, object_id two); 3269 3270 /** 3271 * Find a merge base given a list of commits 3272 * 3273 * @param id the ID of a merge base considering all the commits 3274 * @param input ids of the commits 3275 */ 3276 [CCode(cname = "git_merge_base_many", instance_pos = 1.1)] 3277 public Error find_merge_base_many(out object_id id, [CCode(array_length_type = "size_t")]object_id[] input); 3278 3279 /** 3280 * Loop over all the notes within a specified namespace. 3281 * @param notes_ref OID reference to read from (optional); defaults to "refs/notes/commits". 3282 */ 3283 [CCode(cname = "git_note_foreach")] 3284 public Error for_each_note(string? notes_ref, NoteForEach note_for_each); 3285 3286 /** 3287 * Loop over all the stashed states. 3288 * 3289 * The most recent stash state will be enumerated first. 3290 */ 3291 [CCode(cname = "git_stash_foreach")] 3292 public Error for_each_stash(StashForEach stash_for_each); 3293 3294 /** 3295 * Gather file statuses and run a callback for each one. 3296 * 3297 * The callback is passed the path of the file, the status and the data 3298 * pointer passed to this function. If the callback returns something other 3299 * than {@link Error.OK}, this function will return that value. 3300 * 3301 * @param status_for_each the function to call on each file 3302 * @return {@link Error.OK} or the return value of the callback 3303 */ 3304 [CCode(cname = "git_status_foreach")] 3305 public Error for_each_status(StatusForEach status_for_each); 3306 3307 /** 3308 * Gather file status information and run callbacks as requested. 3309 */ 3310 [CCode(cname = "git_status_foreach_ext")] 3311 public Error for_each_status_ext(status_options opts, StatusForEach status_for_each); 3312 3313 /** 3314 * Get the configuration file for this repository. 3315 * 3316 * If a configuration file has not been set, the default 3317 * config set for the repository will be returned, including 3318 * global and system configurations (if they are available). 3319 * 3320 * @param config the repository's configuration 3321 */ 3322 [CCode(cname = "git_repository_config", instance_pos = -1)] 3323 public Error get_config(out Config config); 3324 3325 /** 3326 * Get the Object Database for this repository. 3327 * 3328 * If a custom ODB has not been set, the default database for the 3329 * repository will be returned (the one located in //.git/objects//). 3330 */ 3331 [CCode(cname = "git_repository_odb", instance_pos = -1)] 3332 public Error get_db(out Database.Handle db); 3333 3334 /** 3335 * Get file status for a single file 3336 * 3337 * @param status the status value 3338 * @param path the file to retrieve status for, rooted at the repo's workdir 3339 * @return {@link Error.ERROR} when //path// points at a folder, {@link Error.NOTFOUND} when the file doesn't exist in any of HEAD, the index or the worktree, {@link Error.OK} otherwise 3340 */ 3341 [CCode(cname = "git_status_file", instance_pos = 1.2)] 3342 public Error get_file_status(out Status status, string path); 3343 3344 /** 3345 * Retrieve and resolve the reference pointed at by HEAD. 3346 * 3347 * @param head the reference which will be retrieved 3348 */ 3349 [CCode(cname = "git_repository_head", instance_pos = -1)] 3350 public Error get_head(out Reference head); 3351 3352 /** 3353 * Get the index file for this repository. 3354 * 3355 * If a custom index has not been set, the default 3356 * index for the repository will be returned (the one 3357 * located in //.git/index//). 3358 * 3359 * If a custom index has not been set, the default 3360 * index for the repository will be returned (the one 3361 * located in //.git/index//). 3362 * 3363 */ 3364 [CCode(cname = "git_repository_index", instance_pos = -1)] 3365 public void get_index(out Index index); 3366 3367 /** 3368 * Get the information for a particular remote 3369 * 3370 * The name will be checked for validity. 3371 * @param remote the new remote object 3372 * @param name the remote's name 3373 * @see create_tag 3374 */ 3375 [CCode(cname = "git_remote_load", instance_pos = 1.2)] 3376 public Error get_remote(out Remote remote, string name); 3377 3378 /** 3379 * Return the name of remote that the remote tracking branch belongs to. 3380 * 3381 * @param remote_name The buffer which will be filled with the name of the 3382 * remote. Pass null if you just want to get the needed size of the name of 3383 * the remote as the output value. 3384 * 3385 * @param canonical_branch_name name of the remote tracking branch. 3386 * 3387 * @return Number of characters in the reference name including the 3388 * trailing NUL byte; {@link Error.NOTFOUND} when no remote matching remote 3389 * was found, {@link Error.AMBIGUOUS} when the branch maps to several 3390 * remotes, otherwise an error code. 3391 */ 3392 [CCode(cname = "git_branch_remote_name", insance_pos = 1.2)] 3393 public int get_branch_remote_name([CCode(array_length_type = "size_t")] uint8[]? remote_name, string canonical_branch_name); 3394 3395 /** 3396 * Get the Reference Database Backend for this repository. 3397 * 3398 * If a custom refsdb has not been set, the default database for the 3399 * repository will be returned (the one that manipulates loose and packed 3400 * references in the '''.git''' directory). 3401 */ 3402 [CCode(cname = "git_repository_refdb", instance_pos = -1)] 3403 public Error get_refdb(out RefDb? refdb); 3404 3405 /** 3406 * Get a list of the configured remotes for a repo 3407 * 3408 * @param remotes_list a string array with the names of the remotes 3409 */ 3410 [CCode(cname = "git_remote_list", instance_pos = -1)] 3411 public Error get_remote_list(out string_array remotes_list); 3412 3413 /** 3414 * Fill a list with all the tags in the Repository 3415 * 3416 * @param tag_names where the tag names will be stored 3417 */ 3418 [CCode(cname = "git_tag_list", instance_pos = -1)] 3419 public Error get_tag_list(string_array tag_names); 3420 3421 /** 3422 * Fill a list with all the tags in the Repository which name match a 3423 * defined pattern 3424 * 3425 * If an empty pattern is provided, all the tags will be returned. 3426 * 3427 * @param tag_names the tag names will be stored 3428 * @param pattern standard shell-like (fnmatch) pattern 3429 */ 3430 [CCode(cname = "git_tag_list_match", instance_pos = -1)] 3431 public Error get_tag_list_match(out string_array tag_names, string pattern); 3432 3433 /** 3434 * Return the name of the reference supporting the remote tracking branch, 3435 * given the name of a local branch reference. 3436 * 3437 * @param tracking_branch_name The buffer which will be filled with the 3438 * name of the reference, or null if you just want to get the needed size 3439 * of the name of the reference as the output value. 3440 * 3441 * @param canonical_branch_name name of the local branch. 3442 * 3443 * @return number of characters in the reference name including the 3444 * trailing NUL byte; otherwise an error code. 3445 */ 3446 [CCode(cname = "git_branch_tracking_name", instance_pos = 1.3)] 3447 public int get_tracking_branch_name([CCode(array_length_type = "size_t")] char[]? tracking_branch_name, string canonical_branch_name); 3448 3449 /** 3450 * Allocate a new revision walker to iterate through a repo. 3451 * 3452 * This revision walker uses a custom memory pool and an internal commit 3453 * cache, so it is relatively expensive to allocate. 3454 * 3455 * For maximum performance, this revision walker should be reused for 3456 * different walks. 3457 * 3458 * This revision walker is ''not'' thread safe: it may only be used to walk 3459 * a repository on a single thread; however, it is possible to have several 3460 * revision walkers in several different threads walking the same 3461 * repository. 3462 * 3463 * @param walker the new revision walker 3464 */ 3465 [CCode(cname = "git_revwalk_new", instance_pos = -1)] 3466 public Error get_walker(out RevisionWalker walker); 3467 3468 /** 3469 * Calculate hash of file using repository filtering rules. 3470 * 3471 * If you simply want to calculate the hash of a file on disk with no filters, 3472 * you can just use the {@link object_id.hashfile} API. However, if you 3473 * want to hash a file in the repository and you want to apply filtering 3474 * rules (e.g. crlf filters) before generating the SHA, then use this 3475 * function. 3476 * 3477 * @param path Path to file on disk whose contents should be hashed. This can be a relative path. 3478 * @param type The object type to hash 3479 * @param as_path The path to use to look up filtering rules. If this is 3480 * null, then the path parameter will be used instead. If this is passed as 3481 * the empty string, then no filters will be applied when calculating the 3482 * hash. 3483 */ 3484 [CCode(cname = "git_repository_hashfile", instance_pos = 1.1)] 3485 public Error hashfile(out object_id id, string path, ObjectType type, string? as_path = null); 3486 3487 /** 3488 * Iterate over the branches in the repository. 3489 * 3490 * @param list_flags Filtering flags for the branch listing. 3491 */ 3492 [CCode(cname = "git_branch_foreach")] 3493 public Error for_each_branch(BranchType list_flags, Branch branch); 3494 /** 3495 * Test if the ignore rules apply to a given path. 3496 * 3497 * This function checks the ignore rules to see if they would apply to the 3498 * given file. This indicates if the file would be ignored regardless of 3499 * whether the file is already in the index or commited to the repository. 3500 * 3501 * One way to think of this is if you were to do '''git add .''' on the 3502 * directory containing the file, would it be added or not? 3503 * 3504 * @param path the file to check ignores for, relative to the repo's 3505 * workdir. 3506 */ 3507 [CCode(cname = "git_ignore_path_is_ignored", instance_pos = 1.1)] 3508 public Error is_path_ignored(out bool ignored, string path); 3509 3510 [CCode(cname = "git_branch_foreach", instance_pos = 1.2)] 3511 public Error list_branches(out string_array branch_names, BranchType list_flags); 3512 3513 /** 3514 * Fill a list with all the references that can be found 3515 * in a repository. 3516 * 3517 * The listed references may be filtered by type, or using 3518 * a bitwise OR of several types. Use the magic value 3519 * {@link ReferenceType.LISTALL} to obtain all references, including 3520 * packed ones. 3521 * 3522 * @param array where the reference names will be stored 3523 * @param list_flags Filtering flags for the reference listing. 3524 */ 3525 [CCode(cname = "git_reference_listall", instance_pos = 1.2)] 3526 public Error list_all(out string_array array, ReferenceType list_flags); 3527 3528 /** 3529 * Convert a tree entry to the object it points too. 3530 * 3531 * @param object pointer to the converted object 3532 * @param entry a tree entry 3533 */ 3534 [CCode(cname = "git_tree_entry_to_object", instance_pos = 1.2)] 3535 public Error load(out Object object, TreeEntry entry); 3536 3537 /** 3538 * Lookup a blob object from a repository. 3539 * 3540 * @param blob the looked up blob 3541 * @param id identity of the blob to locate. 3542 */ 3543 [CCode(cname = "git_blob_lookup", instance_pos = 1.2)] 3544 public Error lookup_blob(out Blob blob, object_id id); 3545 3546 /** 3547 * Lookup a blob object from a repository, given a prefix of its identifier 3548 * (short id). 3549 * 3550 * @see lookup_object_by_prefix 3551 * 3552 * @param blob the looked up blob 3553 * @param id identity of the blob to locate. 3554 * @param len the length of the short identifier 3555 */ 3556 [CCode(cname = "git_blob_lookup_prefix", instance_pos = 1.2)] 3557 public Error lookup_blob_by_prefix(out Blob blob, object_id id, size_t len); 3558 /** 3559 * Lookup a branch by its name. 3560 * 3561 * @param branch_name Name of the branch to be looked-up; this name is 3562 * validated for consistency. 3563 */ 3564 [CCode(cname = "git_branch_lookup", instance_pos = 1.1)] 3565 public Error lookup_branch(out Reference? branch, string branch_name, BranchType branch_type); 3566 3567 /** 3568 * Lookup a commit object from a repository. 3569 * 3570 * @param commit the looked up commit 3571 * @param id identity of the commit to locate. If the object is an annotated tag it will be peeled back to the commit. 3572 */ 3573 [CCode(cname = "git_commit_lookup", instance_pos = 1.2)] 3574 public Error lookup_commit(out Commit commit, object_id id); 3575 3576 /** 3577 * Lookup a commit object from a repository, given a prefix of its 3578 * identifier (short id). 3579 * 3580 * @see lookup_object_by_prefix 3581 * 3582 * @param commit the looked up commit 3583 * @param id identity of the commit to locate. If the object is an annotated tag it will be peeled back to the commit. 3584 * @param len the length of the short identifier 3585 */ 3586 [CCode(cname = "git_commit_lookup_prefix", instance_pos = 1.2)] 3587 public Error lookup_commit_by_prefix(out Commit commit, object_id id, size_t len); 3588 3589 /** 3590 * Lookup a reference to one of the objects in a repostory. 3591 * 3592 * The //type// parameter must match the type of the object in the ODB; the 3593 * method will fail otherwise. The special value {@link ObjectType.ANY} 3594 * may be passed to let the method guess the object's type. 3595 * 3596 * @param object the looked-up object 3597 * @param id the unique identifier for the object 3598 * @param type the type of the object 3599 * @return a reference to the object 3600 */ 3601 [CCode(cname = "git_object_lookup", instance_pos = 1.2)] 3602 public Error lookup_object(out Object object, object_id id, ObjectType type); 3603 3604 /** 3605 * Lookup a reference to one of the objects in a repostory, given a prefix 3606 * of its identifier (short id). 3607 * 3608 * The object obtained will be so that its identifier matches the first 3609 * //len// hexadecimal characters (packets of 4 bits) of the given //id//. 3610 * //len// must be at least {@link object_id.MIN_PREFIX_LENGTH}, and long 3611 * enough to identify a unique object matching the prefix; otherwise the 3612 * method will fail. 3613 * 3614 * The //type// parameter must match the type of the object in the ODB; the 3615 * method will fail otherwise. The special value {@link ObjectType.ANY} 3616 * may be passed to let the method guess the object's type. 3617 * 3618 * @param object where to store the looked-up object 3619 * @param id a short identifier for the object 3620 * @param len the length of the short identifier 3621 * @param type the type of the object 3622 */ 3623 [CCode(cname = "git_object_lookup_prefix", instance_pos = 1.2)] 3624 public Error lookup_object_by_prefix(out Object object, object_id id, size_t len, ObjectType type); 3625 3626 /** 3627 * Lookup a reference by its name in a repository. 3628 * 3629 * @param reference the looked-up reference 3630 * @param name the long name for the reference (e.g., HEAD, ref/heads/master, refs/tags/v0.1.0, ...) 3631 */ 3632 [CCode(cname = "git_reference_lookup", instance_pos = 1.2)] 3633 public Error lookup_reference(out Reference reference, string name); 3634 3635 /** 3636 * Lookup a reference by name and resolve immediately to an ID. 3637 * 3638 * @param name The long name for the reference 3639 */ 3640 [CCode(cname = "git_reference_name_to_id", instance_pos = 1.2)] 3641 public Error lookup_reference_to_id(out object_id id, string name); 3642 3643 /** 3644 * Lookup submodule information by name or path. 3645 * 3646 * Given either the submodule name or path (they are ususally the same), 3647 * this returns a structure describing the submodule. 3648 * 3649 * @param name The name of the submodule. Trailing slashes will be ignored. 3650 */ 3651 [CCode(cname = "git_submodule_lookup", instance_pos = 1.2)] 3652 public Error lookup_submodule(out unowned Submodule? submodule, string name); 3653 3654 /** 3655 * Lookup a tag object from the repository. 3656 * 3657 * @param tag pointer to the looked up tag 3658 * @param id identity of the tag to locate. 3659 */ 3660 [CCode(cname = "git_tag_lookup", instance_pos = 1.2)] 3661 public Error lookup_tag(out Tag tag, object_id id); 3662 3663 /** 3664 * Lookup a tag object from the repository, given a prefix of its 3665 * identifier (short id). 3666 * 3667 * @see lookup_object_by_prefix 3668 * 3669 * @param tag pointer to the looked up tag 3670 * @param id identity of the tag to locate. 3671 * @param len the length of the short identifier 3672 */ 3673 [CCode(cname = "git_tag_lookup_prefix", instance_pos = 1.2)] 3674 public Error prefix_lookup_tag(out Tag tag, object_id id, uint len); 3675 3676 /** 3677 * Lookup a tree object from the repository. 3678 * 3679 * @param tree the looked up tree 3680 * @param id identity of the tree to locate. 3681 */ 3682 [CCode(cname = "git_tree_lookup", instance_pos = 1.2)] 3683 public Error lookup_tree(out Tree tree, object_id id); 3684 3685 /** 3686 * Lookup a tree object from the repository, given a prefix of its 3687 * identifier (short id). 3688 * 3689 * @see lookup_object_by_prefix 3690 * 3691 * @param tree the looked up tree 3692 * @param id identity of the tree to locate. 3693 * @param len the length of the short identifier 3694 */ 3695 [CCode(cname = "git_tree_lookup_prefix", instance_pos = 1.2)] 3696 public Error lookup_tree_by_prefix(out Tree tree, object_id id, uint len); 3697 3698 /** 3699 * Create a new reference database and automatically add 3700 * the default backends: 3701 * 3702 * - git_refdb_dir: read and write loose and packed refs from disk, 3703 * assuming the repository dir as the folder 3704 */ 3705 [CCode(cname = "git_refdb_open", instance_pos = -1)] 3706 public Error open_refdb(out RefDb? refdb); 3707 3708 /** 3709 * Find an object, as specified by a revision string. See the gitrevisions 3710 * manual page, or the documentation for '''git rev-parse''' for 3711 * information on the syntax accepted. 3712 * 3713 * @param spec the textual specification for an object 3714 */ 3715 [CCode(cname = "git_revparse_single", instance_pos = 1.1)] 3716 public Error parse(out Object? obj, string spec); 3717 3718 /** 3719 * Read the note for an object 3720 * @param notes_ref ID reference to use (optional); defaults to "refs/notes/commits" 3721 * @param id ID of the object 3722 */ 3723 [CCode(cname = "git_note_read", instance_pos = 1.2)] 3724 public Error read_note(out Note? note, string? notes_ref, object_id id); 3725 /** 3726 * Get the default notes reference for a repository 3727 */ 3728 [CCode(cname = "git_note_default_ref", instance_pos = -1)] 3729 public Error read_note_default_ref(out unowned string note); 3730 3731 /** 3732 * Reread all submodule info. 3733 * 3734 * Call this to reload all cached submodule information for the repo. 3735 */ 3736 [CCode(cname = "git_submodule_reload_all")] 3737 public Error reload_submodules(); 3738 3739 /** 3740 * Remove the note for an object 3741 * 3742 * @param notes_ref ID reference to use (optional); defaults to "refs/notes/commits" 3743 * @param author signature of the notes commit author 3744 * @param committer signature of the notes commit committer 3745 * @param id the id which note's to be removed 3746 */ 3747 [CCode(cname = "git_note_remove")] 3748 public Error remove_note(string? notes_ref, Signature author, Signature committer, object_id id); 3749 3750 /** 3751 * Sets the current head to the specified commit oid and optionally resets 3752 * the index and working tree to match. 3753 * 3754 * When specifying a Soft kind of reset, the head will be moved to the commit. 3755 * 3756 * Specifying a Mixed kind of reset will trigger a Soft reset and the index 3757 * will be replaced with the content of the commit tree. 3758 * 3759 * @param target Object to which the Head should be moved to. This object 3760 * must belong to this repository and can either be a {@link Commit} or a 3761 * {@link Tag}. When a {@link Tag} is being passed, it should be 3762 * dereferencable to a {@link Commit} which oid will be used as the target 3763 * of the branch. 3764 * @param reset_type Kind of reset operation to perform. 3765 */ 3766 [CCode(cname = "git_reset")] 3767 public Error reset(Object target, ResetType reset_type); 3768 3769 /** 3770 * Updates some entries in the index from the target commit tree. 3771 * 3772 * The scope of the updated entries is determined by the paths 3773 * specified. 3774 * 3775 * @param target The committish which content will be used to reset the 3776 * content of the index. Passing null will result in removing entries in 3777 * the index matching the provided pathspecs. 3778 * 3779 * @param pathspecs List of pathspecs to operate on. 3780 */ 3781 [CCode(cname = "git_reset_default")] 3782 public Error reset_default(Object? target, string_array pathspecs); 3783 3784 /** 3785 * Save the local modifications to a new stash. 3786 * 3787 * @param id id of the commit containing the stashed state. This commit is 3788 * also the target of the direct reference refs/stash. 3789 * @param stasher The identity of the person performing the stashing. 3790 * @param message description along with the stashed state. 3791 */ 3792 [CCode(cname = "git_stash_save", instance_pos = 1.1)] 3793 public Error save_stash(out object_id id, Signature stasher, string? message = null, StashFlag flags = StashFlag.DEFAULT); 3794 3795 /** 3796 * Set the configuration file for this repository 3797 * 3798 * This configuration file will be used for all configuration 3799 * queries involving this repository. 3800 */ 3801 [CCode(cname = "git_repository_set_config")] 3802 public void set_config(Config config); 3803 3804 /** 3805 * Set the Object Database for this repository 3806 * 3807 * The ODB will be used for all object-related operations involving this 3808 * repository. 3809 */ 3810 [CCode(cname = "git_repository_set_odb")] 3811 public void set_db(Database.Handle db); 3812 /** 3813 * Make the repository HEAD point to the specified reference. 3814 * 3815 * If the provided reference points to a Tree or a Blob, the HEAD is 3816 * unaltered and an error is returned. 3817 * 3818 * If the provided reference points to a branch, the HEAD will point to 3819 * that branch, staying attached, or become attached if it isn't yet. If 3820 * the branch doesn't exist yet, no error will be return. The HEAD will 3821 * then be attached to an unborn branch. 3822 * 3823 * Otherwise, the HEAD will be detached and will directly point to the 3824 * Commit. 3825 * 3826 * @param refname Canonical name of the reference the HEAD should point at 3827 */ 3828 [CCode(cname = "git_repository_set_head")] 3829 public Error set_head(string refname); 3830 3831 /** 3832 * Make the repository HEAD directly point to the Commit. 3833 * 3834 * If the provided committish cannot be found in the repository, the HEAD 3835 * is unaltered and {@link Error.NOTFOUND} is returned. 3836 * 3837 * If the provided commitish cannot be peeled into a commit, the HEAD is 3838 * unaltered and and error is returned. 3839 * 3840 * Otherwise, the HEAD will eventually be detached and will directly point to 3841 * the peeled Commit. 3842 * 3843 * @param commitish Object id of the Commit the HEAD should point to 3844 * @return 0 on success, or an error code 3845 */ 3846 [CCode(cname = "git_repository_set_head_detached")] 3847 public Error set_head_detached(object_id commitish); 3848 3849 /** 3850 * Set the index file for this repository 3851 * 3852 * This index will be used for all index-related operations 3853 * involving this repository. 3854 */ 3855 [CCode(cname = "git_repository_set_index")] 3856 public void set_index(Index index); 3857 3858 /** 3859 * Set the Reference Database Backend for this repository 3860 * 3861 * The refdb will be used for all reference related operations involving 3862 * this repository. 3863 */ 3864 [CCode(cname = "git_repository_set_refdb")] 3865 public void set_refdb(RefDb refdb); 3866 3867 /** 3868 * Set the working directory. 3869 * @param workdir The path to a working directory 3870 * @param update_gitlink Create/update gitlink in workdir and set config 3871 * "core.worktree" (if workdir is not the parent of the .git directory) 3872 */ 3873 [CCode(cname = "git_repository_set_workdir")] 3874 public Error set_workdir(string workdir, bool update_gitlink); 3875 3876 /** 3877 * Test if the ignore rules apply to a given file. 3878 * 3879 * This function simply checks the ignore rules to see if they would apply 3880 * to the given file. Unlike {@link get_file_status}, this indicates if 3881 * the file would be ignored regardless of whether the file is already in 3882 * the index or in the repository. 3883 * 3884 * @param path the file to check ignores for, rooted at the repo's workdir 3885 * @param ignored false if the file is not ignored, true if it is 3886 * @return {@link Error.OK} if the ignore rules could be processed 3887 * for the file (regardless of whether it exists or not), or an error if 3888 * they could not. 3889 */ 3890 [CCode(cname = "git_status_should_ignore", instance_pos = 1.2)] 3891 public Error should_ignore(out bool ignored, string path); 3892 3893 /** 3894 * Write the contents of the tree builder as a tree object 3895 * 3896 * The tree builder will be written to the repositrory, and it's 3897 * identifying SHA1 hash will be stored in the id pointer. 3898 * 3899 * @param id Pointer where to store the written id 3900 * @param builder Tree builder to write 3901 */ 3902 [CCode(cname = "git_treebuilder_write", instance_pos = 1.2)] 3903 public Error write(object_id id, TreeBuilder builder); 3904 3905 } 3906 3907 /** 3908 * An in-progress walk through the commits in a repo 3909 */ 3910 [CCode(cname = "git_revwalk", free_function = "git_revwalk_free", has_type_id = false)] 3911 [Compact] 3912 public class RevisionWalker { 3913 3914 /** 3915 * The repository on which this walker is operating. 3916 */ 3917 public Repository repository { 3918 [CCode(cname = "git_revwalk_repository")] 3919 get; 3920 } 3921 3922 /** 3923 * Mark a commit (and its ancestors) uninteresting for the output. 3924 * 3925 * The given id must belong to a commit on the walked repository. 3926 * 3927 * The resolved commit and all its parents will be hidden from the output 3928 * on the revision walk. 3929 * 3930 * @param id the id of commit that will be ignored during the traversal 3931 */ 3932 [CCode(cname = "git_revwalk_hide")] 3933 public Error hide(object_id id); 3934 3935 /** 3936 * Hide the OID pointed to by a reference 3937 * 3938 * The reference must point to a commit. 3939 * 3940 * @param refname the referece to hide 3941 */ 3942 [CCode(cname = "git_revwalk_hide_ref")] 3943 public Error hide_ref(string refname); 3944 3945 /** 3946 * Get the next commit from the revision walk. 3947 * 3948 * The initial call to this method is ''not'' blocking when iterating through 3949 * a repo with a time-sorting mode. 3950 * 3951 * Iterating with topological or inverted modes makes the initial call 3952 * blocking to preprocess the commit list, but this block should be mostly 3953 * unnoticeable on most repositories (topological preprocessing times at 3954 * 0.3s on the git.git repo). 3955 * 3956 * The revision walker is reset when the walk is over. 3957 * 3958 * @param id where to store the id of the next commit 3959 */ 3960 [CCode(cname = "git_revwalk_next", instance_pos = -1)] 3961 public Error next(out object_id id); 3962 3963 /** 3964 * Mark a commit to start traversal from. 3965 * 3966 * The given id must belong to a commit on the walked repository. 3967 * 3968 * The given commit will be used as one of the roots when starting the 3969 * revision walk. At least one commit must be pushed the repository before 3970 * a walk can be started. 3971 * 3972 * @param id the id of the commit to start from. 3973 */ 3974 [CCode(cname = "git_revwalk_push")] 3975 public Error push(object_id id); 3976 3977 /** 3978 * Push the OID pointed to by a reference 3979 * 3980 * The reference must point to a commit. 3981 * 3982 * @param refname the referece to push 3983 */ 3984 [CCode(cname = "git_revwalk_push_ref")] 3985 public Error push_ref(string refname); 3986 3987 /** 3988 * Push matching references 3989 * 3990 * The OIDs pinted to by the references that match the given glob 3991 * pattern will be pushed to the revision walker. 3992 * 3993 * A leading 'refs/' is implied it not present as well as a trailing 3994 * '/ *' if the glob lacks '?', '*' or '['. 3995 * 3996 * @param glob the glob pattern references should match 3997 */ 3998 [CCode(cname = "git_revwalk_push_glob")] 3999 public Error push_glob(string glob); 4000 4001 /** 4002 * Push the repository's HEAD 4003 */ 4004 [CCode(cname = "git_revwalk_push_head")] 4005 public Error push_head(); 4006 4007 /** 4008 * Reset the revision walker for reuse. 4009 * 4010 * This will clear all the pushed and hidden commits, and leave the walker 4011 * in a blank state (just like at creation) ready to receive new commit 4012 * pushes and start a new walk. 4013 * 4014 * The revision walk is automatically reset when a walk is over. 4015 */ 4016 [CCode(cname = "git_revwalk_reset")] 4017 public void reset(); 4018 4019 /** 4020 * Change the sorting mode when iterating through the repository's 4021 * contents. 4022 * 4023 * Changing the sorting mode resets the walker. 4024 * 4025 * @param sort combination of sort flags 4026 */ 4027 [CCode(cname = "git_revwalk_sorting")] 4028 public void set_sorting(Sorting sort); 4029 4030 /** 4031 * Hide matching references. 4032 * 4033 * The OIDs pinted to by the references that match the given glob 4034 * pattern and their ancestors will be hidden from the output on the 4035 * revision walk. 4036 * 4037 * A leading 'refs/' is implied it not present as well as a trailing 4038 * '/ *' if the glob lacks '?', '*' or '['. 4039 * 4040 * @param glob the glob pattern references should match 4041 */ 4042 [CCode(cname = "git_revwalk_hide_glob")] 4043 public Error hide_glob(string glob); 4044 4045 /** 4046 * Hide the repository's HEAD 4047 */ 4048 [CCode(cname = "git_revwalk_hide_head")] 4049 public Error hide_head(); 4050 } 4051 4052 /** 4053 * An action signature (e.g. for committers, taggers, etc) 4054 */ 4055 [CCode(cname = "git_signature", free_function = "git_signature_free", copy_function = "git_signature_dup", has_type_id = false)] 4056 [Compact] 4057 public class Signature { 4058 /** 4059 * Email of the author 4060 */ 4061 public string email; 4062 /** 4063 * Full name of the author 4064 */ 4065 public string name; 4066 /** 4067 * Time when the action happened 4068 */ 4069 public time when; 4070 4071 /** 4072 * Create a new action signature. 4073 * 4074 * Note: angle brackets characters are not allowed in either the name or 4075 * the email. 4076 * @param sig new signature, null in case of error 4077 * @param name name of the person 4078 * @param email email of the person 4079 * @param time time when the action happened 4080 * @param offset timezone offset in minutes for the time 4081 */ 4082 [CCode(cname = "git_signature_new")] 4083 public static int create(out Signature? sig, string name, string email, int64 time, int offset); 4084 4085 /** 4086 * Create a new action signature with a timestamp of now. 4087 * 4088 * @param sig new signature, null in case of error 4089 * @param name name of the person 4090 * @param email email of the person 4091 */ 4092 [CCode(cname = "git_signature_now")] 4093 public static int create_now(out Signature? sig, string name, string email); 4094 } 4095 4096 /** 4097 * Description of submodule 4098 * 4099 * This record describes a submodule found in a repository. There 4100 * should be an entry for every submodule found in the HEAD and for 4101 * every submodule described in .gitmodules. 4102 */ 4103 [CCode(cname = "git_submodule", has_type_id = false)] 4104 [Compact] 4105 public class Submodule { 4106 /** 4107 * The name of the submodule from .gitmodules. 4108 */ 4109 public string name { 4110 [CCode(cname = "git_submodule_name")] 4111 get; 4112 } 4113 /** 4114 * The path to the submodule from the repo working directory. 4115 * 4116 * It is almost always the same as {@link name}. 4117 */ 4118 public string path { 4119 [CCode(cname = "git_submodule_path")] 4120 get; 4121 } 4122 /** 4123 * The url for the submodule. 4124 * 4125 * If deleted but not commited, this will be null. 4126 */ 4127 public string? url { 4128 [CCode(cname = "git_submodule_url")] 4129 get; 4130 [CCode(cname = "git_submodule_set_url")] 4131 set; 4132 } 4133 /** 4134 * Get the OID for the submodule in the index. 4135 */ 4136 public object_id? index_id { 4137 [CCode(cname = "git_submodule_index_id")] 4138 get; 4139 } 4140 /** 4141 * Get the OID for the submodule in the current HEAD tree. 4142 */ 4143 public object_id? head_id { 4144 [CCode(cname = "git_submodule_head_id")] 4145 get; 4146 } 4147 /** 4148 * Whether or not to fetch submodules of submodules recursively. 4149 */ 4150 public bool fetch_recurse { 4151 [CCode(cname = "git_submodule_fetch_recurse_submodules")] 4152 get; 4153 [CCode(cname = "git_submodule_set_fetch_recurse_submodules")] 4154 set; 4155 } 4156 /** 4157 * The containing repository for a submodule. 4158 * 4159 * This returns a pointer to the repository that contains the submodule. 4160 */ 4161 public Repository repository { 4162 [CCode(cname = "git_submodule_owner")] 4163 get; 4164 } 4165 4166 /** 4167 * Get the OID for the submodule in the current working directory. 4168 * 4169 * This returns the OID that corresponds to looking up 'HEAD' in the 4170 * checked out submodule. If there are pending changes in the index or 4171 * anything else, this won't notice that. You should check 4172 * {@link status} for a more complete picture about the state of the 4173 * working directory. 4174 */ 4175 public object_id? wd_id { 4176 [CCode(cname = "git_submodule_wd_id")] 4177 get; 4178 } 4179 4180 /** 4181 * The ignore rule for the submodule. 4182 */ 4183 [CCode(cname = "git_submodule_ignore")] 4184 public SubmoduleIgnore ignore { 4185 [CCode(cname = "git_submodule_ignore")] 4186 get; 4187 [CCode(cname = "git_submodule_set_ignore")] 4188 set; 4189 } 4190 4191 /** 4192 * The update rule for the submodule. 4193 */ 4194 public SubmoduleUpdate update { 4195 [CCode(cname = "git_submodule_update")] 4196 get; 4197 [CCode(cname = "git_submodule_set_update")] 4198 set; 4199 } 4200 4201 /** 4202 * Resolve the setup of a new git submodule. 4203 * 4204 * This should be called on a submodule once you have called add setup and 4205 * done the clone of the submodule. This adds the .gitmodules file and the 4206 * newly cloned submodule to the index to be ready to be committed (but 4207 * doesn't actually do the commit). 4208 */ 4209 [CCode(cname = "git_submodule_add_finalize")] 4210 public Error add_finalize(); 4211 4212 /** 4213 * Add current submodule HEAD commit to index of superproject. 4214 * 4215 * @param write_index if this should immediately write the index file. If 4216 * you pass this as false, you will have to explicitly call {@link Index.write} 4217 * on it to save the change. 4218 */ 4219 [CCode(cname = "git_submodule_add_to_index")] 4220 public Error add_to_index(bool write_index); 4221 4222 /** 4223 * Copy submodule info into ".git/config" file. 4224 * 4225 * Just like "git submodule init", this copies information about the 4226 * submodule into ".git/config". You can use the accessor functions above 4227 * to alter the in-memory git_submodule object and control what is written 4228 * to the config, overriding what is in .gitmodules. 4229 * 4230 * @param overwrite By default, existing entries will not be overwritten, 4231 * but setting this to true forces them to be updated. 4232 */ 4233 [CCode(cname = "git_submodule_init")] 4234 public Error init(bool overwrite); 4235 4236 /** 4237 * Get the locations of submodule information. 4238 * 4239 * This is a bit like a very lightweight version of {@link status}. 4240 * It just returns a made of the first four submodule status values (i.e. 4241 * the ones like {@link SubmoduleStatus.IN_HEAD}, etc) that tell you where 4242 * the submodule data comes from (i.e. the HEAD commit, gitmodules file, 4243 * etc.). 4244 * 4245 * This can be useful if you want to know if the submodule is present in 4246 * the working directory at this point in time, etc. 4247 */ 4248 [CCode(cname = "git_submodule_location", instance_pos = -1)] 4249 public Error location(out SubmoduleStatus status); 4250 4251 /** 4252 * Copy submodule remote info into submodule repo. 4253 * 4254 * This copies the information about the submodules URL into the checked 4255 * out submodule config, acting like "git submodule sync". This is useful 4256 * if you have altered the URL for the submodule (or it has been altered by 4257 * a fetch of upstream changes) and you need to update your local repo. 4258 */ 4259 [CCode(cname = "git_submodule_sync")] 4260 public Error sync(); 4261 4262 /** 4263 * Open the repository for a submodule. 4264 * 4265 * This will only work if the submodule is checked out into the working 4266 * directory. 4267 */ 4268 [CCode(cname = "git_submodule_open", instance_pos = -1)] 4269 public Error open(out Repository? repo); 4270 4271 /** 4272 * Reread submodule info from config, index, and HEAD. 4273 * 4274 * Call this to reread cached submodule information for this submodule if 4275 * you have reason to believe that it has changed. 4276 */ 4277 [CCode(cname = "git_submodule_reload")] 4278 public Error reload(); 4279 4280 /** 4281 * Write submodule settings to .gitmodules file. 4282 * 4283 * This commits any in-memory changes to the submodule to the gitmodules 4284 * file on disk. You may also be interested in `git_submodule_init()` 4285 * which writes submodule info to ".git/config" (which is better for local 4286 * changes to submodule settings) and/or `git_submodule_sync()` which 4287 * writes settings about remotes to the actual submodule repository. 4288 */ 4289 [CCode(cname = "git_submodule_save")] 4290 public Error save(); 4291 4292 /** 4293 * Get the status for a submodule. 4294 * 4295 * This looks at a submodule and tries to determine the status. 4296 */ 4297 [CCode(cname = "git_submodule_status", instance_pos = -1)] 4298 public Error status(out SubmoduleStatus status); 4299 } 4300 4301 /** 4302 * Parsed representation of a tag object. 4303 */ 4304 [CCode(cname = "git_tag", free_function = "git_tag_free", has_type_id = false)] 4305 [Compact] 4306 public class Tag : Object { 4307 /** 4308 * The id of a tag. 4309 */ 4310 public object_id? id { 4311 [CCode(cname = "git_tag_id")] 4312 get; 4313 } 4314 4315 /** 4316 * The message of a tag 4317 */ 4318 public string message { 4319 [CCode(cname = "git_tag_message")] 4320 get; 4321 } 4322 4323 /** 4324 * The name of a tag 4325 */ 4326 public string name { 4327 [CCode(cname = "git_tag_name")] 4328 get; 4329 } 4330 4331 /** 4332 * The tagger (author) of a tag 4333 */ 4334 public Signature tagger { 4335 [CCode(cname = "git_tag_tagger")] 4336 get; 4337 } 4338 4339 /** 4340 * The id of the tagged object of a tag 4341 */ 4342 public object_id? target_id { 4343 [CCode(cname = "git_tag_target_id")] 4344 get; 4345 } 4346 4347 /** 4348 * The type of a tag's tagged object 4349 */ 4350 public ObjectType target_type { 4351 [CCode(cname = "git_tag_target_type")] 4352 get; 4353 } 4354 4355 /** 4356 * Get the tagged object of a tag 4357 * 4358 * This method performs a repository lookup for the given object and 4359 * returns it 4360 * 4361 * @param target where to store the target 4362 */ 4363 [CCode(cname = "git_tag_target", instance_pos = -1)] 4364 public Error lookup_target(out Object target); 4365 4366 /** 4367 * Recursively peel a tag until a non-tag-object is met 4368 */ 4369 [CCode(cname = "git_tag_peel", instance_pos = -1)] 4370 public Error peel(out Object result); 4371 } 4372 4373 /** 4374 * Representation of a tree object. 4375 */ 4376 [CCode(cname = "git_tree", free_function = "git_tree_free", has_type_id = false)] 4377 [Compact] 4378 public class Tree : Object { 4379 /** 4380 * The id of a tree. 4381 */ 4382 public object_id? id { 4383 [CCode(cname = "git_tree_id")] 4384 get; 4385 } 4386 4387 public Repository repository { 4388 [CCode(cname = "git_tree_owner")] 4389 get; 4390 } 4391 4392 /** 4393 * Get the number of entries listed in a tree 4394 */ 4395 public size_t size { 4396 [CCode(cname = "git_tree_entrycount")] 4397 get; 4398 } 4399 4400 /** 4401 * Lookup a tree entry by its position in the tree 4402 * 4403 * @param idx the position in the entry list 4404 * @return the tree entry; null if not found 4405 */ 4406 [CCode(cname = "git_tree_entry_byindex")] 4407 public unowned TreeEntry? get(size_t idx); 4408 /** 4409 * Lookup a tree entry by SHA value. 4410 * 4411 * Warning: this must examine every entry in the tree, so it is not fast. 4412 * 4413 * @param id the sha being looked for 4414 * @return the tree entry; null if not found 4415 */ 4416 [CCode(cname = "git_tree_entry_byoid")] 4417 public unowned TreeEntry? get_by_id(object_id id); 4418 4419 /** 4420 * Lookup a tree entry by its filename 4421 * 4422 * @param filename the filename of the desired entry 4423 * @return the tree entry; null if not found 4424 */ 4425 [CCode(cname = "git_tree_entry_byname")] 4426 public unowned TreeEntry? get_by_name(string filename); 4427 4428 /** 4429 * Retrieve a subtree contained in a tree, given its relative path. 4430 * 4431 * @param path Path to the tree entry from which to extract the last tree object 4432 * @return {@link Error.OK} on success; {@link Error.NOTFOUND} if the path does not lead to an entry; otherwise, an error code 4433 */ 4434 [CCode(cname = "git_tree_entry_bypath", instance_pos = 1.2)] 4435 public Error get_by_path(out TreeEntry entry, string path); 4436 4437 /** 4438 * Traverse the entries in a tree and its subtrees in post or pre order 4439 * 4440 * The entries will be traversed in the specified order, children subtrees 4441 * will be automatically loaded as required, and the callback will be 4442 * called once per entry with the current (relative) root for the entry and 4443 * the entry data itself. 4444 * 4445 * If the callback returns a negative value, the passed entry will be 4446 * skiped on the traversal. 4447 * 4448 * @param mode Traversal mode (pre or post-order) 4449 * @param tree_walker Function to call on each tree entry 4450 */ 4451 [CCode(cname = "git_tree_walk")] 4452 public Error walk(WalkMode mode, TreeWalker tree_walker); 4453 } 4454 4455 /** 4456 * Constructor for in-memory trees 4457 */ 4458 [CCode(cname = "git_treebuilder", free_function = "git_treebuilder_free", has_type_id = false)] 4459 [Compact] 4460 public class TreeBuilder { 4461 /** 4462 * The number of entries listed in a treebuilder. 4463 */ 4464 public uint size { 4465 [CCode(cname = "git_treebuilder_entrycount")] 4466 get; 4467 } 4468 4469 /** 4470 * Create a new tree builder. 4471 * 4472 * The tree builder can be used to create or modify trees in memory and 4473 * write them as tree objects to the database. 4474 * 4475 * If the source parameter is not null, the tree builder will be 4476 * initialized with the entries of the given tree. 4477 * 4478 * If the source parameter is null, the tree builder will have no entries 4479 * and will have to be filled manually. 4480 * 4481 * @param builder where to store the tree builder 4482 * @param source source tree to initialize the builder (optional) 4483 */ 4484 [CCode(cname = "git_treebuilder_create")] 4485 public static Error create(out TreeBuilder builder, Tree? source = null); 4486 4487 /** 4488 * Clear all the entires in the builder 4489 */ 4490 [CCode(cname = "git_treebuilder_clear")] 4491 public void clear(); 4492 4493 /** 4494 * Filter the entries in the tree 4495 * 4496 * The filter will be called for each entry in the tree with an entry. If 4497 * the callback returns true, the entry will be filtered (removed from the 4498 * builder). 4499 * @param filter function to filter entries 4500 */ 4501 [CCode(cname = "git_treebuilder_filter")] 4502 public void filter(Filter filter); 4503 4504 /** 4505 * Add or update an entry to the builder 4506 * 4507 * Insert a new entry for the given filename in the builder with the given 4508 * attributes. 4509 * 4510 * If an entry named filename already exists, its attributes will be 4511 * updated with the given ones. 4512 * 4513 * @param entry where to store the entry (optional) 4514 * @param filename Filename of the entry 4515 * @param id SHA1 id of the entry 4516 * @param attributes Folder attributes of the entry 4517 * @return 0 on success; error code otherwise 4518 */ 4519 [CCode(cname = "git_treebuilder_insert", instance_pos = 1.2)] 4520 public Error insert(out unowned TreeEntry? entry = null, string filename, object_id id, Attributes attributes); 4521 4522 /** 4523 * Get an entry from the builder from its filename 4524 * @param filename Name of the entry 4525 * @return the entry; null if not found 4526 */ 4527 [CCode(cname = "git_treebuilder_get")] 4528 public unowned TreeEntry? get(string filename); 4529 4530 /** 4531 * Remove an entry from the builder by its filename 4532 * 4533 * @param filename Filename of the entry to remove 4534 */ 4535 [CCode(cname = "git_treebuilder_remove")] 4536 public Error remove(string filename); 4537 } 4538 4539 /** 4540 * Representation of each one of the entries in a tree object. 4541 */ 4542 [CCode(cname = "git_tree_entry", has_type_id = false, free_function = "git_tree_entry_free", copy_function = "git_tree_entry_dup")] 4543 [Compact] 4544 public class TreeEntry { 4545 4546 /** 4547 * The id of the object pointed by the entry 4548 */ 4549 public unowned object_id? id { 4550 [CCode(cname = "git_tree_entry_id")] 4551 get; 4552 } 4553 4554 /** 4555 * The filename of a tree entry 4556 */ 4557 public string name { 4558 [CCode(cname = "git_tree_entry_name")] 4559 get; 4560 } 4561 4562 /** 4563 * The UNIX file attributes of a tree entry 4564 */ 4565 public FileMode mode { 4566 [CCode(cname = "git_tree_entry_filemode")] 4567 get; 4568 } 4569 4570 /** 4571 * The type of the object pointed by the entry 4572 */ 4573 public ObjectType type { 4574 [CCode(cname = "git_tree_entry_type")] 4575 get; 4576 } 4577 /** 4578 * Compare two tree entries 4579 * 4580 * @param that second tree entry 4581 * @return <0 if this is before that, 0 if this == that, >0 if this is after that 4582 */ 4583 [CCode(cname = "git_tree_entry_cmp")] 4584 public int cmp(TreeEntry that); 4585 4586 /** 4587 * Create a new tree builder. 4588 * 4589 * The tree builder can be used to create or modify trees in memory and 4590 * write them as tree objects to the database. 4591 * 4592 * The tree builder will be initialized with the entries of the given tree. 4593 * 4594 * @param builder where to store the tree builder 4595 */ 4596 [CCode(cname = "git_treebuilder_create", instance_pos = -1)] 4597 public Error create_builder(out TreeBuilder builder); 4598 /** 4599 * Create a copy of a tree entry. 4600 */ 4601 [CCode(cname = "git_tree_entry_dup")] 4602 public TreeEntry dup(); 4603 } 4604 4605 /** 4606 * List of unmerged index entries 4607 */ 4608 [CCode(cname = "git_index", has_type_id = false)] 4609 [Compact] 4610 public class ReucIndex { 4611 /** 4612 * The count of unmerged entries currently in the index 4613 */ 4614 public uint size { 4615 [CCode(cname = "git_index_reuc_entrycount")] 4616 get; 4617 } 4618 /** 4619 * Adds a resolve undo entry for a file based on the given parameters. 4620 * 4621 * The resolve undo entry contains the OIDs of files that were involved in 4622 * a merge conflict after the conflict has been resolved. This allows 4623 * conflicts to be re-resolved later. 4624 * 4625 * If there exists a resolve undo entry for the given path in the index, it 4626 * will be removed. 4627 * 4628 * This method will fail in bare index instances. 4629 * 4630 * @param path filename to add 4631 * @param ancestor_mode mode of the ancestor file 4632 * @param ancestor_id oid of the ancestor file 4633 * @param our_mode mode of our file 4634 * @param our_id oid of our file 4635 * @param their_mode mode of their file 4636 * @param their_id oid of their file 4637 */ 4638 [CCode(cname = "git_index_reuc_add")] 4639 public Error add(string path, FileMode ancestor_mode, object_id ancestor_id, FileMode our_mode, object_id our_id, FileMode their_mode, object_id their_id); 4640 4641 /** 4642 * Remove all resolve undo entries from the index 4643 */ 4644 [CCode(cname = "git_index_reuc_clear")] 4645 public void clear(); 4646 4647 /** 4648 * Finds the resolve undo entry that points to the given path in the Git 4649 * index. 4650 * 4651 * @param path path to search 4652 * @return an index >= 0 if found, -1 otherwise 4653 */ 4654 [CCode(cname = "git_index_reuc_find")] 4655 public Error find(string path); 4656 4657 /** 4658 * Get an unmerged entry from the index. 4659 * 4660 * @param n the position of the entry 4661 * @return a pointer to the unmerged entry; null if out of bounds 4662 */ 4663 [CCode(cname = "git_index_reuc_get_byindex")] 4664 public unowned index_reuc_entry? get(uint n); 4665 4666 /** 4667 * Get an unmerged entry from the index. 4668 * 4669 * @param path path to search 4670 * @return the unmerged entry; null if not found 4671 */ 4672 [CCode(cname = "git_index_reuc_get_bypath")] 4673 public unowned index_reuc_entry? get_by_path(string path); 4674 4675 /** 4676 * Remove an resolve undo entry from the index 4677 * 4678 * @param n position of the resolve undo entry to remove 4679 */ 4680 [CCode(cname = "git_index_reuc_remove")] 4681 public Error remove(size_t n); 4682 } 4683 [CCode(cname = "git_checkout_opts", has_type_id = false, default_value = "GIT_CHECKOUT_OPTS_INIT")] 4684 public struct checkout_opts { 4685 [CCode(cname = "GIT_CHECKOUT_OPTS_VERSION")] 4686 public const uint VERSION; 4687 4688 public uint version; 4689 public unowned CheckoutStategy checkout_strategy; 4690 public bool disable_filters; 4691 /** 4692 * Directory mode. 4693 * 4694 * If set to 0, the default is 0755 used. 4695 */ 4696 public int dir_mode; 4697 /** 4698 * File mode. 4699 * 4700 * If set to 0, the default is 0644 is used. 4701 */ 4702 public int file_mode; 4703 /** 4704 * File open(3) flags. 4705 * 4706 * If set to 0, the default is O_CREAT | O_TRUNC | O_WRONLY is used. 4707 */ 4708 public int file_open_flags; 4709 public CheckoutNotify notify_flags; 4710 [CCode(cname = "notify_cb", delegate_target_cname = "notify_payload")] 4711 public unowned CheckoutNotify? notify; 4712 4713 /** 4714 * Notify the consumer of checkout progress. 4715 */ 4716 [CCode(cname = "progress_cb", delegate_target_cname = "progress_payload")] 4717 public unowned Progress? progress; 4718 4719 /** 4720 * When not null, arrays of fnmatch pattern specifying which paths should be taken into account 4721 */ 4722 public string_array paths; 4723 /** 4724 * Expected content of workdir, defaults to HEAD 4725 */ 4726 public unowned Tree? baseline; 4727 } 4728 4729 [CCode(cname = "git_config_entry", has_type_id = false)] 4730 public struct config_entry{ 4731 public string name; 4732 public string @value; 4733 public ConfigLevel level; 4734 } 4735 4736 /** 4737 * Clone options structure 4738 */ 4739 [CCode(cname = "git_clone_options", has_type_id = false, default_value = "GIT_CLONE_OPTIONS_INIT")] 4740 public struct clone_opts { 4741 [CCode(cname = "GIT_CLONE_OPTIONS_VERSION")] 4742 public const uint VERSION; 4743 public uint version; 4744 public checkout_opts checkout_opts; 4745 /** 4746 * False to create a standard repo, true for a bare repo. 4747 */ 4748 public bool bare; 4749 [CCode(cname = "fetch_progress_cb", delegate_target_cname = "fetch_progress_payload")] 4750 public unowned TransferProgress? fetch_progress; 4751 4752 /** 4753 * The name given to the "origin" remote. 4754 * 4755 * The default is "origin". 4756 */ 4757 public string? remote_name; 4758 /** 4759 * The URL to be used for pushing. 4760 * 4761 * If unset, the fetch URL will be used. 4762 */ 4763 public string? pushurl; 4764 /** 4765 * The fetch specification to be used for fetching. 4766 * 4767 * If unset, "+refs/heads/ *:refs/remotes/<remote_name>/ *" 4768 */ 4769 public string? fetch_spec; 4770 /** 4771 * The fetch specification to be used for pushing. 4772 * 4773 * If unset, the same spec as for fetching. 4774 */ 4775 public string? push_spec; 4776 /** 4777 * Callback to be used if credentials are required during the initial 4778 * fetch. 4779 */ 4780 [CCode(cname = "git_cred_acquire_cb", delegate_target_cname = "cred_acquire_payload")] 4781 public unowned CredAcquire cred_acquire; 4782 /** 4783 * A custom transport to be used for the initial fetch. 4784 * 4785 * If unset, the transport autodetected from the URL. 4786 */ 4787 public unowned transport? transport; 4788 /** 4789 * May be used to specify custom progress callbacks for the origin remote 4790 * before the fetch is initiated. 4791 */ 4792 public unowned remote_callbacks? remote_callbacks; 4793 /** 4794 * May be used to specify the autotag setting before the initial fetch. 4795 */ 4796 AutoTag remote_autotag; 4797 /** 4798 * Gives the name of the branch to checkout. 4799 * 4800 * If unset, use the remote's HEAD. 4801 */ 4802 public string? checkout_branch; 4803 } 4804 4805 [CCode(cname = "git_cvar_map", has_type_id = false)] 4806 public struct config_var_map { 4807 public ConfigVar cvar_type; 4808 public string? str_match; 4809 public int map_value; 4810 } 4811 [CCode(cname = "git_cred")] 4812 public struct cred { 4813 public CredTypes credtype; 4814 public CredFree free; 4815 4816 /** 4817 * Creates a new plain-text username and password credential object. 4818 * 4819 * @param username The username of the credential. 4820 * @param password The password of the credential. 4821 */ 4822 [CCode(cname = "git_cred_userpass_plaintext_new")] 4823 public static Error create_userpass_plaintext(out cred? cred, string username, string password); 4824 } 4825 [CCode(cname = "git_cred_userpass_payload", has_type_id = false)] 4826 public struct cred_userpass { 4827 public string username; 4828 public string password; 4829 /** 4830 * Method usable as {@link CredAcquire}. 4831 * 4832 * This calls {@link cred.create_userpass_plaintext} unless the protocol 4833 * has not specified {@link CredTypes.USERPASS_PLAINTEXT} as an allowed 4834 * type. 4835 * 4836 * @param cred The newly created credential object. 4837 * @param url The resource for which we are demanding a credential. 4838 * @param username_from_url The username that was embedded in a "user@host" 4839 * remote url, or null if not included. 4840 */ 4841 [CCode(cname = "git_cred_userpass", instance_pos = -1)] 4842 public Error acquire(out cred? cred, string url, string? username_from_url, CredTypes allowed_types); 4843 } 4844 4845 /** 4846 * Description of changes to one entry. 4847 * 4848 * When iterating over a diff list object, this will be passed to most 4849 * callback functions and you can use the contents to understand exactly what 4850 * has changed. 4851 * 4852 * The {@link diff_delta.old_file} repesents the "from" side of the diff and 4853 * the {@link diff_delta.new_file} repesents to "to" side of the diff. What 4854 * those means depend on the function that was used to generate the diff and 4855 * will be documented below. You can also use the {@link DiffFlags.REVERSE} 4856 * flag to flip it around. 4857 * 4858 * Although the two sides of the delta are named "old_file" and "new_file", 4859 * they actually may correspond to entries that represent a file, a symbolic 4860 * link, a submodule commit id, or even a tree (if you are tracking type 4861 * changes or ignored/untracked directories). 4862 * 4863 * Under some circumstances, in the name of efficiency, not all fields will 4864 * be filled in, but we generally try to fill in as much as possible. 4865 */ 4866 [CCode(cname = "git_diff_delta", has_type_id = false)] 4867 public struct diff_delta { 4868 public diff_file old_file; 4869 public diff_file new_file; 4870 public DeltaType status; 4871 /** 4872 * For RENAMED and COPIED, value 0-100 4873 */ 4874 public uint similarity; 4875 public DiffFlag flags; 4876 } 4877 4878 /** 4879 * Description of one side of a diff. 4880 * Although this is called a "file", it may actually represent a file, a 4881 * symbolic link, a submodule commit id, or even a tree (although that only 4882 * if you are tracking type changes or ignored/untracked directories). 4883 * 4884 4885 */ 4886 [CCode(cname = "git_diff_file", has_type_id = false)] 4887 public struct diff_file { 4888 /** 4889 * The object id. 4890 * 4891 * If the entry represents an absent side of a diff (e.g., the {@link diff_delta.old_file} 4892 * of a {@link DeltaType.ADDED} delta), then the oid will be zeroes. 4893 */ 4894 [CCode(cname = "oid")] 4895 public object_id id; 4896 /** 4897 * The path to the entry relative to the working directory of the 4898 * repository. 4899 */ 4900 public string path; 4901 public FileMode mode; 4902 /** 4903 * The size of the entry in bytes. 4904 */ 4905 public int size; 4906 public DiffFlag flags; 4907 } 4908 4909 /** 4910 * Structure describing options about how the diff should be executed. 4911 * 4912 * Setting all values of the structure to zero will yield the default 4913 * values. Similarly, passing NULL for the options structure will 4914 * give the defaults. The default values are marked below. 4915 * 4916 * Most of the parameters here are not actually supported at this time. 4917 */ 4918 [CCode(cname = "git_diff_options", has_type_id = false, default_value = "GIT_DIFF_OPTIONS_INIT")] 4919 public struct diff_options { 4920 [CCode(cname = "GIT_DIFF_OPTIONS_VERSION")] 4921 public const uint VERSION; 4922 /** 4923 * Version for the struct 4924 */ 4925 public uint version; 4926 public DiffFlags flags; 4927 /** 4928 * Number of lines of context to show around diffs 4929 */ 4930 public uint16 context_lines; 4931 /** 4932 * Min lines between diff hunks to merge them 4933 */ 4934 public uint16 interhunk_lines; 4935 /** 4936 * "Directory" to prefix to old file names (default "a") 4937 */ 4938 public string? old_prefix; 4939 /** 4940 * "Directory" to prefix to new file names (default "b") 4941 */ 4942 public string? new_prefix; 4943 /** 4944 * Array of paths / patterns to constrain diff 4945 * 4946 * Defaults to all paths 4947 */ 4948 public string_array pathspec; 4949 /** 4950 * Maximum blob size to diff, above this treated as binary 4951 * 4952 * Defaults to 512 MB. 4953 */ 4954 public uint64 max_size; 4955 } 4956 4957 /** 4958 * Structure describing a hunk of a diff. 4959 */ 4960 [CCode(cname = "git_diff_range", has_type_id = false)] 4961 public struct diff_range { 4962 public int old_start; 4963 public int old_lines; 4964 public int new_start; 4965 public int new_lines; 4966 } 4967 4968 [CCode(cname = "git_diff_find_options", has_type_id = false, default_value = "GIT_DIFF_FIND_OPTIONS_INIT ")] 4969 public struct find_options { 4970 [CCode(cname = "GIT_DIFF_FIND_OPTIONS_VERSION")] 4971 public const uint VERSION; 4972 public uint version; 4973 public DiffFind flags; 4974 /** 4975 * Similarity to consider a file renamed (default 50) 4976 */ 4977 public uint rename_threshold; 4978 /** 4979 * Similarity of modified to be eligible rename source (default 50) 4980 */ 4981 public uint rename_from_rewrite_threshold; 4982 /** 4983 * Similarity to consider a file a copy (default 50) 4984 */ 4985 public uint copy_threshold; 4986 /** 4987 * Similarity to split modify into delete/add pair (default 60) 4988 */ 4989 public uint break_rewrite_threshold; 4990 /** 4991 * Maximum similarity sources to examine (e.g., diff's '''-l''' option or 4992 * the '''diff.renameLimit''' config) (default 200) 4993 */ 4994 public uint target_limit; 4995 } 4996 4997 /** 4998 * Time used in a index entry 4999 */ 5000 [CCode(cname = "git_index_time", has_type_id = false)] 5001 public struct index_time { 5002 public int64 seconds; 5003 public uint nanoseconds; 5004 } 5005 5006 /** 5007 * A resolve undo entry in the index. 5008 */ 5009 [CCode(cname = "git_index_reuc_entry", has_type_id = false)] 5010 public struct index_reuc_entry { 5011 uint mode[3]; 5012 [CCode(cname = "oid")] 5013 public object_id id[3]; 5014 public string path; 5015 } 5016 5017 /** 5018 * Extended options structure for {@link Repository.init_ext}. 5019 * 5020 * This contains extra options that enable additional initialization 5021 * features. 5022 */ 5023 [CCode(cname = "git_repository_init_options", has_type_id = false, default_value = "GIT_REPOSITORY_INIT_OPTIONS_INIT")] 5024 public struct init_options { 5025 /** 5026 * Use permissions configured by umask - the default. 5027 */ 5028 [CCode(cname = "GIT_REPOSITORY_INIT_SHARED_UMASK")] 5029 public const uint32 MODE_SHARED_UMASK; 5030 /** 5031 * Use '''--shared=group''' behavior, chmod'ing the new repo to be group 5032 * writable and "g+sx" for sticky group assignment. 5033 */ 5034 [CCode(cname = "GIT_REPOSITORY_INIT_SHARED_GROUP")] 5035 public const uint32 MODE_SHARED_GROUP; 5036 /** 5037 * Use '''--shared=all''' behavior, adding world readability. 5038 */ 5039 [CCode(cname = "GIT_REPOSITORY_INIT_SHARED_ALL")] 5040 public const uint32 MODE_SHARED_ALL; 5041 [CCode(cname = "GIT_REPOSITORY_INIT_OPTIONS_VERSION")] 5042 public const uint VERSION; 5043 public uint version; 5044 public InitFlag flags; 5045 /** 5046 * The UNIX file mode. 5047 * 5048 * The standard values are {@link MODE_SHARED_UMASK}, 5049 * {@link MODE_SHARED_GROUP}, or {@link MODE_SHARED_ALL}, but a custom 5050 * value may be used instead. 5051 */ 5052 public uint32 mode; 5053 /** 5054 * The path to the working dir or null for default (i.e., the repoistory 5055 * path's parent on non-bare repos). 5056 * 5057 * If this is relative path, it will be evaluated relative to the 5058 * repository path. 5059 * 5060 * If this is not the natural working directory, a .git gitlink file will 5061 * be created here linking to the repoitory path. 5062 */ 5063 public string? workdir_path; 5064 /** 5065 * If set, this will be used to initialize the '''description''' file in 5066 * the repository, instead of using the template content. 5067 */ 5068 public string? description; 5069 /** 5070 * When {@link InitFlag.EXTERNAL_TEMPLATE} is set, this contains the path 5071 * to use for the template directory. 5072 * 5073 * If this is null, the config or default directory options will be used 5074 * instead. 5075 */ 5076 public string? template_path; 5077 /** 5078 * The name of the head to point HEAD at. If null, then this will be 5079 * treated as '''master''' and the HEAD ref will be set to 5080 * '''refs/heads/master'''. If this begins with '''refs/''' it will be 5081 * used verbatim; otherwise '''refs/heads/''' will be prefixed. 5082 */ 5083 public string? initial_head; 5084 /** 5085 * If this is non-null, then after the rest of the repository 5086 * initialization is completed, an '''origin''' remote will be added 5087 * pointing to this URL. 5088 */ 5089 public string? origin_url; 5090 } 5091 5092 /** 5093 * Unique identity of any object (commit, tree, blob, tag). 5094 */ 5095 [CCode(cname = "git_oid", has_type_id = false)] 5096 public struct object_id { 5097 /** 5098 * Raw binary formatted id 5099 */ 5100 uint8 id[20]; 5101 5102 [CCode(cname = "GIT_OID_HEX_ZERO")] 5103 public const string HEX_ZERO; 5104 5105 /** 5106 * Size (in bytes) of a raw/binary id 5107 */ 5108 [CCode(cname = "GIT_OID_RAWSZ")] 5109 public const int RAW_SIZE; 5110 5111 /** 5112 * Size (in bytes) of a hex formatted id 5113 */ 5114 [CCode(cname = "GIT_OID_HEXSZ")] 5115 public const int HEX_SIZE; 5116 5117 /** 5118 * Minimum length (in number of hex characters, 5119 * (i.e., packets of 4 bits) of an id prefix 5120 */ 5121 [CCode(cname = "GIT_OID_MINPREFIXLEN")] 5122 public const int MIN_PREFIX_LENGTH; 5123 5124 /** 5125 * Parse a hex formatted null-terminated string. 5126 * 5127 * @param id id structure the result is written into. 5128 * @param str input hex string; must be at least 4 characters long. 5129 */ 5130 [CCode(cname = "git_oid_fromstrp")] 5131 public static Error from_string(out object_id id, string str); 5132 5133 /** 5134 * Parse a hex formatted object id 5135 * 5136 * @param id id structure the result is written into. 5137 * @param str input hex string; must be pointing at the start of the hex 5138 * sequence and have at least the number of bytes needed for an id encoded 5139 * in hex (40 bytes). 5140 * @return {@link Error.OK} if valid, {@link Error.NOTID} on failure. 5141 */ 5142 [CCode(cname = "git_oid_fromstr")] 5143 public static Error from_string_exact(out object_id id, string str); 5144 5145 /** 5146 * Parse N characters of a hex formatted object id 5147 * 5148 * If N is odd, N-1 characters will be parsed instead. 5149 * The remaining space in the git_oid will be set to zero. 5150 * 5151 * @param id id structure the result is written into. 5152 * @param data input hex string 5153 * @return {@link Error.OK} if valid. 5154 */ 5155 [CCode(cname = "git_oid_fromstrn")] 5156 public static Error from_array(out object_id id, [CCode(array_length_type = "size_t")] uint8[] data); 5157 5158 /** 5159 * Copy an already raw id 5160 */ 5161 [CCode(cname = "git_oid_fromraw")] 5162 public static void from_raw(out object_id id, [CCode(array_length = false)] uint8[] raw); 5163 5164 /** 5165 * Format an id into a hex string. 5166 * 5167 * @param str output hex string; must be pointing at the start of the hex 5168 * sequence and have at least the number of bytes needed for an id encoded 5169 * in hex (40 bytes). Only the id digits are written; a nul terminator must 5170 * be added by the caller if it is required. 5171 */ 5172 [CCode(cname = "git_oid_fmt", instance_pos = -1)] 5173 public void to_buffer([CCode(array_length = false)] char[] str); 5174 5175 /** 5176 * Format an id into a loose-object path string. 5177 * 5178 * The resulting string is "aa/...", where "aa" is the first two 5179 * hex digitis of the id and "..." is the remaining 38 digits. 5180 * 5181 * @param str output hex string; must be pointing at the start of the hex 5182 * sequence and have at least the number of bytes needed for an oid encoded 5183 * in hex (41 bytes). Only the id digits are written; a nul terminator 5184 * must be added by the caller if it is required. 5185 */ 5186 [CCode(cname = "git_oid_pathfmt", instance_pos = -1)] 5187 public void to_path([CCode(array_length = false)] char[] str); 5188 5189 /** 5190 * Format an id into a string. 5191 * 5192 * @return the string; null if memory is exhausted. 5193 */ 5194 [CCode(cname = "git_oid_allocfmt")] 5195 public string? to_string(); 5196 5197 /** 5198 * Format an id into a buffer as a hex format string. 5199 * 5200 * If the buffer is smaller than {@link HEX_SIZE}+1, then the resulting 5201 * id string will be truncated to data.length-1 characters. If there are 5202 * any input parameter errors, then a pointer to an empty string is returned, 5203 * so that the return value can always be printed. 5204 * 5205 * @param buffer the buffer into which the id string is output. 5206 * @return the out buffer pointer, assuming no input parameter errors, 5207 * otherwise a pointer to an empty string. 5208 */ 5209 [CCode(cname = "git_oid_tostr", instance_pos = -1)] 5210 public unowned string to_string_buffer([CCode(array_length_type = "size_t")] char[] buffer); 5211 5212 /** 5213 * Copy an id from one structure to another. 5214 * 5215 * @param dest id structure the result is written into. 5216 * @param src id structure to copy from. 5217 */ 5218 [CCode(cname = "git_oid_cpy")] 5219 public static void copy(out object_id dest, object_id src); 5220 5221 /** 5222 * Copy an id from one structure to another. 5223 * 5224 * @param dest id structure the result is written into. 5225 */ 5226 [CCode(cname = "git_oid_cpy", instance_pos = -1)] 5227 public void copy_to(out object_id dest); 5228 5229 /** 5230 * Compare two id structures. 5231 * 5232 * @param a first id structure. 5233 * @param b second id structure. 5234 * @return <0, 0, >0 if a < b, a == b, a > b. 5235 */ 5236 [CCode(cname = "git_oid_cmp")] 5237 public static int compare(object_id a, object_id b); 5238 5239 /** 5240 * Compare two id structures. 5241 * 5242 * @param b second id structure. 5243 * @return <0, 0, >0 if a < b, a == b, a > b. 5244 */ 5245 [CCode(cname = "git_oid_cmp")] 5246 public int compare_to(object_id b); 5247 5248 /** 5249 * Compare the first //len// hexadecimal characters (packets of 4 bits) 5250 * of two id structures. 5251 * 5252 * @param a first id structure. 5253 * @param b second id structure. 5254 * @param len the number of hex chars to compare 5255 * @return 0 in case of a match 5256 */ 5257 [CCode(cname = "git_oid_ncmp")] 5258 public static int compare_n(object_id a, object_id b, size_t len); 5259 5260 /** 5261 * Compare the first //len// hexadecimal characters (packets of 4 bits) 5262 * of two id structures. 5263 * 5264 * @param b second id structure. 5265 * @param len the number of hex chars to compare 5266 * @return 0 in case of a match 5267 */ 5268 [CCode(cname = "git_oid_ncmp")] 5269 public int compare_n_to(object_id b, size_t len); 5270 5271 /** 5272 * Check if an oid equals an hex formatted object id. 5273 * 5274 * @param str input hex string of an object id. 5275 * @return {@link Error.OK} in case of a match, {@link Error.ERROR} otherwise. 5276 */ 5277 [CCode(cname = "git_oid_streq")] 5278 public Error compare_string(string str); 5279 /** 5280 * Compare two oid structures for equality 5281 * 5282 * @param a first id structure. 5283 * @param b second id structure. 5284 * @return true if equal, false otherwise 5285 */ 5286 [CCode(cname = "git_oid_equal")] 5287 public static bool equal(object_id a, object_id b); 5288 /** 5289 * Compare two oid structures for equality 5290 * 5291 * @param b second id structure. 5292 * @return true if equal, false otherwise 5293 */ 5294 [CCode(cname = "git_oid_equal")] 5295 public bool equal_to(object_id b); 5296 5297 /** 5298 * Determine the id of a buffer containing an object 5299 * 5300 * The resulting id will the itentifier for the data 5301 * buffer as if the data buffer it were to written to the ODB. 5302 * 5303 * @param id the resulting id. 5304 * @param data data to hash 5305 * @param type of the data to hash 5306 */ 5307 [CCode(cname = "git_odb_hash")] 5308 public static Error from_data(out object_id id, [CCode(array_length_type = "size_t")] uint8[] data, ObjectType type); 5309 5310 /** 5311 * Read a file from disk and determine the id 5312 * 5313 * Read the file and compute the id have if it were 5314 * written to the database as an object of the given type. 5315 * Similar functionality to git's //git hash-object// without 5316 * the //-w// flag. 5317 * 5318 * @param id id structure the result is written into. 5319 * @param path file to read and determine object id for 5320 * @param type the type of the object that will be hashed 5321 */ 5322 [CCode(cname = "git_odb_hashfile")] 5323 public static Error hashfile(out object_id id, string path, ObjectType type); 5324 /** 5325 * Check is an oid is all zeros. 5326 */ 5327 [CCode(cname = "git_oid_iszero")] 5328 public bool is_zero(); 5329 5330 } 5331 /** 5332 * Controls the behavior of a {@link Push} object. 5333 */ 5334 [CCode(cname = "git_push_options", has_type_id = false, default_value = "GIT_PUSH_OPTIONS_INIT")] 5335 public struct push_options { 5336 [CCode(cname = "GIT_PUSH_OPTIONS_VERSION")] 5337 public const uint VERSION; 5338 public uint version; 5339 /** 5340 * If the transport being used to push to the remote requires the creation 5341 * of a pack file, this controls the number of worker threads used by the 5342 * packbuilder when creating that pack file to be sent to the remote. 5343 * 5344 * If set to false, the packbuilder will auto-detect the number of threads 5345 * to create. The default value is true. 5346 */ 5347 public bool pb_parallelism; 5348 } 5349 [CCode(cname = "struct git_refdb_backend", default_value = "GIT_ODB_BACKEND_INIT", has_type_id = false)] 5350 public struct refdb_backend { 5351 [CCode(cname = "GIT_ODB_BACKEND_VERSION")] 5352 public const uint VERSION; 5353 public uint version; 5354 public RefDbCompress? compress; 5355 public RefDbDelete @delete; 5356 public RefDbExists exists; 5357 public RefDbForEach @foreach; 5358 public RefDbForEachGlob? foreach_glob; 5359 public RefDbFree? free; 5360 public RefDbLookup lookup; 5361 public RefDbWrite write; 5362 /** 5363 * Constructors for default refdb backend. 5364 */ 5365 [CCode(cname = "git_refdb_backend_fs")] 5366 public static Error create_backend_fs(out refdb_backend? backend, Repository repo, RefDb refdb); 5367 } 5368 /** 5369 * Reference specification (i.e., some kind of local or remote branch) 5370 */ 5371 [CCode(cname = "git_refspec", has_type_id = false, destroy_function = "")] 5372 public struct ref_spec { 5373 /** 5374 * The destination specifier 5375 */ 5376 public string destination { 5377 [CCode(cname = "git_refspec_dst")] 5378 get; 5379 } 5380 /** 5381 * The force update setting 5382 */ 5383 public bool is_forced { 5384 [CCode(cname = "git_refspec_force")] 5385 get; 5386 } 5387 5388 /** 5389 * The source specifier 5390 */ 5391 public string source { 5392 [CCode(cname = "git_refspec_src")] 5393 get; 5394 } 5395 5396 /** 5397 * Check if a refspec's source descriptor matches a reference name 5398 * 5399 * @param refname the name of the reference to check 5400 */ 5401 [CCode(cname = "git_refspec_src_matches")] 5402 public bool matches_source(string refname); 5403 5404 /** 5405 * Check if a refspec's destination descriptor matches a reference 5406 * 5407 * @param refname the name of the reference to check 5408 */ 5409 [CCode(cname = "git_refspec_dst_matches")] 5410 public bool matches_destination(string refname); 5411 5412 /** 5413 * Transform a target reference to its source reference following the refspec's rules 5414 * 5415 * @param refname where to store the source reference name 5416 * @param name the name of the reference to transform 5417 */ 5418 [CCode(cname = "git_refspec_rtransform", instance_pos = 1.2)] 5419 public Error rtransform([CCode(array_length_type = "size_t")] uint8[] refname, string name); 5420 5421 /** 5422 * Transform a reference to its target following the refspec's rules 5423 * 5424 * @param buffer where to store the target name 5425 * @param name the name of the reference to transform 5426 * @return {@link Error.OK}, {@link Error.SHORTBUFFER} or another error 5427 */ 5428 [CCode(cname = "git_refspec_transform", instance_pos = 1.3)] 5429 public Error transform([CCode(array_length_type = "size_t")] char[] buffer, string name); 5430 } 5431 5432 5433 /** 5434 * Remote head description, given out on //ls// calls. 5435 */ 5436 [CCode(cname = "struct git_remote_head", has_type_id = false)] 5437 public struct remote_head { 5438 public bool local; 5439 [CCode(cname = "oid")] 5440 public object_id id; 5441 [CCode(cname = "loid")] 5442 public object_id l_id; 5443 public unowned string name; 5444 } 5445 5446 [CCode(cname = "git_remote_callbacks", simple_generics = true, default_value = "GIT_REMOTE_CALLBACKS_INIT ")] 5447 public struct remote_callbacks<T> { 5448 [CCode(cname = "GIT_REMOTE_CALLBACKS_VERSION")] 5449 public const uint VERSION; 5450 5451 public uint version; 5452 public RemoteProgress<T>? progress; 5453 public RemoteCompletion<T>? completion; 5454 public RemoteUpdateTips<T>? update_tips; 5455 5456 [CCode(simple_generics = true)] 5457 public T payload; 5458 } 5459 /** 5460 * The smart transport knows how to speak the git protocol, but it has no 5461 * knowledge of how to establish a connection between it and another 5462 * endpoint, or how to move data back and forth. 5463 * 5464 * For this, a subtransport interface is declared, and the smart transport 5465 * delegates this work to the subtransports. Three subtransports are 5466 * implemented: git, http, and winhttp. (The http and winhttp transports each 5467 * implement both http and https.) 5468 * 5469 * Subtransports can either be persistent or stateless (request/response). 5470 * The smart transport handles the differences in its own logic. 5471 */ 5472 [CCode(cname = "git_smart_subtransport")] 5473 public struct smart_subtransport { 5474 public SubTransportAction action; 5475 5476 /** 5477 * Subtransports are guaranteed a call to {@link close} between calls to 5478 * {@link action}, except for the following two natural progressions of 5479 * actions against a constant URL. 5480 * 5481 * 1. {@link SmartService.UPLOADPACK_LS} → {@link SmartService.UPLOADPACK} 5482 * 2. {@link SmartService.RECEIVEPACK_LS} → {@link SmartService.RECEIVEPACK} 5483 */ 5484 public SubTransportClose close; 5485 public SubTransportFree free; 5486 } 5487 [CCode(cname = "git_smart_subtransport_definition")] 5488 public struct smart_subtransport_definition { 5489 /** 5490 * Create an instance of the smart transport. 5491 * 5492 * @param owner The {@link Remote} which will own this transport 5493 */ 5494 [CCode(cname = "git_transport_smart", instance_pos = -1)] 5495 public Error create_transport(out transport? transport, Remote owner); 5496 5497 /** 5498 * The function to use to create the subtransport 5499 */ 5500 public CreateSubTransport callback; 5501 5502 /** 5503 * Is the protocol is stateless. 5504 * 5505 * For example, http:// is stateless, but git:// is not. 5506 */ 5507 [CCode(cname = "rpc")] 5508 public bool rpc; 5509 } 5510 /** 5511 * A stream used by the smart transport to read and write data from a 5512 * subtransport 5513 */ 5514 [CCode(cname = "git_smart_subtransport_stream")] 5515 public struct smart_subtransport_stream { 5516 /** 5517 * The owning subtransport 5518 */ 5519 public unowned smart_subtransport? subtransport; 5520 public SubTransportStreamRead read; 5521 public SubTransportStreamWrite write; 5522 public SubTransportStreamFree free; 5523 } 5524 [CCode(cname = "git_status_options", has_type_id = false, default_value = "GIT_STATUS_OPTIONS_INIT")] 5525 public struct status_options { 5526 [CCode(cname = "GIT_STATUS_OPTIONS_VERSION")] 5527 public const uint VERSION; 5528 5529 public uint version; 5530 StatusShow show; 5531 StatusControl flags; 5532 /** 5533 * The path patterns to match (using fnmatch-style matching), or just an 5534 * array of paths to match exactly if {@link DiffFlags.DISABLE_PATHSPEC_MATCH} 5535 * is specified in the flags. 5536 */ 5537 string_array pathspec; 5538 } 5539 5540 /** 5541 * Collection of strings 5542 */ 5543 [CCode(cname = "git_strarray", destroy_function = "git_strarray_free", has_type_id = false)] 5544 public struct string_array { 5545 [CCode(array_length_cname = "count", array_length_type = "size_t")] 5546 string[]? strings; 5547 [CCode(cname = "git_strarray_copy", instance_pos = -1)] 5548 public Error copy(out string_array target); 5549 } 5550 5551 /** 5552 * Time in a signature 5553 */ 5554 [CCode(cname = "git_time", has_type_id = false)] 5555 public struct time { 5556 /** 5557 * time in seconds from epoch 5558 */ 5559 int64 time; 5560 /** 5561 * timezone offset, in minutes 5562 */ 5563 int offset; 5564 } 5565 [CCode(cname = "git_transfer_progress", has_type_id = false)] 5566 public struct transfer_progress { 5567 public uint total_objects; 5568 public uint indexed_objects; 5569 public uint received_objects; 5570 public size_t received_bytes; 5571 } 5572 [CCode(cname = "git_transport", has_type_id = false, default_value = "GIT_TRANSPORT_INIT ")] 5573 public struct transport { 5574 [CCode(cname = "GIT_TRANSPORT_VERSION")] 5575 public const uint VERSION; 5576 public uint version; 5577 /** 5578 * Set progress and error callbacks 5579 */ 5580 public TransportSetCallbacks set_callbacks; 5581 /** 5582 * Connect the transport to the remote repository, using the given 5583 * direction. 5584 */ 5585 public TransportConnect connect; 5586 /** 5587 * This function may be called after a successful call to {@link connect}. 5588 * 5589 * The provided callback is invoked for each ref discovered on the remote 5590 * end. 5591 */ 5592 public TransportList ls; 5593 /** 5594 * Executes the push whose context is in a {@link Push} object. 5595 */ 5596 public TransportPush push; 5597 /** 5598 * The function performs a negotiation to calculate the wants list for the 5599 * fetch. 5600 * 5601 * This function may be called after a successful call to {@link connect}, 5602 * when the direction is FETCH. 5603 */ 5604 public TransportNegotiatFetch negotiate_fetch; 5605 /** 5606 * This function retrieves the pack file for the fetch from the remote end. 5607 * 5608 * This function may be called after a successful call to 5609 * {@link negotiate_fetch}, when the direction is FETCH. 5610 */ 5611 public TransportDownloadPack download_pack; 5612 /** 5613 * Checks to see if the transport is connected 5614 */ 5615 public TransportIsConnected is_connected; 5616 /** 5617 * Reads the flags value previously passed into {@link connect} 5618 */ 5619 public TransportReadFlags read_flags; 5620 /** 5621 * Cancels any outstanding transport operation 5622 */ 5623 public TransportCancel cancel; 5624 /** 5625 * This function is the reverse of {@link connect} – it terminates the 5626 * connection to the remote end. 5627 */ 5628 public TransportClose close; 5629 /** 5630 * Frees/destructs the transport object. 5631 */ 5632 public TransportFree free; 5633 5634 /** 5635 * Function to use to create a transport from a URL. 5636 * 5637 * The transport database is scanned to find a transport that implements 5638 * the scheme of the URI (e.g., git:// or http://) and a transport object 5639 * is returned to the caller. 5640 * 5641 * @param owner The {@link Remote} which will own this transport 5642 * @param url The URL to connect to 5643 */ 5644 [CCode(cname = "git_transport_new")] 5645 public static Error create(out transport? transport, Remote owner, string url); 5646 5647 /** 5648 * Create an instance of the dummy transport. 5649 * 5650 * @param owner The {@link Remote} which will own this transport 5651 * @param payload You must pass null for this parameter. 5652 */ 5653 [CCode(cname = "git_transport_dummy")] 5654 public static Error create_dummy(out transport? transport, Remote owner, void* payload = null); 5655 /** 5656 * Create an instance of the local transport. 5657 * 5658 * @param owner The {@link Remote} which will own this transport 5659 * @param payload You must pass null for this parameter. 5660 */ 5661 [CCode(cname = "git_transport_local")] 5662 public static Error create_local(out transport? transport, Remote owner, void* payload = null); 5663 5664 /** 5665 * Create an instance of the http subtransport. 5666 * 5667 * This subtransport also supports https. On Win32, this subtransport may 5668 * be implemented using the WinHTTP library. 5669 */ 5670 [CCode(cname = "git_smart_subtransport_http", instance_pos = -1)] 5671 public Error create_http_subtransport(out smart_subtransport? subtransport); 5672 5673 /** 5674 * Create an instance of the git subtransport. 5675 */ 5676 [CCode(cname = "git_smart_subtransport_git", instance_pos = -1)] 5677 public Error create_git_subtransport(out smart_subtransport? subtransport); 5678 } 5679 5680 /** 5681 * Default port for git: protocol. 5682 */ 5683 [CCode(cname = "GIT_DEFAULT_PORT")] 5684 public const string DEFAULT_PORT; 5685 5686 /** 5687 * The separator used in path list strings. 5688 * 5689 * For instance, in the //$PATH// environment variable). A semi-colon ";" 5690 * is used on Windows, and a colon ":" for all other systems. 5691 */ 5692 [CCode(cname = "GIT_PATH_LIST_SEPARATOR")] 5693 public const char PATH_LIST_SEPARATOR; 5694 5695 /** 5696 * The maximum length of a git valid git path. 5697 */ 5698 [CCode(cname = "GIT_PATH_MAX")] 5699 public const int PATH_MAX; 5700 5701 [CCode(cname = "uint32_t", cprefix = "GIT_ATTR_CHECK_", has_type_id = false)] 5702 [Flags] 5703 public enum AttrCheck { 5704 /** 5705 * Reading values from index and working directory. 5706 * 5707 * When checking attributes, it is possible to check attribute files 5708 * in both the working directory (if there is one) and the index (if 5709 * there is one). You can explicitly choose where to check and in 5710 * which order using the following flags. 5711 * 5712 * Core git usually checks the working directory then the index, 5713 * except during a checkout when it checks the index first. It will 5714 * use index only for creating archives or for a bare repo (if an 5715 * index has been specified for the bare repo). 5716 */ 5717 FILE_THEN_INDEX, 5718 /** 5719 * @see FILE_THEN_INDEX 5720 */ 5721 INDEX_THEN_FILE, 5722 /** 5723 * @see FILE_THEN_INDEX 5724 */ 5725 INDEX_ONLY, 5726 /** 5727 * Using the system attributes file. 5728 * 5729 * Normally, attribute checks include looking in the /etc (or system 5730 * equivalent) directory for a `gitattributes` file. Passing this 5731 * flag will cause attribute checks to ignore that file. 5732 */ 5733 NO_SYSTEM 5734 } 5735 5736 /** 5737 * States for a file in the index 5738 */ 5739 [CCode(cname = "int", cprefix = "GIT_IDXENTRY_", has_type_id = false)] 5740 [Flags] 5741 public enum Attributes { 5742 EXTENDED, 5743 VALID, 5744 UPDATE, 5745 REMOVE, 5746 UPTODATE, 5747 ADDED, 5748 HASHED, 5749 UNHASHED, 5750 WT_REMOVE, 5751 CONFLICTED, 5752 UNPACKED, 5753 NEW_SKIP_WORKTREE, 5754 INTENT_TO_ADD, 5755 SKIP_WORKTREE, 5756 EXTENDED2, 5757 EXTENDED_FLAGS 5758 } 5759 [CCode(cname = "git_remote_autotag_option_t", cprefix = "GIT_REMOTE_DOWNLOAD_TAGS_", has_type_id = false)] 5760 public enum AutoTag { 5761 UNSET, 5762 NONE, 5763 AUTO, 5764 ALL 5765 } 5766 5767 /** 5768 * Basic type of any Git branch. 5769 */ 5770 [CCode(cname = "git_branch_t", cprefix = "GIT_BRANCH_", has_type_id = false)] 5771 [Flags] 5772 public enum BranchType { 5773 LOCAL, 5774 REMOTE 5775 } 5776 /** 5777 * Combinations of these values describe the capabilities of libgit2. 5778 */ 5779 [CCode(cname = "int", cprefix = "GIT_CAP_", has_type_id = false)] 5780 public enum Capabilities { 5781 /** 5782 * Libgit2 was compiled with thread support. 5783 * 5784 * Note that thread support is still to be seen as a 'work in progress'. 5785 */ 5786 THREADS, 5787 /** 5788 * Libgit2 supports the https protocol. 5789 * 5790 * This requires the OpenSSL library to be found when compiling libgit2. 5791 */ 5792 HTTPS; 5793 /** 5794 * Query compile time options for libgit2. 5795 */ 5796 [CCode(cname = "git_libgit2_capabilities")] 5797 public static Capabilities get(); 5798 } 5799 /** 5800 * Options for which cases to invoke notification callback. 5801 */ 5802 [CCode(cname = "git_checkout_notify_t", has_type_id = false, cprefix = "GIT_CHECKOUT_NOTIFY_")] 5803 [Flags] 5804 public enum CheckoutNotify { 5805 NONE, 5806 /** 5807 * Invokes callback on conflicting paths. 5808 */ 5809 CONFLICT, 5810 /** 5811 * Invokes callback to notify about "dirty" files, i.e. those that do not 5812 * need an update but no longer match the baseline. Core git displays 5813 * these files when checkout runs, but won't stop the checkout. 5814 */ 5815 DIRTY, 5816 /** 5817 * Invokes callback to notify for any changed file. 5818 */ 5819 UPDATED, 5820 /** 5821 * Invokes callback to notify about untracked files. 5822 */ 5823 UNTRACKED, 5824 /** 5825 * Invokes callback to notify about ignored files. 5826 */ 5827 IGNORED 5828 } 5829 5830 /** 5831 * Control what checkout does with files 5832 * 5833 * No flags does a "dry run" where no files will be modified. 5834 * 5835 * Checkout groups the working directory content into 3 classes of files: (1) 5836 * files that don't need a change, and files that do need a change that 5837 * either (2) we are allowed to modifed or (3) we are not. The flags you 5838 * pass in will decide which files we are allowed to modify. 5839 * 5840 * By default, checkout is not allowed to modify any files. Anything needing 5841 * a change would be considered a conflict. 5842 * 5843 * If any files need update but are disallowed by the strategy, normally 5844 * checkout calls the conflict callback (if given) and then aborts. 5845 * 5846 * Any unmerged entries in the index are automatically considered conflicts. 5847 */ 5848 [CCode(cname = "git_checkout_strategy_t", has_type_id = false, cprefix = "GIT_CHECKOUT_")] 5849 [Flags] 5850 public enum CheckoutStategy { 5851 /** 5852 * Dry run, no actual updates 5853 */ 5854 NONE, 5855 /** 5856 * Allow safe updates that cannot overwrite uncommited data 5857 */ 5858 SAFE, 5859 /** 5860 * Allow safe updates plus creation of missing files 5861 */ 5862 SAFE_CREATE, 5863 /** 5864 * Allow all updates to force working directory to look like index 5865 */ 5866 FORCE, 5867 /** 5868 * Allow checkout to make safe updates even if conflicts are found 5869 * 5870 * It is okay to update the files that are allowed by the strategy even if 5871 * there are conflicts. The conflict callbacks are still made, but 5872 * non-conflicting files will be updated. 5873 */ 5874 ALLOW_CONFLICTS, 5875 /** 5876 * Remove untracked files not in index (that are not ignored) 5877 */ 5878 REMOVE_UNTRACKED, 5879 /** 5880 * Remove ignored files not in index 5881 */ 5882 REMOVE_IGNORED, 5883 /** 5884 * Only update existing files, don't create new ones 5885 */ 5886 UPDATE_ONLY, 5887 /** 5888 * Normally checkout updates index entries as it goes; this stops that 5889 */ 5890 DONT_UPDATE_INDEX, 5891 /** 5892 * Don't refresh index/config/etc before doing checkout 5893 */ 5894 NO_REFRESH, 5895 /** 5896 * Treat pathspec as simple list of exact match file paths 5897 */ 5898 DISABLE_PATHSPEC_MATCH, 5899 /** 5900 * Allow checkout to skip unmerged files (NOT IMPLEMENTED) 5901 */ 5902 SKIP_UNMERGED, 5903 USE_OURS, 5904 /** 5905 * For unmerged files, checkout stage 3 from index (NOT IMPLEMENTED) 5906 */ 5907 USE_THEIRS, 5908 /** 5909 * Recursively checkout submodules with same options (NOT IMPLEMENTED) 5910 */ 5911 UPDATE_SUBMODULES, 5912 /** 5913 * Recursively checkout submodules if HEAD moved in super repo (NOT IMPLEMENTED) 5914 */ 5915 UPDATE_SUBMODULES_IF_CHANGED 5916 } 5917 5918 /** 5919 * Priority level of a config file. 5920 * 5921 * These priority levels correspond to the natural escalation logic (from 5922 * higher to lower) when searching for config entries in git.git. 5923 */ 5924 [CCode(cname = "int", cprefix = "GIT_CONFIG_LEVEL_", has_type_id = false)] 5925 public enum ConfigLevel { 5926 /** 5927 * System-wide configuration file. 5928 */ 5929 SYSTEM, 5930 /** 5931 * XDG compatible configuration file: '''.config/git/config''' 5932 */ 5933 XDG, 5934 /** 5935 * User-specific configuration file, also called global configuration file. 5936 */ 5937 GLOBAL, 5938 /** 5939 * Repository specific configuration file. 5940 */ 5941 LOCAL, 5942 /** 5943 * Represents the highest level of a config file. 5944 */ 5945 LEVEL, 5946 } 5947 5948 [CCode(cname = "git_cvar_t", cprefix = "GIT_CVAR_", has_type_id = false)] 5949 public enum ConfigVar { 5950 FALSE, 5951 TRUE, 5952 INT32, 5953 STRING 5954 } 5955 5956 [CCode(cname = "git_credtype_t", cprefix = "GIT_CREDTYPE_", has_type_id = false)] 5957 [Flags] 5958 public enum CredTypes { 5959 USERPASS_PLAINTEXT 5960 } 5961 5962 /** 5963 * What type of change is described? 5964 */ 5965 [CCode(cname = "git_delta_t", cprefix = "GIT_DELTA_", has_type_id = false)] 5966 public enum DeltaType { 5967 /** 5968 * Use in queries to include all delta types. 5969 */ 5970 [CCode(cname = "(-1)")] 5971 ALL, 5972 /** 5973 * No changes 5974 */ 5975 UNMODIFIED, 5976 /** 5977 * Entry does not exist in old version 5978 */ 5979 ADDED, 5980 /** 5981 * Entry does not exist in new version 5982 */ 5983 DELETED, 5984 /** 5985 * Entry content changed between old and new 5986 */ 5987 MODIFIED, 5988 /** 5989 * Entry was renamed between old and new 5990 */ 5991 RENAMED, 5992 /** 5993 * Entry was copied from another old entry 5994 */ 5995 COPIED, 5996 /** 5997 * Entry is ignored item in workdir 5998 */ 5999 IGNORED, 6000 /** 6001 * Entry is untracked item in workdir 6002 */ 6003 UNTRACKED, 6004 /** 6005 * Type of entry changed between old and new 6006 */ 6007 TYPECHANGE; 6008 /** 6009 * Look up the single character abbreviation for a delta status code. 6010 * 6011 * When you call {@link DiffList.print_compact} it prints single letter 6012 * codes into the output such as 'A' for added, 'D' for deleted, 'M' for 6013 * modified, etc. It is sometimes convenient to convert a {@link DeltaType} 6014 * value into these letters for your own purposes. This function does just 6015 * that. By the way, unmodified will return a space (i.e. ' '). 6016 */ 6017 [CCode(cname = "git_diff_status_char")] 6018 public char to_char(); 6019 } 6020 /** 6021 * Flags that can be set for the file on side of a diff. 6022 */ 6023 [CCode(cname = "uint32", cprefix = "GIT_DIFF_FLAG_", has_type_id = false)] 6024 [Flags] 6025 public enum DiffFlag { 6026 /** 6027 * File(s) treated as binary data 6028 */ 6029 BINARY, 6030 /** 6031 * File(s) treated as text data 6032 */ 6033 NOT_BINARY, 6034 /** 6035 * Id value is known correct 6036 */ 6037 [CCode(cname = "GIT_DIFF_FLAG_VALID_OID")] 6038 VALID_OID 6039 } 6040 /** 6041 * Control the behavior of diff rename/copy detection. 6042 */ 6043 [CCode(cname = "unsigned int", cprefix = "GIT_DIFF_FIND_", has_type_id = false)] 6044 [Flags] 6045 public enum DiffFind { 6046 /** 6047 * Look for renames? 6048 */ 6049 RENAMES, 6050 /** 6051 * Consider old side of modified for renames? 6052 */ 6053 RENAMES_FROM_REWRITES, 6054 /** 6055 * Look for copies? 6056 */ 6057 COPIES, 6058 /** 6059 * Consider unmodified as copy sources? 6060 */ 6061 COPIES_FROM_UNMODIFIED, 6062 /** 6063 * Split large rewrites into delete/add pairs. 6064 */ 6065 AND_BREAK_REWRITES, 6066 /** 6067 * Turn on all finding features 6068 */ 6069 ALL, 6070 /** 6071 * Measure similarity ignoring leading whitespace (default) 6072 */ 6073 IGNORE_LEADING_WHITESPACE, 6074 /** 6075 * Measure similarity ignoring all whitespace 6076 */ 6077 IGNORE_WHITESPACE, 6078 /** 6079 * Measure similarity including all data 6080 */ 6081 DONT_IGNORE_WHITESPACE 6082 } 6083 6084 [CCode(cname = "uint32_t", cprefix = "GIT_DIFF_", has_type_id = false)] 6085 [Flags] 6086 public enum DiffFlags { 6087 /** 6088 * Normal diff, the default 6089 */ 6090 NORMAL, 6091 /** 6092 * Reverse the sides of the diff 6093 */ 6094 REVERSE, 6095 /** 6096 * Treat all files as text, disabling binary attributes & detection 6097 */ 6098 FORCE_TEXT, 6099 /** 6100 * Ignore all whitespace 6101 */ 6102 IGNORE_WHITESPACE, 6103 /** 6104 * Ignore changes in amount of whitespace 6105 */ 6106 IGNORE_WHITESPACE_CHANGE, 6107 /** 6108 * Ignore whitespace at end of line 6109 */ 6110 IGNORE_WHITESPACE_EOL, 6111 /** 6112 * Exclude submodules from the diff completely 6113 */ 6114 IGNORE_SUBMODULES, 6115 /** 6116 * Use the "patience diff" algorithm (currently unimplemented) 6117 */ 6118 PATIENCE, 6119 /** 6120 * Include ignored files in the diff list 6121 */ 6122 INCLUDE_IGNORED, 6123 /** 6124 * Include untracked files in the diff list 6125 */ 6126 INCLUDE_UNTRACKED, 6127 /** 6128 * Include unmodified files in the diff list 6129 */ 6130 INCLUDE_UNMODIFIED, 6131 /** 6132 * Even with the {@link INCLUDE_UNTRACKED} flag, when an untracked 6133 * directory is found, only a single entry for the directory is added to 6134 * the diff list; with this flag, all files under the directory will be 6135 * included, too. 6136 */ 6137 RECURSE_UNTRACKED_DIRS, 6138 /** 6139 * If the pathspec is set in the diff options, this flags means to apply it 6140 * as an exact match instead of as an fnmatch pattern. 6141 */ 6142 DISABLE_PATHSPEC_MATCH, 6143 /** 6144 * Use case insensitive filename comparisons 6145 */ 6146 DELTAS_ARE_ICASE, 6147 /** 6148 * When generating patch text, include the content of untracked files 6149 */ 6150 INCLUDE_UNTRACKED_CONTENT, 6151 /** 6152 * Disable updating of the binary flag in delta records. This is useful 6153 * when iterating over a diff if you don't need hunk and data callbacks and 6154 * want to avoid having to load file completely. 6155 */ 6156 SKIP_BINARY_CHECK, 6157 /** 6158 * Normally, a type change between files will be converted into a DELETED 6159 * record for the old and an ADDED record for the new; this options enabled 6160 * the generation of TYPECHANGE delta records. 6161 */ 6162 INCLUDE_TYPECHANGE, 6163 /** 6164 * Even with {@link INCLUDE_TYPECHANGE}, blob to tree changes still 6165 * generally show as a DELETED blob. This flag tries to correctly label 6166 * blob to tree transitions as TYPECHANGE records with the new file's mode 6167 * set to tree. 6168 * 6169 * Note: the tree SHA will not be available. 6170 */ 6171 INCLUDE_TYPECHANGE_TREES, 6172 /** 6173 * Ignore file mode changes 6174 */ 6175 IGNORE_FILEMODE, 6176 /** 6177 * Even with {@link INCLUDE_IGNORED}, an entire ignored directory will be 6178 * marked with only a single entry in the diff list; this flag adds all 6179 * files under the directory as IGNORED entries, too. 6180 */ 6181 RECURSE_IGNORED_DIRS 6182 } 6183 6184 /** 6185 * Line origin constants. 6186 * 6187 * These values describe where a line came from and will be passed to 6188 * the {@link DiffLine} when iterating over a diff. There are some 6189 * special origin contants at the end that are used for the text 6190 * output callbacks to demarcate lines that are actually part of 6191 * the file or hunk headers. 6192 */ 6193 [CCode(cname = "char", cprefix = "GIT_DIFF_LINE_", has_type_id = false)] 6194 public enum DiffLineType { 6195 CONTEXT, 6196 ADDITION, 6197 DELETION, 6198 [Deprecated] 6199 ADD_EOFNL, 6200 DEL_EOFNL, 6201 FILE_HDR, 6202 HUNK_HDR, 6203 BINARY; 6204 [CCode(cname = "")] 6205 public char to_char(); 6206 } 6207 6208 /** 6209 * Transfer direction in a transport 6210 */ 6211 [CCode(cname = "int", cprefix = "GIT_DIR_", has_type_id = false)] 6212 public enum Direction { 6213 FETCH, PUSH 6214 } 6215 6216 /** 6217 * Return codes for many functions. 6218 */ 6219 [CCode(cname = "git_error_t", cprefix = "GIT_E", has_type_id = false)] 6220 public enum Error { 6221 [CCode(cname = "GIT_OK")] 6222 OK, 6223 [CCode(cname = "GIT_ERROR")] 6224 ERROR, 6225 /** 6226 * Input does not exist in the scope searched 6227 */ 6228 NOTFOUND, 6229 /** 6230 * A reference with this name already exists 6231 */ 6232 EXISTS, 6233 /** 6234 * The given integer literal is too large to be parsed 6235 */ 6236 OVERFLOW, 6237 /** 6238 * The given short {@link object_id} is ambiguous 6239 */ 6240 AMBIGUOUS, 6241 BUFS, 6242 USER, 6243 /** 6244 * Skip and passthrough the given ODB backend 6245 */ 6246 PASSTHROUGH, 6247 /** 6248 * The buffer is too short to satisfy the request 6249 */ 6250 SHORTBUFFER, 6251 /** 6252 * The revsion walk is complete. 6253 */ 6254 ITEROVER, 6255 SSL, 6256 BAREREPO, 6257 ORPHANEDHEAD, 6258 UNMERGED, 6259 NONFASTFORWARD, 6260 INVALIDSPEC, 6261 MERGECONFLICT 6262 } 6263 6264 [CCode(cname = "git_error_class", cprefix = "GITERR_", has_type_id = false)] 6265 public enum ErrClass { 6266 NOMEMORY, 6267 OS, 6268 INVALID, 6269 REFERENCE, 6270 ZLIB, 6271 REPOSITORY, 6272 CONFIG, 6273 REGEX, 6274 ODB, 6275 INDEX, 6276 OBJECT, 6277 NET, 6278 TAG, 6279 TREE, 6280 INDEXER, 6281 SSL, 6282 SUBMODULE, 6283 THREAD, 6284 STASH, 6285 CHECKOUT, 6286 FETCHHEAD, 6287 MERGE; 6288 /** 6289 * Set the error message string for this thread. 6290 * 6291 * This function is public so that custom ODB backends and the like can 6292 * relay an error message through libgit2. Most regular users of libgit2 6293 * will never need to call this function -- actually, calling it in most 6294 * circumstances (for example, calling from within a callback function) 6295 * will just end up having the value overwritten by libgit2 internals. 6296 * 6297 * This error message is stored in thread-local storage and only applies to 6298 * the particular thread that this libgit2 call is made from. 6299 * 6300 * {@link ErrClass.OS} has a special behavior: we attempt to append the 6301 * system default error message for the last OS error that occurred and 6302 * then clear the last error. The specific implementation of looking up 6303 * and clearing this last OS error will vary by platform. 6304 * 6305 * @param message The formatted error message to keep 6306 */ 6307 [CCode(cname = "giterr_set_str")] 6308 void raise(string message); 6309 } 6310 /** 6311 * The UNIX file mode associated with a {@link TreeEntry}. 6312 * 6313 * Consult the mode_t manual page. 6314 */ 6315 [CCode(cname = "unsigned int", cheader_filename = "sys/stat.h", cprefix = "S_I", has_type_id = false)] 6316 [Flags] 6317 public enum FileMode { 6318 /** 6319 * This is the mask to isolate only the F modes. 6320 */ 6321 FMT, 6322 /** 6323 * A block device 6324 */ 6325 FBLK, 6326 /** 6327 * A character device 6328 */ 6329 FCHR, 6330 /** 6331 * A directory 6332 */ 6333 FDIR, 6334 /** 6335 * A FIFO special 6336 */ 6337 FIFO, 6338 /** 6339 * A symbolic link 6340 */ 6341 FLNK, 6342 /** 6343 * A regular file 6344 */ 6345 FREG, 6346 /** 6347 * A socket 6348 */ 6349 FSOCK, 6350 /** 6351 * Read, write, and execute by owner 6352 */ 6353 RWXU, 6354 /** 6355 * Read by owner 6356 */ 6357 RUSR, 6358 /** 6359 * Write by owner 6360 */ 6361 WUSR, 6362 /** 6363 * Execute by owner 6364 */ 6365 XUSR, 6366 /** 6367 * Read, write, and execute by group 6368 */ 6369 RWXG, 6370 /** 6371 * Read by group 6372 */ 6373 RGRP, 6374 /** 6375 * Write by group 6376 */ 6377 WGRP, 6378 /** 6379 * Execute by group 6380 */ 6381 XGRP, 6382 /** 6383 * Read, write, and execute by others 6384 */ 6385 RWXO, 6386 /** 6387 * Read by others 6388 */ 6389 ROTH, 6390 /** 6391 * Write by others 6392 */ 6393 WOTH, 6394 /** 6395 * Execute by others 6396 */ 6397 XOTH, 6398 /** 6399 * Set user-id on execution 6400 */ 6401 SUID, 6402 /** 6403 * Set group-id on execution 6404 */ 6405 SGID, 6406 /** 6407 * Restricted delition on directories 6408 */ 6409 SVTX; 6410 [CCode(cname = "S_ISBLK")] 6411 public bool is_block_dev(); 6412 [CCode(cname = "S_ISCHR")] 6413 public bool is_char_dev(); 6414 [CCode(cname = "S_ISDIR")] 6415 public bool is_dir(); 6416 [CCode(cname = "S_ISFIFO")] 6417 public bool is_fifo(); 6418 [CCode(cname = "S_ISREG")] 6419 public bool is_regular(); 6420 [CCode(cname = "S_ISLNK")] 6421 public bool is_link(); 6422 [CCode(cname = "S_ISSOCK")] 6423 public bool is_sock(); 6424 /** 6425 * Converts the format mode to an ls-style long mode. 6426 */ 6427 public string to_string() { 6428 char attr[11]; 6429 switch (this&FileMode.FMT) { 6430 case FileMode.FBLK : 6431 attr[0] = 'b'; 6432 break; 6433 case FileMode.FCHR : 6434 attr[0] = 'c'; 6435 break; 6436 case FileMode.FDIR : 6437 attr[0] = 'd'; 6438 break; 6439 case FileMode.FIFO : 6440 attr[0] = 'p'; 6441 break; 6442 case FileMode.FLNK : 6443 attr[0] = 'l'; 6444 break; 6445 case FileMode.FREG : 6446 attr[0] = '-'; 6447 break; 6448 case FileMode.FSOCK : 6449 attr[0] = 's'; 6450 break; 6451 default : 6452 attr[0] = '?'; 6453 break; 6454 } 6455 attr[1] = check_mode(FileMode.RUSR, 'r'); 6456 attr[2] = check_mode(FileMode.WUSR, 'w'); 6457 attr[3] = check_mode_x(FileMode.RUSR, FileMode.SUID, 's'); 6458 attr[4] = check_mode(FileMode.RGRP, 'r'); 6459 attr[5] = check_mode(FileMode.WGRP, 'w'); 6460 attr[6] = check_mode_x(FileMode.RGRP, FileMode.SGID, 's'); 6461 attr[7] = check_mode(FileMode.ROTH, 'r'); 6462 attr[8] = check_mode(FileMode.WOTH, 'w'); 6463 attr[9] = check_mode_x(FileMode.ROTH, FileMode.SVTX, 't'); 6464 attr[10] = '\0'; 6465 return ((string) attr).dup(); 6466 } 6467 char check_mode(FileMode mode, char symbol) { 6468 return mode in this ? symbol : '-'; 6469 } 6470 char check_mode_x(FileMode mode, FileMode modifier, char symbol) { 6471 if ((mode|modifier) in this) { 6472 return symbol.tolower(); 6473 } 6474 if (modifier in this) { 6475 return symbol.toupper(); 6476 } 6477 return mode in this ? 'x' : '-'; 6478 } 6479 } 6480 /** 6481 * Capabilities of system that affect index actions. 6482 */ 6483 [Flags] 6484 [CCode(cname = "unsigned int", cprefix = "GIT_INDEXCAP_", has_type_id = false)] 6485 public enum IndexCapability { 6486 IGNORE_CASE, 6487 NO_FILEMODE, 6488 NO_SYMLINKS, 6489 /** 6490 * Read capabilites from the config of the owner object, looking at 6491 * '''core.ignorecase''', '''core.filemode''', '''core.symlinks'''. 6492 */ 6493 FROM_OWNER 6494 } 6495 /** 6496 * Extra behaviors to {@link Repository.init_ext}. 6497 * 6498 * In every case, the default behavior is the flag not set. 6499 * 6500 */ 6501 [CCode(cname = "uint32_t", cprefix = "GIT_REPOSITORY_INIT_", has_type_id = false)] 6502 [Flags] 6503 public enum InitFlag { 6504 /** 6505 * Create a bare repository with no working directory. 6506 */ 6507 BARE, 6508 /** 6509 * Return an {@link Error.EXISTS} error if the path appears to already be 6510 * an git repository. 6511 */ 6512 NO_REINIT, 6513 /** 6514 * Normally a '''/.git/''' will be appended to the repo path for non-bare 6515 * repos (if it is not already there), but passing this flag prevents that 6516 * behavior. 6517 */ 6518 NO_DOTGIT_DIR, 6519 /** 6520 * Make the path (and working directory) as needed. 6521 * 6522 * Init is always willing to create the '''.git''' directory even without 6523 * this flag. This flag tells init to create the trailing component of the 6524 * repo and workdir paths as needed. 6525 */ 6526 MKDIR, 6527 /** 6528 * Recursively make all components of the repo and workdir paths as 6529 * necessary. 6530 */ 6531 MKPATH, 6532 /** 6533 * libgit2 normally uses internal templates to initialize a new repo. This 6534 * flags enables external templates, looking the '''template_path''' from 6535 * the options if set, or the '''init.templatedir''' global config if not, 6536 * or falling back on '''/usr/share/git-core/templates''' if it exists. 6537 */ 6538 EXTERNAL_TEMPLATE 6539 } 6540 /** 6541 * Basic type (loose or packed) of any git object 6542 */ 6543 [CCode(cname = "git_otype", cprefix = "GIT_OBJ_", has_type_id = false)] 6544 public enum ObjectType { 6545 /** 6546 * Object can be any of the following 6547 */ 6548 ANY, 6549 /** 6550 * Object is invalid 6551 */ 6552 BAD, 6553 /** 6554 * Reserved for future use 6555 */ 6556 _EXT1, 6557 /** 6558 * A commit object 6559 */ 6560 COMMIT, 6561 /** 6562 * A tree (directory listing) object 6563 */ 6564 TREE, 6565 /** 6566 * A file revision object 6567 */ 6568 BLOB, 6569 /** 6570 * An annotated tag object 6571 */ 6572 TAG, 6573 /** 6574 * Reserved for future use 6575 */ 6576 _EXT2, 6577 /** 6578 * A delta, base is given by an offset 6579 */ 6580 OFS_DELTA, 6581 /** 6582 * A delta, base is given by {@link object_id} 6583 */ 6584 REF_DELTA; 6585 /** 6586 * Convert an object type to its string representation 6587 */ 6588 [CCode(cname = "git_object_type2string")] 6589 public unowned string to_string(); 6590 6591 /** 6592 * Parse a string containing an object type 6593 * 6594 * @param str the string to convert 6595 * @return the corresponding object type 6596 */ 6597 [CCode(cname = "git_object_string2type")] 6598 public static ObjectType from_string(string str); 6599 6600 /** 6601 * Determine if the given this type is a valid loose object type 6602 * 6603 * @return true if the type represents a valid loose object type, false otherwise. 6604 */ 6605 [CCode(cname = "git_object_typeisloose")] 6606 public bool is_loose(); 6607 6608 /** 6609 * Get the size in bytes for the structure which holding this object type 6610 */ 6611 [CCode(cname = "git_object__size")] 6612 public size_t get_size(); 6613 } 6614 6615 [CCode(cname = "unsigned int", cprefix = "GIT_REPOSITORY_OPEN_", has_type_id = false)] 6616 [Flags] 6617 public enum OpenFlags { 6618 NO_SEARCH, 6619 CROSS_FS 6620 } 6621 [CCode(cname = "unsigned int", cprefix = "GIT_REF_FORMAT_", has_type_id = false)] 6622 [Flags] 6623 public enum ReferenceFormat { 6624 NORMAL, 6625 /** 6626 * Control whether one-level refnames are accepted 6627 * 6628 * (i.e., refnames that do not contain multiple /-separated components) 6629 */ 6630 ALLOW_ONELEVEL, 6631 /** 6632 * Interpret the provided name as a reference pattern for a refspec (as 6633 * used with remote repositories). 6634 * 6635 * If this option is enabled, the name is allowed to contain a single * 6636 * (<star>) in place of a one full pathname component (e.g., foo/<star>/bar 6637 * but not foo/bar<star>). 6638 */ 6639 REFSPEC_PATTERN, 6640 } 6641 /** 6642 * Basic type of any Git reference. 6643 */ 6644 [CCode(cname = "git_rtype", cprefix = "GIT_REF_", has_type_id = false)] 6645 [Flags] 6646 public enum ReferenceType { 6647 /** 6648 * Invalid reference 6649 */ 6650 INVALID, 6651 /** 6652 * A reference which points at an object id 6653 */ 6654 [CCode(cname = "GIT_REF_OID")] 6655 ID, 6656 /** 6657 * A reference which points at another reference 6658 */ 6659 SYMBOLIC, 6660 LISTALL 6661 } 6662 /** 6663 * Which operation remote operation has finished. 6664 */ 6665 [CCode(cname = "git_remote_completion_type", cprefix = "GIT_REMOTE_COMPLETION_", has_type_id = false)] 6666 public enum CompletionType { 6667 DOWNLOAD, 6668 INDEXING, 6669 ERROR 6670 } 6671 6672 /** 6673 * Kinds of reset operation. 6674 */ 6675 [CCode(cname = "git_reset_type", cprefix = "GIT_RESET_", has_type_id = false)] 6676 public enum ResetType { 6677 SOFT, 6678 MIXED, 6679 HARD 6680 } 6681 6682 /** 6683 * Actions that the smart transport can ask a subtransport to perform 6684 */ 6685 [CCode(cname = "git_smart_service_t", cprefix = "GIT_SERVICE_", has_type_id = false)] 6686 public enum SmartService { 6687 UPLOADPACK_LS, 6688 UPLOADPACK, 6689 RECEIVEPACK_LS, 6690 RECEIVEPACK 6691 } 6692 6693 /** 6694 * Sort order for revision walking. 6695 */ 6696 [CCode(cname = "int", cprefix = "GIT_SORT_", has_type_id = false)] 6697 [Flags] 6698 public enum Sorting { 6699 /** 6700 * Sort the repository contents in no particular ordering; 6701 * this sorting is arbitrary, implementation-specific 6702 * and subject to change at any time. 6703 * This is the default sorting for new walkers. 6704 */ 6705 NONE, 6706 /** 6707 * Sort the repository contents in topological order 6708 * (parents before children); this sorting mode 6709 * can be combined with time sorting. 6710 */ 6711 TOPOLOGICAL, 6712 /** 6713 * Sort the repository contents by commit time; 6714 * this sorting mode can be combined with 6715 * topological sorting. 6716 */ 6717 TIME, 6718 /** 6719 * Iterate through the repository contents in reverse 6720 * order; this sorting mode can be combined with 6721 * any of the above. 6722 */ 6723 REVERSE 6724 } 6725 [CCode(cname = "unsigned int", cprefix = "GIT_STASH_", has_type_id = false)] 6726 [Flags] 6727 public enum StashFlag { 6728 DEFAULT, 6729 /** 6730 * All changes already added to the index are left intact in the working 6731 * directory 6732 */ 6733 KEEP_INDEX, 6734 /** 6735 * All untracked files are also stashed and then cleaned up from the 6736 * working directory 6737 */ 6738 INCLUDE_UNTRACKED, 6739 /** 6740 * All ignored files are also stashed and then cleaned up from the working 6741 * directory 6742 */ 6743 INCLUDE_IGNORED 6744 } 6745 6746 [CCode(cname = "int", cprefix = "GIT_REPOSITORY_STATE_", has_type_id = false)] 6747 public enum State { 6748 NONE, 6749 MERGE, 6750 REVERT, 6751 CHERRY_PICK, 6752 BISECT, 6753 REBASE, 6754 REBASE_INTERACTIVE, 6755 REBASE_MERGE, 6756 APPLY_MAILBOX, 6757 APPLY_MAILBOX_OR_REBASE 6758 } 6759 6760 /** 6761 * Working directory file status 6762 */ 6763 [CCode(cname = "int", cprefix = "GIT_STATUS_", has_type_id = false)] 6764 public enum Status { 6765 CURRENT, 6766 INDEX_NEW, 6767 INDEX_MODIFIED, 6768 INDEX_DELETED, 6769 WT_NEW, 6770 WT_MODIFIED, 6771 WT_DELETED, 6772 IGNORED 6773 } 6774 /** 6775 * Select the files on which to report status. 6776 */ 6777 [CCode(cname = "git_status_show_t", has_type_id = false, cprefix = "GIT_STATUS_SHOW_")] 6778 public enum StatusShow { 6779 /** 6780 * The rough equivalent of '''git status --porcelain''' where each file 6781 * will receive a callback indicating its status in the index and in the 6782 * workdir. 6783 */ 6784 INDEX_AND_WORKDIR, 6785 /** 6786 * Only make callbacks for index side of status. 6787 * 6788 * The status of the index contents relative to the HEAD will be given. 6789 */ 6790 INDEX_ONLY, 6791 /** 6792 * Only make callbacks for the workdir side of status, reporting the status 6793 * of workdir content relative to the index. 6794 */ 6795 WORKDIR_ONLY, 6796 /** 6797 * Behave like index-only followed by workdir-only, causing two callbacks 6798 * to be issued per file (first index then workdir). 6799 * 6800 * This is slightly more efficient than making separate calls. This makes 6801 * it easier to emulate the output of a plain '''git status'''. 6802 */ 6803 INDEX_THEN_WORKDIR 6804 } 6805 6806 /** 6807 * Flags to control status callbacks 6808 */ 6809 [CCode(cname = "unsigned int", cprefix = "GIT_STATUS_OPT_", has_type_id = false)] 6810 public enum StatusControl { 6811 /** 6812 * Callbacks should be made on untracked files. 6813 * 6814 * These will only be made if the workdir files are included in the status 6815 * "show" option. 6816 */ 6817 INCLUDE_UNTRACKED, 6818 /** 6819 * Ignored files should get callbacks. 6820 * 6821 * These callbacks will only be made if the workdir files are included in 6822 * the status "show" option. Right now, there is no option to include all 6823 * files in directories that are ignored completely. 6824 */ 6825 INCLUDE_IGNORED, 6826 /** 6827 * Callbacks should be made even on unmodified files. 6828 */ 6829 INCLUDE_UNMODIFIED, 6830 /** 6831 * Directories which appear to be submodules should just be skipped over. 6832 */ 6833 EXCLUDE_SUBMODULES, 6834 /** 6835 * The contents of untracked directories should be included in the status. 6836 * 6837 * Normally if an entire directory is new, then just the top-level 6838 * directory will be included (with a trailing slash on the entry name). 6839 * Given this flag, the directory itself will not be included, but all the 6840 * files in it will. 6841 */ 6842 RECURSE_UNTRACKED_DIRS, 6843 DEFAULTS 6844 } 6845 6846 [CCode(cname = "git_submodule_update_t", cprefix = "GIT_SUBMODULE_UPDATE_", has_type_id = false)] 6847 public enum SubmoduleUpdate { 6848 DEFAULT, 6849 CHECKOUT, 6850 REBASE, 6851 MERGE, 6852 NONE 6853 } 6854 6855 [CCode(cname = "git_submodule_ignore_t", cpreifx = "GIT_SUBMODULE_IGNORE_", has_type_id = false)] 6856 public enum SubmoduleIgnore { 6857 /** 6858 * The working directory will be consider clean so long as there is a 6859 * checked out version present. 6860 */ 6861 ALL, 6862 /** 6863 * Only check if the HEAD of the submodule has moved for status. 6864 * 6865 * This is fast since it does not need to scan the working tree of the 6866 * submodule at all. 6867 */ 6868 DIRTY, 6869 /** 6870 * Examines the contents of the working tree but untracked files will not 6871 * count as making the submodule dirty. 6872 */ 6873 UNTRACKED, 6874 /** 6875 * Consider any change to the contents of the submodule from a clean 6876 * checkout to be dirty, including the addition of untracked files. 6877 * 6878 * This is the default if unspecified. 6879 */ 6880 NONE 6881 } 6882 6883 /** 6884 * Submodule status 6885 * 6886 * Submodule info is contained in 4 places: the HEAD tree, the index, config 6887 * files (both .git/config and .gitmodules), and the working directory. Any 6888 * or all of those places might be missing information about the submodule 6889 * depending on what state the repo is in. We consider all four places to 6890 * build the combination of status flags. 6891 * 6892 * There are four values that are not really status, but give basic info 6893 * about what sources of submodule data are available. These will be 6894 * returned even if {@link Submodule.ignore} is set to {@link SubmoduleIgnore.ALL}. 6895 * 6896 * * {@link IN_HEAD} superproject head contains submodule 6897 * * {@link IN_INDEX} superproject index contains submodule 6898 * * {@link IN_CONFIG} superproject gitmodules has submodule 6899 * * {@link IN_WD} superproject workdir has submodule 6900 * 6901 * The following values will be returned so long as ignore is not {@link SubmoduleIgnore.ALL}. 6902 * 6903 * * {@link INDEX_ADDED} in index, not in head 6904 * * {@link INDEX_DELETED} in head, not in index 6905 * * {@link INDEX_MODIFIED} index and head don't match 6906 * * {@link WD_UNINITIALIZED} workdir contains empty directory 6907 * * {@link WD_ADDED} in workdir, not index 6908 * * {@link WD_DELETED} in index, not workdir 6909 * * {@link WD_MODIFIED} index and workdir head don't match 6910 * 6911 * The following can only be returned if ignore is {@link SubmoduleIgnore.NONE} or {@link SubmoduleIgnore.UNTRACKED}. 6912 * 6913 * * {@link WD_INDEX_MODIFIED} submodule workdir index is dirty 6914 * * {@link WD_WD_MODIFIED} submodule workdir has modified files 6915 * 6916 * Lastly, the following will only be returned for ignore {@link SubmoduleIgnore.NONE}. 6917 * 6918 * * {@link WD_UNTRACKED} wd contains untracked files 6919 */ 6920 [CCode(cname = "unsigned int", has_type_id = false, cprefix = "GIT_SUBMODULE_STATUS_")] 6921 public enum SubmoduleStatus { 6922 IN_HEAD, 6923 IN_INDEX, 6924 IN_CONFIG, 6925 IN_WD, 6926 INDEX_ADDED, 6927 INDEX_DELETED, 6928 INDEX_MODIFIED, 6929 WD_UNINITIALIZED, 6930 WD_ADDED, 6931 WD_DELETED, 6932 WD_MODIFIED, 6933 WD_INDEX_MODIFIED, 6934 WD_WD_MODIFIED, 6935 WD_UNTRACKED; 6936 [CCode(cname = "GIT_SUBMODULE_STATUS_IS_UNMODIFIED")] 6937 public bool is_unmodified(); 6938 [CCode(cname = "GIT_SUBMODULE_STATUS_IS_WD_DIRTY")] 6939 public bool is_wd_dirty(); 6940 } 6941 /** 6942 * Available tracing levels. 6943 * 6944 * When tracing is set to a particular level, callers will be provided 6945 * tracing at the given level and all lower levels. 6946 */ 6947 [CCode(cname = "git_trace_level_t", cprefix = "GIT_TRACE_", has_type_id = false)] 6948 public enum Trace { 6949 /** 6950 * No tracing will be performed. 6951 */ 6952 NONE, 6953 /** 6954 * Severe errors that may impact the program's execution 6955 */ 6956 FATAL, 6957 /** 6958 * Errors that do not impact the program's execution 6959 */ 6960 ERROR, 6961 /** 6962 * Warnings that suggest abnormal data 6963 */ 6964 WARN, 6965 /** 6966 * Informational messages about program execution 6967 */ 6968 INFO, 6969 /** 6970 * Detailed data that allows for debugging 6971 */ 6972 DEBUG, 6973 /** 6974 * Exceptionally detailed debugging data 6975 */ 6976 TRACE; 6977 /** 6978 * Sets the system tracing configuration to the specified level with the 6979 * specified callback. 6980 * 6981 * When system events occur at a level equal to, or lower than, the given 6982 * level they will be reported to the given callback. 6983 */ 6984 [CCode(cname = "git_trace_set")] 6985 public Error setup(Tracer tracer); 6986 } 6987 [CCode(cname = "int", cprefix = "GIT_TRANSPORTFLAGS_", has_type_id = false)] 6988 public enum TransportFlags { 6989 NONE, 6990 /** 6991 * If the connection is secured with SSL/TLS, the authenticity of the 6992 * server certificate should not be verified. 6993 */ 6994 NO_CHECK_CERT 6995 } 6996 6997 /** 6998 * Tree traversal modes 6999 */ 7000 [CCode(cname = "git_treewalk_mode", cprefix = "GIT_TREEWALK_", has_type_id = false)] 7001 public enum WalkMode { 7002 PRE, 7003 POST 7004 } 7005 7006 [CCode(cname = "git_attr_foreach_cb", has_type_id = false)] 7007 public delegate Error AttributeForEach(string name, string? val); 7008 [CCode(cname = "git_branch_foreach_cb")] 7009 public delegate int Branch(string branch_name, BranchType branch_type); 7010 /** 7011 * Callback for notification of a file during checkout. 7012 * 7013 * 7014 * Notification callbacks are made prior to modifying any files on disk. 7015 * 7016 * @return true to cancel the checkout; false otherwise. 7017 */ 7018 [CCode(cname = "git_checkout_notify_cb", has_type_id = false)] 7019 public delegate bool CheckoutNotifier(CheckoutNotify why, string path, diff_file baseline, diff_file target, diff_file workdir); 7020 /** 7021 * 7022 * The implementation of the callback has to respect the 7023 * following rules: 7024 * 7025 * @param content will have to be filled. The maximum number of bytes that 7026 * the buffer can accept per call is the length of the array. 7027 * 7028 * @return The callback is expected to return the number of bytes 7029 * written to content. When there is no more data to stream, the callback 7030 * should return 0. This will prevent it from being invoked anymore. When an 7031 * error occurs, the callback should return -1. 7032 */ 7033 [CCode(cname = "git_blob_chunk_cb")] 7034 public delegate int ChunkSource([CCode(array_length_type = "size_t")] uint8[] content); 7035 7036 [CCode(cname = "git_config_foreach_cb")] 7037 public delegate int ConfigForEach(config_entry entry); 7038 /** 7039 * made on files where the index differs from the working 7040 * directory but the rules do not allow update. 7041 * 7042 * All such callbacks will be made before any changes are made to the 7043 * working directory. 7044 * @return true to abort the checkout. 7045 */ 7046 public delegate bool Conflict(string conflicting_path, object_id index_id, uint index_mode, uint wd_mode); 7047 /** 7048 * A function which creates a new subtransport for the smart transport 7049 */ 7050 [CCode(cname = "git_smart_subtransport_cb", has_target = false)] 7051 public delegate Error CreateSubTransport(out smart_subtransport? subtransport, transport owner); 7052 /** 7053 * Signature of a function which creates a transport 7054 */ 7055 [CCode(cname = "git_transport_cb")] 7056 public delegate Error CreateTransport(out transport? transport, Remote owner); 7057 7058 /** 7059 * Signature of a function which acquires a credential object. 7060 * 7061 * @param cred The newly created credential object. 7062 * @param url The resource for which we are demanding a credential. 7063 * @param allowed_types A bitmask stating which cred types are OK to return. 7064 */ 7065 [CCode(cname = "git_cred_acquire_cb", has_type_id = false)] 7066 public delegate Error CredAcquire(out cred? cred, string url, CredTypes allowed_types); 7067 [CCode(has_target = false, has_type_id = false)] 7068 public delegate void CredFree(owned cred cred); 7069 7070 /** 7071 * When printing a diff, callback that will be made to output each line of 7072 * text. 7073 * @return true to stop iteration 7074 */ 7075 [CCode(cname = "git_diff_data_cb", simple_generics = true, has_target = false, has_type_id = false)] 7076 public delegate bool DiffData<T>(diff_delta delta, diff_range range, DiffLineType line_origin, [CCode(array_length_type = "size_t")] char[] formatted_output, T context); 7077 /** 7078 * When iterating over a diff, callback that will be made per file. 7079 */ 7080 [CCode(cname = "git_diff_file_cb", simple_generics = true, has_target = false, has_type_id = false)] 7081 public delegate Error DiffFile<T>(diff_delta delta, float progress, T context); 7082 7083 /** 7084 * When iterating over a diff, callback that will be made per hunk. 7085 */ 7086 [CCode(cname = "git_diff_hunk_cb", simple_generics = true, has_target = false, has_type_id = false)] 7087 public delegate Error DiffHunk<T>(diff_delta delta, diff_range range, [CCode(array_length_type = "size_t")] char[] header, T context); 7088 7089 /** 7090 * When iterating over a diff, callback that will be made per text diff 7091 * line. 7092 * @return true to stop iteration 7093 */ 7094 [CCode(cname = "git_diff_line_fn", simple_generics = true, has_target = false, has_type_id = false)] 7095 public delegate bool DiffLine<T>(T context, diff_delta delta, DiffLineType line_origin, [CCode(array_length_type = "size_t")] uint8[] content); 7096 /* 7097 * Diff notification callback function. 7098 * 7099 * The callback will be called for each file, just before the {@link 7100 * DeltaType} gets inserted into the diff list. 7101 * 7102 * When the callback: 7103 * - returns < 0, the diff process will be aborted. 7104 * - returns > 0, the delta will not be inserted into the diff list, but the 7105 * diff process continues. 7106 * - returns 0, the delta is inserted into the diff list, and the diff process 7107 * continues. 7108 */ 7109 [CCode(cname = "git_diff_notify_cb", has_type_id = false)] 7110 public delegate int DiffNotify(DiffList diff_so_far, diff_delta delta_to_add, string matched_pathspec); 7111 7112 /** 7113 * When printing a diff, callback that will be made to output each line of 7114 * text. 7115 * @return true to stop iteration 7116 */ 7117 [CCode(cname = "git_diff_data_cb", has_type_id = false)] 7118 public delegate bool DiffOutput(diff_delta delta, diff_range range, DiffLineType line_origin, [CCode(array_length_type = "size_t")] char[] formatted_output); 7119 [CCode(cname = "git_repository_fetchhead_foreach_cb")] 7120 public delegate bool FetchHeadForEach(string ref_name, string remote_url, object_id id, bool is_merge); 7121 7122 [CCode(cname = "git_treebuilder_filter_cb", has_type_id = false)] 7123 public delegate bool Filter(TreeEntry entry); 7124 [CCode(cname = "git_headlist_cb", has_type_id = false)] 7125 public delegate int Head(remote_head head); 7126 [CCode(cname = "git_repository_mergehead_foreach_cb", has_type_id = false)] 7127 public delegate bool MergeHeadForEach(object_id id); 7128 /** 7129 * Called to process a note. 7130 * @param blob_id id of the blob containing the message 7131 * @param annotated_object_id id of the git object being annotated 7132 */ 7133 [CCode(cname = "git_note_foreach_cb", has_type_id = false)] 7134 public delegate Error NoteForEach(object_id blob_id, object_id annotated_object_id); 7135 [CCode(cname = "git_odb_foreach_cb", has_type_id = false)] 7136 public delegate Error ObjectIdForEach(object_id id); 7137 [CCode(cname = "git_packbuilder_foreach_cb", has_type_id = false)] 7138 public delegate int PackBuilderForEach([CCode(array_length_type = "size_t")] uint8[] buffer); 7139 public delegate bool PushForEach(string ref_spec, string msg); 7140 [CCode(cname = "git_checkout_progress_cb")] 7141 public delegate void Progress(string path, size_t completed_steps, size_t total_steps); 7142 7143 /** 7144 * Suggests that the given refdb compress or optimize its references. 7145 * 7146 * This mechanism is implementation specific. (For on-disk reference 7147 * databases, this may pack all loose references.) 7148 */ 7149 [CCode(has_target = false, has_type_id = false)] 7150 public delegate Error RefDbCompress(refdb_backend backend); 7151 /** 7152 * Deletes the given reference from the refdb. 7153 */ 7154 [CCode(has_target = false, has_type_id = false)] 7155 public delegate Error RefDbDelete(refdb_backend backend, Reference reference); 7156 /** 7157 * Queries the refdb backend to determine if the given ref_name 7158 * exists. 7159 */ 7160 [CCode(has_target = false, has_type_id = false)] 7161 public delegate Error RefDbExists(out bool exists, refdb_backend backend, string ref_name); 7162 /** 7163 * Enumerates each reference in the refdb. 7164 */ 7165 [CCode(has_target = false, has_type_id = false)] 7166 public delegate Error RefDbForEach(refdb_backend backend, ReferenceType list_flags, ReferenceForEach @foreach); 7167 /** 7168 * Enumerates each reference in the refdb that matches the given glob string. 7169 */ 7170 [CCode(has_target = false, has_type_id = false)] 7171 public delegate Error RefDbForEachGlob(refdb_backend backend, string glob, ReferenceType list_flags, ReferenceForEach @foreach); 7172 /** 7173 * Frees any resources held by the refdb. 7174 */ 7175 [CCode(has_target = false, has_type_id = false)] 7176 public delegate void RefDbFree(owned refdb_backend backend); 7177 /** 7178 * Queries the refdb backend for a given reference. 7179 */ 7180 [CCode(has_target = false, has_type_id = false)] 7181 public delegate Error RefDbLookup(out Reference? reference, refdb_backend backend, string ref_name); 7182 /** 7183 * Writes the given reference to the refdb. 7184 */ 7185 [CCode(has_target = false, has_type_id = false)] 7186 public delegate Error RefDbWrite(refdb_backend backend, Reference reference); 7187 7188 [CCode(cname = "git_reference_foreach_cb", has_type_id = false)] 7189 public delegate bool ReferenceForEach(string refname); 7190 [CCode(simple_generics = true, has_type_id = false)] 7191 public delegate void RemoteProgress<T>(uint8[] str, T data); 7192 [CCode(has_target = false, simple_generics = true, has_type_id = false)] 7193 public delegate Error RemoteCompletion<T>(CompletionType type, T data); 7194 [CCode(has_target = false, simple_generics = true, has_type_id = false)] 7195 public delegate Error RemoteUpdateTips<T>(string refname, object_id a, object_id b, T data); 7196 /** 7197 * When iterating over all the stashed states, callback that will be issued 7198 * per entry. 7199 * 7200 * @param index The position within the stash list. 0 points to the most 7201 * recent stashed state. 7202 * @param message The stash message. 7203 * @param stash_id The commit id of the stashed state. 7204 * @return 0 on success, GIT_EUSER on non-zero callback, or error code 7205 */ 7206 [CCode(cname = "git_stash_cb")] 7207 public delegate Error StashForEach(size_t index, string message, object_id stash_id); 7208 /** 7209 * Function to receive status on individual files 7210 * 7211 * @param file the relative path to the file from the root of the repository. 7212 */ 7213 [CCode(cname = "git_status_cb", has_type_id = false)] 7214 public delegate Error StatusForEach(string file, Status status); 7215 public delegate Error SubmoduleForEach(string name); 7216 [CCode(cname = "git_tag_foreach_cb", has_type_id = false)] 7217 public delegate bool TagForEach(string name, object_id id); 7218 /** 7219 * An instance for a tracing function 7220 */ 7221 [CCode(cname = "git_trace_callback", has_type_id = false, has_target = false)] 7222 public delegate void Tracer(Trace level, string msg); 7223 /** 7224 * Type for progress callbacks during indexing. 7225 * 7226 * @param stats Structure containing information about the state of the transfer 7227 * @return an error to cancel the transfer. 7228 */ 7229 [CCode(cname = "git_transfer_progress_callback", has_type_id = false)] 7230 public delegate Error TransferProgress(transfer_progress stats); 7231 7232 [CCode(has_target = false, has_type_id = false)] 7233 public delegate void TransportCancel(transport transport); 7234 [CCode(has_target = false, has_type_id = false)] 7235 public delegate Error TransportClose(transport transport); 7236 [CCode(has_target = false, has_type_id = false)] 7237 public delegate Error TransportConnect(transport transport, string url, CredAcquire cred_acquire, Direction direction, TransportFlags flags); 7238 [CCode(has_target = false, has_type_id = false)] 7239 public delegate Error TransportDownloadPack(transport transport, Repository repo, out transfer_progress stats, Progress progress); 7240 [CCode(has_target = false, has_type_id = false)] 7241 public delegate void TransportFree(owned transport? transport); 7242 [CCode(has_target = false, has_type_id = false)] 7243 public delegate bool TransportIsConnected(transport transport); 7244 [CCode(has_target = false, has_type_id = false)] 7245 public delegate Error TransportList(transport transport, Head list); 7246 [CCode(cname = "git_transport_message_cb", has_type_id = false, has_target = false, simple_generics = true)] 7247 public delegate void TransportMessage<T>(uint8[] message, T data); 7248 [CCode(has_target = false, has_type_id = false)] 7249 public delegate Error TransportNegotiatFetch(transport transport, Repository repo, [CCode(array_length_type = "size_t")] remote_head[] refs); 7250 [CCode(has_target = false, has_type_id = false)] 7251 public delegate Error TransportPush(transport transport, Push push); 7252 [CCode(has_target = false, has_type_id = false)] 7253 public delegate Error TransportReadFlags(transport transport, out TransportFlags flags); 7254 [CCode(has_target = false, has_type_id = false)] 7255 public delegate Error TransportSetCallbacks<T>(transport transport, TransportMessage<T> progress, TransportMessage<T> error, T data); 7256 7257 [CCode(has_target = false, has_type_id = false)] 7258 public delegate Error SubTransportAction(out smart_subtransport_stream? stream, smart_subtransport transport, string url, SmartService action); 7259 [CCode(has_target = false, has_type_id = false)] 7260 public delegate Error SubTransportClose(smart_subtransport transport); 7261 [CCode(has_target = false, has_type_id = false)] 7262 public delegate void SubTransportFree(owned smart_subtransport? transport); 7263 [CCode(has_target = false, has_type_id = false)] 7264 public delegate void SubTransportStreamFree(owned smart_subtransport_stream? stream); 7265 [CCode(has_target = false, has_type_id = false)] 7266 public delegate Error SubTransportStreamRead(smart_subtransport_stream stream, [CCode(array_length_type = "size_t")] uint8[] buffer, out size_t bytes_read); 7267 [CCode(has_target = false, has_type_id = false)] 7268 public delegate Error SubTransportStreamWrite(smart_subtransport_stream stream, [CCode(array_length_type = "size_t")] uint8[] buffer); 7269 7270 [CCode(cname = "git_treewalk_cb", has_type_id = false)] 7271 public delegate int TreeWalker(string root, TreeEntry entry); 7272 [CCode(has_target = false)] 7273 public delegate Error Update(string refname, object_id old, object_id @new); 7274 7275 /** 7276 * Clean up message from excess whitespace and make sure that the last line 7277 * ends with a new line. 7278 * 7279 * @param message_out The buffer which will be filled with the cleaned up 7280 * message. 7281 * @param message The message to be prettified. 7282 * 7283 * @param strip_comments remove lines starting with a "#". 7284 */ 7285 [CCode(cname = "git_message_prettify")] 7286 public Error prettify_message([CCode(array_length_type = "size_t")] uint8[] message_out, string message, bool strip_comments); 7287 7288 namespace Option { 7289 [CCode(cname = "int", cprefix = "GIT_OPT_")] 7290 private enum _Option { 7291 GET_MWINDOW_SIZE, 7292 SET_MWINDOW_SIZE, 7293 GET_MWINDOW_MAPPED_LIMIT, 7294 SET_MWINDOW_MAPPED_LIMIT, 7295 GET_SEARCH_PATH, 7296 SET_SEARCH_PATH, 7297 GET_ODB_CACHE_SIZE, 7298 SET_ODB_CACHE_SIZE; 7299 [CCode(cname = "git_libgit2_opts")] 7300 public Error opts(...); 7301 } 7302 public size_t get_mwindow_mapped_limit() { 7303 size_t s = 0; 7304 _Option.GET_MWINDOW_MAPPED_LIMIT.opts(out s); 7305 return s; 7306 } 7307 /** 7308 * Set the maximum amount of memory that can be mapped at any time by the 7309 * library. 7310 */ 7311 public void set_mwindow_mapped_limit(size_t size) { 7312 _Option.SET_MWINDOW_MAPPED_LIMIT.opts(size); 7313 } 7314 /** 7315 * Set the maximum mmap window size. 7316 */ 7317 public size_t get_mwindow_size() { 7318 size_t s = 0; 7319 _Option.GET_MWINDOW_SIZE.opts(out s); 7320 return s; 7321 } 7322 public void set_mwindow_size(size_t size) { 7323 _Option.SET_MWINDOW_SIZE.opts(size); 7324 } 7325 /** 7326 * Get the size of the libgit2 odb cache. 7327 */ 7328 public size_t get_odb_cache_size() { 7329 size_t s = 0; 7330 _Option.GET_ODB_CACHE_SIZE.opts(out s); 7331 return s; 7332 } 7333 /** 7334 * Set the size of the of the libgit2 odb cache. 7335 * 7336 * This needs to be done before {@link Repository.open} is called, since 7337 * it initializes the odb layer. Defaults to 128. 7338 */ 7339 public void set_odb_cache_size(size_t size = 128) { 7340 _Option.SET_ODB_CACHE_SIZE.opts(size); 7341 } 7342 /** 7343 * Set the search path for a given level of config data. 7344 * 7345 * @param level must be one of {@link ConfigLevel.SYSTEM}, 7346 * {@link ConfigLevel_GLOBAL}, or {@link ConfigLevel.XDG}. 7347 */ 7348 public string get_search_path(ConfigLevel level) { 7349 uint8[] buffer = new uint8[64]; 7350 while (_Option.GET_SEARCH_PATH.opts(level, (void*)buffer, (size_t) buffer.length) == Error.BUFS) { 7351 buffer = new uint8[buffer.length * 2]; 7352 } 7353 return ((string)buffer).dup(); 7354 } 7355 public void set_search_path(ConfigLevel level, string path) { 7356 _Option.SET_SEARCH_PATH.opts(level, path); 7357 } 7358 } 7359 7360 /** 7361 * Set the error message to a special value for memory allocation failure. 7362 * 7363 * The normal {@link ErrClass.raise} function attempts to duplicate the 7364 * string that is passed in. This is not a good idea when the error in 7365 * question is a memory allocation failure. That circumstance has a special 7366 * setter function that sets the error string to a known and statically 7367 * allocated internal value. 7368 */ 7369 [CCode(cname = "giterr_set_oom")] 7370 public void raise_oom(); 7371 7372 7373 [CCode(cname = "char*", has_type_id = false)] 7374 [SimpleType] 7375 private struct unstr { 7376 [CCode(cname = "strdup")] 7377 public string dup(); 7378 } 7379 } 7380 7381 7382