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>
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.
13 * Library to access the contents of git repositories
15 * libgit2 can access and manipulate the contents of git repositories. To begin, create an instance of a {@link Git.Repository} like so:
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);
23 * Then use the methods of //repo// to access the repository.
25 [CCode (cheader_filename = "git2.h")]
27 namespace Configuration {
29 * Generic backend that implements the interface to
30 * access a configuration file
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;
37 public unowned Config cfg;
38 public Delete @delete;
39 [CCode (cname = "foreach")]
40 public ForEach for_each;
43 [CCode (cname = "get_multivar")]
44 public GetMulti get_multi;
45 [CCode (cname = "refersh")]
46 public Refresh refresh;
49 public SetMulti set_multi;
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);
75 * An open object database handle
77 [CCode (cname = "git_odb", free_function = "git_odb_close", has_type_id = false)]
81 * Create a new object database with no backends.
83 * Before the ODB can be used for read/writing, a custom database
84 * backend must be manually added using {@link Handle.add_backend}.
86 * @param db location to store the database pointer, if opened. Set to null if the open failed.
88 [CCode (cname = "git_odb_new")]
89 public static Error create (out Handle? db);
92 * Create a new object database and automatically add
93 * the two default backends.
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
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
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.
107 [CCode (cname = "git_odb_open")]
108 public static Error open (out Handle db, string objects_dir);
111 * Add a custom backend to an existing Object DB; this
112 * backend will work as an alternate.
114 * Alternate backends are always checked for objects ''after''
115 * all the main backends have been exhausted.
117 * The backends are checked in relative ordering, based on the
118 * value of the //priority// parameter.
120 * Writing is disabled on alternate backends.
122 * @param backend the backend instance
123 * @param priority Value for ordering the backends queue
125 [CCode (cname = "git_odb_add_alternate")]
126 public Error add_alternate (backend backend, int priority);
129 * Add a custom backend to an existing Object DB
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
136 [CCode (cname = "git_odb_add_backend")]
137 public Error add_backend (backend backend, int priority);
140 * Determine if the given object can be found in the object database.
142 * @param id the object to search for.
144 [CCode (cname = "git_odb_exists")]
145 public bool contains (object_id id);
148 * Create a "fake" repository to wrap an object database
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.
154 [CCode (cname = "git_repository_wrap_odb", instance_pos = -1)]
155 public Error create_repository (out Repository? repository);
158 * List all objects available in the database
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.
164 [CCode (cname = "git_odb_foreach")]
165 public Error for_each (ObjectIdForEach object_for_each);
168 * Read an object from the database.
170 * This method queries all available ODB backends
171 * trying to read the given id.
173 * @param obj pointer where to store the read object
174 * @param id identity of the object to read.
176 [CCode (cname = "git_odb_read", instance_pos = 1.2)]
177 public Error read (out Object obj, object_id id);
180 * Read an object from the database, given a prefix
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.
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.
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
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);
205 * Read the header of an object from the database, without
206 * reading its full contents.
208 * The header includes the length and the type of an object.
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.
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.
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);
222 * Refresh the object database to load newly added files.
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.
227 * Use this function when you're confident that an external application
228 * has tampered with the ODB.
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
235 [CCode (cname = "git_odb_refresh")]
236 public Error refresh ();
239 * Open a stream to write an object into the ODB
241 * The type and final length of the object must be specified
242 * when opening the stream.
244 * The returned stream will be of type {@link StreamMode.WRONLY} and
245 * will have the following methods:
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
250 * The streaming write won't be effective until {@link stream.finalize_write}
251 * is called and returns without an error
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
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);
261 * Open a stream to read an object from the ODB
263 * Note that most backends do ''not'' support streaming reads
264 * because they store their objects as compressed/delta'ed blobs.
266 * It's recommended to use {@link Handle.read} instead, which is
267 * assured to work on all backends.
269 * The returned stream will be of type {@link StreamMode.RDONLY} and
270 * will have the following methods:
272 * * {@link stream.read}: read //n// bytes from the stream
274 * @param stream where to store the stream
275 * @param id id of the object the stream will read from
277 [CCode (cname = "git_odb_open_rstream")]
278 public Error open_read_stream (out stream stream, object_id id);
281 * Write an object directly into the ODB
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
288 * This method is provided for compatibility with custom backends
289 * which are not able to support streaming writes
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
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);
300 * An object read from the database
302 [CCode (cname = "git_odb_object", free_function = "git_odb_object_free", has_type_id = false)]
304 public class Object {
307 * The data of an ODB object
309 * This is the uncompressed, raw data as read from the ODB,
310 * without the leading header.
312 public uint8[] data {
313 [CCode (cname = "git_odb_object_data", array_length_cexpr = "git_odb_object_size")]
318 * The id of an ODB object
320 public object_id? id {
321 [CCode (cname = "git_odb_object_id")]
326 * The type of an ODB object
328 public ObjectType type {
329 [CCode (cname = "git_odb_object_type")]
335 * A custom backend in an ODB
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;
342 public unowned Handle odb;
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;
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);
369 * A stream to read/write from the ODB
371 [CCode (cname = "git_odb_stream", has_type_id = false)]
372 public struct stream {
373 public unowned backend? backend;
375 public StreamMode mode;
377 public StreamFinalizeWrite finalize_write;
378 public StreamFree free;
379 public StreamRead read;
380 public StreamWrite write;
383 * A stream to write a pack file to the ODB
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;
398 [CCode (cname = "git_odb_streammode", cprefix = "GIT_STREAM_", has_type_id = false)]
399 public enum StreamMode {
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);
411 * Read each return to libgit2 a buffer which will be freed later.
413 * The buffer should be allocated using the function {@link backend.malloc} to
414 * ensure that it can be safely freed later.
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);
419 * Find a unique object given a prefix
421 * The id given must be so that the remaining
422 * ({@link object_id.HEX_SIZE} - len)*4 bits are 0s.
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);
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);
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);
455 * Init the threading system.
457 * If libgit2 has been built with GIT_THREADS
458 * on, this function must be called once before
459 * any other library functions.
461 * If libgit2 has been built without GIT_THREADS
462 * support, this function is a no-op.
464 [CCode (cname = "git_threads_init")]
465 public Error init ();
468 * Shutdown the threading system.
470 * If libgit2 has been built with GIT_THREADS
471 * on, this function must be called before shutting
474 * If libgit2 has been built without GIT_THREADS
475 * support, this function is a no-op.
477 [CCode (cname = "git_threads_shutdown")]
478 public void shutdown ();
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;
490 * Return the version of the libgit2 library
491 * being currently used.
493 * @param major Store the major version number
494 * @param minor Store the minor version number
495 * @param rev Store the revision (patch) number
497 [CCode (cname = "git_libgit2_version")]
498 public void get_version (out int major, out int minor, out int rev);
502 * Attribute management routines
504 [CCode (cname = "git_repository", cheader_filename = "git2/attr.h", has_type_id = false)]
506 [CCode (cname = "git_attr_t", cprefix = "GIT_ATTR_", has_type_id = false)]
507 public enum AttrType {
508 [CCode (cname = "GIT_ATTR_UNSPECIFIED_T")]
510 [CCode (cname = "GIT_ATTR_TRUE_T")]
512 [CCode (cname = "GIT_ATTR_FALSE_T")]
514 [CCode (cname = "GIT_ATTR_VALUE_T")]
517 * Return the value type for a given attribute.
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.
523 * If the attribute has a {@link VALUE} string, it can be accessed
524 * normally as a string.
526 [CCode (cname = "git_attr_value")]
527 public static AttrType from (string attr);
531 * Checks if an attribute is set on.
533 * In core git parlance, this the value for "Set" attributes.
535 [CCode (cname = "GIT_ATTR_TRUE")]
536 public static bool is_true (string? attr);
538 * Checks if an attribute is set off.
540 * In core git parlance, this is the value for attributes that are "Unset"
541 * (not to be confused with values that a "Unspecified").
543 [CCode (cname = "GIT_ATTR_FALSE")]
544 public static bool is_false (string? attr);
546 * Checks if an attribute is set to a value (as opposied to TRUE, FALSE or
549 [CCode (cname = "GIT_ATTR_SET_TO_VALUE")]
550 public static bool is_set (string? attr);
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.
556 [CCode (cname = "GIT_ATTR_UNSPECIFIED")]
557 public static bool is_unspecified (string? attr);
560 * Add a macro definition.
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:
567 * repo.attributes.add_macro("binary", "-diff -crlf");
570 [CCode (cname = "git_attr_add_macro")]
571 public Error add_macro (string name, string val);
574 * Lookup attribute for path returning string caller must free
576 [CCode (cname = "git_attr_get")]
577 public Error lookup (AttrCheck flags, string path, string name, out unowned string? val);
580 * Lookup list of attributes for path, populating array of strings
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.
586 * For example, you might write:
588 * string attrs[] = { "crlf", "diff", "foo" };
590 * repo.attributes.lookup_many(AttrCheck.FILE_THEN_INDEX, "my/fun/file.c", attrs, out values);
592 * Then you could loop through the 3 values to get the settings for
593 * the three attributes you asked about.
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.
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 ();
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);
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
628 [CCode (cname = "git_attr_foreach")]
629 public Error for_each (AttrCheck flags, string path, AttributeForEach attribute_for_each);
632 * Flush the gitattributes cache.
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.
639 [CCode (cname = "git_attr_cache_flush")]
640 public void flush ();
644 * In-memory representation of a blob object.
646 [CCode (cname = "git_blob", free_function = "git_blob_free", has_type_id = false)]
648 public class Blob : Object {
649 [CCode (array_length = false, cname = "git_blob_rawcontent")]
650 private unowned uint8[]? _get_content ();
653 * Get a read-only buffer with the raw content of a blob.
655 * A pointer to the raw content of a blob is returned.
656 * The pointer may be invalidated at a later time.
658 public uint8[]? content {
660 unowned uint8[]? content = _get_content ();
661 if (content != null) {
662 content.length = (int) size;
670 public object_id? id {
671 [CCode (cname = "git_blob_id")]
675 * Determine if the blob content is most certainly binary or not.
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.
681 public bool is_binary {
682 [CCode (cname = "git_blob_is_binary")]
685 public Repository owner {
686 [CCode (cname = "git_blob_owner")]
690 * Get the size in bytes of the contents of a blob
693 [CCode (cname = "git_blob_rawsize")]
697 * Directly run a text diff on two blobs.
699 * Compared to a file, a blob lacks some contextual information. As such, the
700 * {@link diff_file} parameters of the callbacks will be filled accordingly to the following:
701 * mode will be set to 0, path will be null. When dealing with a null blob, object id
704 * When at least one of the blobs being dealt with is binary, the {@link diff_delta} binary
705 * attribute will be set to true and no call to the hunk nor line will be made.
707 * We do run a binary content check on the two blobs and if either of the
708 * blobs looks like binary data, {@link diff_delta.flags} will {@link DiffFlag.BINARY}
709 * and no call to the {@link DiffHunk} nor {@link DiffData} will be made
710 * (unless you pass {@link DiffFlags.FORCE_TEXT} of course).
712 [CCode (cname = "git_diff_blobs", simple_generics = true)]
713 public Error diff<T> (string? old_path, Blob new_blob, string? new_path, diff_options? options, DiffFile<T>? file, DiffHunk<T>? hunk, DiffData<T>? line, T context);
715 * Directly run a diff between a blob and a buffer.
717 * As with {@link diff}, comparing a blob and buffer lacks some context, so
718 * the {@link diff_file} parameters to the callbacks will be faked.
720 [CCode (cname = "git_diff_blob_to_buffer", simple_generics = true)]
721 public Error diff_buffer<T> (string? old_path, [CCode (array_length_type = "size_t")] uint8[] buffer, string? buffer_path, diff_options? options, DiffFile<T>? file, DiffHunk<T>? hunk, DiffData<T>? line, T context);
723 * Directly generate a patch from the difference between two blobs.
725 * This is just like {@link diff} except it generates a patch object for
726 * the difference instead of directly making callbacks.
728 [CCode (cname = "git_diff_patch_from_blobs", instance_pos = 1.1)]
729 public Error diff_patch (out Patch? patch, string? old_path, Blob new_blob, string? new_path, diff_options? options = null);
731 * Directly generate a patch from the difference between a blob and a
734 * This is just like {@link diff_buffer} except it generates a patch object
735 * for the difference instead of directly making callbacks.
737 [CCode (cname = "git_diff_patch_from_blob_and_buffer")]
738 public Error diff_patch_buffer (out Patch? patch, string? old_path, [CCode (array_length_type = "size_t")] uint8[] buffer, string? new_path, diff_options? options = null);
742 * Parsed representation of a commit object.
744 [CCode (cname = "git_commit", free_function = "git_commit_free", has_type_id = false)]
746 public class Commit : Object {
748 * The author of a commit.
750 public Signature author {
751 [CCode (cname = "git_commit_author")]
756 * The committer of a commit.
758 public Signature committer {
759 [CCode (cname = "git_commit_committer")]
764 * The id of a commit.
766 public object_id? id {
767 [CCode (cname = "git_commit_id")]
772 * The full message of a commit.
774 public string message {
775 [CCode (cname = "git_commit_message")]
780 * The encoding for the message of a commit, as a string representing a
781 * standard encoding name.
783 * The encoding may be null if the encoding header in the commit is
784 * missing; in that case UTF-8 is assumed.
786 public string? message_encoding {
787 [CCode (cname = "git_commit_message_encoding")]
791 * Get the repository that contains the commit.
793 * @param commit A previously loaded commit.
794 * @return Repository that contains this commit.
796 public Repository owner {
797 [CCode (cname = "git_commit_owner")]
802 * The parent(s) of this commit
804 * Typically, commits have a single parent, but merges can have many.
806 public Parents parents {
812 * Get the commit time (i.e., committer time) of a commit.
815 [CCode (cname = "git_commit_time")]
820 * Get the commit timezone offset (i.e., committer's preferred timezone) in minutes from UTC of a commit.
822 public int time_offset {
823 [CCode (cname = "git_commit_time_offset")]
828 * Get the id of the tree pointed to by a commit.
830 * This differs from {@link lookup_tree} in that no attempts
831 * are made to fetch an object from the ODB.
833 public object_id? tree_id {
834 [CCode (cname = "git_commit_tree_oid")]
838 * Get the commit object that is an ancestor of the named commit object,
839 * following only the first parents.
841 * @param ancestor the ancestor received, if any
842 * @param n the requested generation, or 0 for a copy of the commit.
844 [CCode (cname = "git_commit_nth_gen_ancestor", instance_pos = 1.2)]
845 public Error get_ancestor (out Commit? ancestor, uint n);
848 * The message of a commit converted to UTF-8.
850 public string get_message_utf8 () throws GLib.ConvertError {
851 return this.message_encoding == null ? this.message : GLib.convert (this.message, this.message.length, "utf-8", this.message_encoding);
855 * Get the tree pointed to by a commit.
857 [CCode (cname = "git_commit_tree", instance_pos = -1)]
858 public Error lookup_tree (out Tree tree);
862 * Memory representation of a set of config files
864 [CCode (cname = "git_config", free_function = "git_config_free", has_type_id = false)]
866 public class Config {
868 * Allocate a new configuration object
870 * This object is empty, so you have to add a file to it before you can do
873 * @param config the new configuration
875 [CCode (cname = "git_config_new")]
876 public static Error create (out Config config);
879 * Locate the path to the global configuration file
881 * The user or global configuration file is usually located in
882 * //$HOME/.gitconfig//.
884 * This method will try to guess the full path to that file, if the file
885 * exists. The returned path may be used on any call to load the global
886 * configuration file.
888 * @param config_path Buffer store the path
889 * @return {@link Error.OK} if a global configuration file has been found.
891 [CCode (cname = "git_config_find_global")]
892 public static Error find_global ([CCode (array_length_type = "size_t")] char[] config_path);
894 * Locate the path to the global xdg compatible configuration file
896 * The xdg compatible configuration file is usually located in
897 * //$HOME/.config/git/config//.
899 * This method will try to guess the full path to that file, if the file
901 * @param config_path Buffer store the path
902 * @return {@link Error.OK} if an XDG configuration file has been found.
904 [CCode (cname = "git_config_find_xdg")]
905 public static Error find_xdg ([CCode (array_length_type = "size_t")] char[] config_path);
908 * Locate the path to the system configuration file
910 * If /etc/gitconfig doesn't exist, it will look for
911 * %PROGRAMFILES%\Git\etc\gitconfig.
912 * @param config_path Buffer of {@link PATH_MAX} length to store the path
913 * @return {@link Error.OK} if a system configuration file has been found. Its path will be stored in //buffer//.
915 [CCode (cname = "git_config_find_system")]
916 public static Error find_system ([CCode (array_length_type = "size_t")] char[] config_path);
919 * Maps a string value to an integer constant
921 [CCode (cname = "git_config_lookup_map_value")]
922 public static Error lookup_map_value (out int result, [CCode (array_length_type = "size_t")] config_var_map[] map, string name);
925 * Create a new config instance containing a single on-disk file
927 * This method is a simple utility wrapper for the following sequence of
930 * * {@link add_filename}
932 * @param cfg the configuration instance to create
933 * @param path path to the on-disk file to open
935 [CCode (cname = "git_config_open_ondisk")]
936 public static Error open (out Config? cfg, string path);
939 * Open the global and system configuration files
941 * Utility wrapper that calls {@link find_global}, {@link find_xdg}, and
942 * {@link find_system} and opens the located file, if it exists.
944 * @param config where to store the config instance
946 [CCode (cname = "git_config_open_default")]
947 public static Error open_default (out Config? config);
950 * Build a single-level focused config object from a multi-level one.
952 * The returned config object can be used to perform get/set/delete
953 * operations on a single specific level.
955 * Getting several times the same level from the same parent multi-level
956 * config will return different config instances, but containing the same
957 * config_file instance.
959 * @param parent Multi-level config to search for the given level
960 * @param level Configuration level to search for
962 [CCode (cname = "git_config_open_level")]
963 public static Error open_level (out Config? config, Config parent, ConfigLevel level);
966 * Parse a string value as a bool.
968 * Valid values for true are: 'true', 'yes', 'on', 1 or any number
971 * Valid values for false are: 'false', 'no', 'off', 0
973 [CCode (cname = "git_config_parse_bool")]
974 public static Error bool(out bool result, string @value);
977 * Parse a string value as an int32.
979 * An optional value suffix of 'k', 'm', or 'g' will cause the value to be
980 * multiplied by 1024, 1048576, or 1073741824 prior to output.
982 [CCode (cname = "git_config_parse_int32")]
983 public static Error parse_int32 (out int32 result, string @value);
986 * Parse a string value as an int64.
988 * An optional value suffix of 'k', 'm', or 'g' will cause the value to be
989 * multiplied by 1024, 1048576, or 1073741824 prior to output.
991 [CCode (cname = "git_config_parse_int64")]
992 public static Error parse_int64 (out int64 result, string @value);
995 * Add an on-disk config file instance to an existing config
997 * The on-disk file pointed at by path will be opened and parsed; it's
998 * expected to be a native Git config file following the default Git config
999 * syntax (see man git-config).
1001 * Further queries on this config object will access each of the config
1002 * file instances in order (instances with a higher priority will be
1005 * @param path path to the configuration file (backend) to add
1006 * @param level the priority the backend should have
1008 [CCode (cname = "git_config_add_file_ondisk")]
1009 public Error add_filename (string path, ConfigLevel level, bool force);
1012 * Delete a config variable
1014 * @param name the variable to delete
1016 [CCode (cname = "git_config_delete_entry")]
1017 public Error delete (string name);
1020 * Perform an operation on each config variable.
1022 * The callback receives the normalized name and value of each variable in
1023 * the config backend. As soon as one of the callback functions returns
1024 * something other than 0, this function returns that value.
1026 * @param config_for_each the function to call on each variable
1028 [CCode (cname = "git_config_foreach")]
1029 public int for_each (ConfigForEach config_for_each);
1031 * Perform an operation on each config variable matching a regular expression.
1033 * This behaviors like {@link for_each} with an additional filter of a
1034 * regular expression that filters which config keys are passed to the
1037 * @param regexp regular expression to match against config names
1038 * @param config_for_each the function to call on each variable
1039 * @return 0 or the return value of the callback which didn't return 0
1041 [CCode (cname = "git_config_foreach_match")]
1042 public int for_each_match (string regexp, ConfigForEach config_for_each);
1045 * Get the value of a boolean config variable.
1047 * @param name the variable's name
1048 * @param value where the value should be stored
1050 [CCode (cname = "git_config_get_bool")]
1051 public Error get_bool (string name, out bool value);
1054 * Get the entry of a config variable.
1055 * @param name the variable's name
1057 [CCode (cname = "git_config_get_entry", instance_pos = 1.1)]
1058 public Error get_entry (out unowned config_entry? entry, string name);
1061 * Get the value of an integer config variable.
1063 * @param name the variable's name
1064 * @param value where the value should be stored
1066 [CCode (cname = "git_config_get_int")]
1067 public Error get_int32 (string name, out int32 value);
1070 * Get the value of a long integer config variable.
1072 * @param name the variable's name
1073 * @param value where the value should be stored
1075 [CCode (cname = "git_config_get_int64")]
1076 public Error get_int64 (string name, out int64 value);
1079 * Get each value of a multivar.
1081 * The callback will be called on each variable found
1083 * @param name the variable's name
1084 * @param regexp regular expression to filter which variables we're interested in. Use NULL to indicate all
1085 * @param fn the function to be called on each value of the variable
1087 [CCode (cname = "git_config_get_multivar")]
1088 public Error get_multivar (string name, string? regexp, Configuration.Setter fn);
1091 * Get the value of a string config variable.
1093 * @param name the variable's name
1094 * @param value the variable's value
1096 public Error get_string (string name, out unowned string value);
1099 * Open the global/XDG configuration file according to git's rules
1101 * Git allows you to store your global configuration at ''$HOME/.config''
1102 * or ''$XDG_CONFIG_HOME/git/config''. For backwards compatability, the XDG
1103 * file shouldn't be used unless the use has created it explicitly. With
1104 * this function you'll open the correct one to write to.
1106 * @param out pointer in which to store the config object
1107 * @param config the config object in which to look
1109 [CCode (cname = "git_config_open_global", instance_pos = 1.1)]
1110 public Error open_global (out Config? config);
1113 * Reload changed config files
1115 * A config file may be changed on disk out from under the in-memory config
1116 * object. This function causes us to look for files that have been
1117 * modified since we last loaded them and refresh the config with the
1118 * latest information.
1120 [CCode (cname = "git_config_refresh")]
1121 public Error refresh ();
1123 * Set the value of a boolean config variable.
1125 * @param name the variable's name
1126 * @param value the value to store
1128 [CCode (cname = "git_config_set_bool")]
1129 public Error set_bool (string name, bool value);
1132 * Set the value of an integer config variable.
1134 * @param name the variable's name
1135 * @param value integer value for the variable
1137 [CCode (cname = "git_config_set_int32")]
1138 public Error set_int32 (string name, int32 value);
1141 * Set the value of a long integer config variable.
1143 * @param name the variable's name
1144 * @param value Long integer value for the variable
1146 [CCode (cname = "git_config_set_long64")]
1147 public Error set_int64 (string name, int64 value);
1152 * @param name the variable's name
1153 * @param regexp a regular expression to indicate which values to replace
1154 * @param value the new value.
1156 [CCode (cname = "git_config_set_multivar")]
1157 public Error set_multivar (string name, string regexp, string @value);
1159 * Set the value of a string config variable.
1161 * A copy of the string is made and the user is free to use it
1164 * @param name the variable's name
1165 * @param value the string to store.
1167 [CCode (cname = "git_config_set_string")]
1168 public Error set_string (string name, string value);
1170 * Query the value of a config variable and return it mapped to an integer
1173 * This is a helper method to easily map different possible values to a
1174 * variable to integer constants that easily identify them.
1176 * A mapping array looks as follows:
1178 * var autocrlf_mapping = Git.config_var_map[] {
1179 * {Git.ConfigVar.FALSE, null, GIT_AUTO_CRLF_FALSE},
1180 * {Git.ConfigVar.TRUE, null, GIT_AUTO_CRLF_TRUE},
1181 * {Git.ConfigVar.STRING, "input", GIT_AUTO_CRLF_INPUT},
1182 * {Git.ConfigVar.STRING, "default", GIT_AUTO_CRLF_DEFAULT}};
1185 * On any "false" value for the variable (e.g. "false", "FALSE", "no"), the
1186 * mapping will store `GIT_AUTO_CRLF_FALSE` in the `out` parameter.
1188 * The same thing applies for any "true" value such as "true", "yes" or "1", storing
1189 * the `GIT_AUTO_CRLF_TRUE` variable.
1191 * Otherwise, if the value matches the string "input" (with case insensitive comparison),
1192 * the given constant will be stored in `out`, and likewise for "default".
1194 * If not a single match can be made to store in `out`, an error code will be
1197 * @param name name of the config variable to lookup
1198 * @param map array of objects specifying the possible mappings
1199 * @param result place to store the result of the mapping
1201 [CCode (cname = "git_config_get_mapped", instance_pos = 1.1)]
1202 public Error get_mapped (out int result, string name, [CCode (array_length_type = "size_t")] config_var_map[] map);
1205 * The diff list object that contains all individual file deltas.
1207 [CCode (cname = "git_diff_list", free_function = "git_diff_list_free")]
1209 public class DiffList {
1211 * How many diff records are there in a diff list.
1213 public size_t num_deltas {
1214 [CCode (cname = "git_diff_num_deltas")]
1218 * Query how many diff records are there in a diff list.
1219 * @param delta_t A delta type to filter the count, or -1 for all records
1220 * @return Count of number of deltas matching delta_t type
1222 [CCode (cname = "git_diff_num_deltas_of_type")]
1223 public size_t get_count (DeltaType delta_t = DeltaType.ALL);
1225 * Return the diff delta and patch for an entry in the diff list.
1227 * For an unchanged file or a binary file, no patch will be created, and
1228 * the {@link diff_delta.flags} will contain {@link DiffFlag.BINARY}.
1230 * @param patch contains the text diffs for the delta.
1231 * @param delta Output parameter for the delta object
1232 * @param idx Index into diff list
1234 [CCode (cname = "git_diff_get_patch", instance_pos = 2.1)]
1235 public Error get_patch (out Patch? patch, out unowned diff_delta? delta, size_t idx);
1237 * Merge one diff list into another.
1239 * This merges items from the "from" list into the current list. The
1240 * resulting diff list will have all items that appear in either list.
1241 * If an item appears in both lists, then it will be "merged" to appear
1242 * as if the old version was from the "onto" list and the new version
1243 * is from the "from" list (with the exception that if the item has a
1244 * pending DELETE in the middle, then it will show as deleted).
1246 * @param from Diff to merge.
1248 [CCode (cname = "git_diff_merge")]
1249 public Error merge (DiffList from);
1252 * Iterate over a diff list issuing callbacks.
1254 * If the hunk and/or line callbacks are not null, then this will calculate
1255 * text diffs for all files it thinks are not binary. If those are both
1256 * null, then this will not bother with the text diffs, so it can be
1259 [CCode (cname = "git_diff_foreach", simple_generics = true)]
1260 public Error foreach < T > (DiffFile<T>? file, DiffHunk<T> hunk, DiffLine<T>? line, T context);
1263 * Iterate over a diff generating text output like "git diff --name-status".
1265 [CCode (cname = "git_diff_print_compact")]
1266 public Error print_compact (DiffOutput print);
1269 * Iterate over a diff generating text output like "git diff".
1271 * This is a super easy way to generate a patch from a diff.
1273 [CCode (cname = "git_diff_print_patch")]
1274 public Error print_patch (DiffOutput print);
1277 * Iterate over a diff generating text output like "git diff --raw".
1280 [CCode (cname = "git_diff_print_raw")]
1281 public Error print_raw (DiffOutput print);
1284 * Transform a diff list marking file renames, copies, etc.
1286 * This modifies a diff list in place, replacing old entries that look like
1287 * renames or copies with new entries reflecting those changes. This also
1288 * will, if requested, break modified files into add/remove pairs if the
1289 * amount of change is above a threshold.
1291 * @param options Control how detection should be run, null for defaults
1293 [CCode (cname = "git_diff_find_similar")]
1294 public Error find_similar (find_options? options = null);
1297 [CCode (cname = "git_error", has_type_id = false, free_function = "")]
1298 public class ErrorInfo {
1300 * The explanation of the error.
1302 public string message;
1306 [CCode (cname = "klass")]
1307 public ErrClass @class;
1309 * Return a detailed error string with the latest error
1310 * that occurred in the library in this thread.
1312 [CCode (cname = "giterr_last")]
1313 public static unowned ErrorInfo? get_last ();
1316 * Clear the last library error for this thread.
1318 [CCode (cname = "giterr_clear")]
1319 public static void clear ();
1323 * Object ID Shortener object
1325 [CCode (cname = "git_oid_shorten", free_function = "git_oid_shorten_free", has_type_id = false)]
1327 public class IdShortener {
1329 * Create a new id shortener.
1331 * The id shortener is used to process a list of ids in text form and
1332 * return the shortest length that would uniquely identify all of them.
1334 * (e.g., look at the result of //git log --abbrev//)
1336 * @param min_length The minimal length for all identifiers, which will be used even if shorter ids would still be unique.
1338 [CCode (cname = "git_oid_shorten_new")]
1339 public IdShortener (size_t min_length);
1342 * Add a new id to set of shortened ids and calculate the minimal length to
1343 * uniquely identify all the ids in the set.
1345 * The id is expected to be a 40-char hexadecimal string.
1347 * For performance reasons, there is a hard-limit of how many ids can be
1348 * added to a single set (around ~22000, assuming a mostly randomized
1349 * distribution), which should be enough for any kind of program, and keeps
1350 * the algorithm fast and memory-efficient.
1352 * Attempting to add more than those ids will result in a {@link ErrClass.NOMEMORY} error
1354 * @param text_id an id in text form
1355 * @return the minimal length to uniquely identify all ids added so far to the set; or an error code (<0) if an error occurs.
1357 [CCode (cname = "git_oid_shorten_add")]
1358 public int add (string text_id);
1362 * Memory representation of an index file.
1364 [CCode (cname = "git_index", free_function = "git_index_free", has_type_id = false)]
1366 public class Index {
1368 * Index capabilities flags.
1370 public IndexCapability capability {
1371 [CCode (cname = "git_index_caps")]
1373 [CCode (cname = "git_index_set_caps")]
1378 * Does the index contains entries representing file conflicts?
1380 public bool has_conflicts {
1381 [CCode (cname = "git_index_has_conflicts")]
1385 public ReucIndex reuc {
1386 [CCode (cname = "")]
1391 * The repository this index relates to
1393 public Repository owner {
1394 [CCode (cname = "git_index_owner")]
1399 * The count of entries currently in the index
1402 [CCode (cname = "git_index_entrycount")]
1407 * Create an in-memory index object.
1409 * This index object cannot be read/written to the filesystem,
1410 * but may be used to perform in-memory index operations.
1412 * The index must be freed once it's no longer in use.
1414 [CCode (cname = "git_index_new")]
1415 public static Error create (out Index? index);
1417 * Create a new bare Git index object as a memory representation of the Git
1418 * index file in the index path, without a repository to back it.
1420 * Since there is no ODB or working directory behind this index, any index
1421 * methods which rely on these (e.g., {@link add}) will fail.
1423 * If you need to access the index of an actual repository, use {@link Repository.get_index}.
1425 * @param index where to put the new index
1426 * @param index_path the path to the index file in disk
1428 public static Error open (out Index index, string index_path);
1431 * Add or update an index entry from an in-memory struct
1433 * A full copy (including the path string) of the given source will be
1434 * inserted on the index.
1436 * @param entry new entry object
1438 [CCode (cname = "git_index_add")]
1439 public Error add (IndexEntry entry);
1442 * Add (append) an index entry from a file on disk
1444 * A new entry will always be inserted into the index; if the index already
1445 * contains an entry for such path, the old entry will ''not'' be replaced.
1447 * The file path must be relative to the repository's working folder and
1450 * This method will fail in bare index instances.
1452 * This forces the file to be added to the index, not looking at gitignore
1455 * If this file currently is the result of a merge conflict, this file will
1456 * no longer be marked as conflicting. The data about the conflict will be
1457 * moved to the "resolve undo" (REUC) section.
1459 * @param path filename to add
1461 [CCode (cname = "git_index_add_bypath")]
1462 public Error add_path (string path);
1465 * Clear the contents (all the entries) of an index object.
1467 * This clears the index object in memory; changes must be manually written
1468 * to disk for them to take effect.
1470 [CCode (cname = "git_index_clear")]
1471 public void clear ();
1474 * Add or update index entries to represent a conflict
1476 * The entries are the entries from the tree included in the merge. Any
1477 * entry may be null to indicate that that file was not present in the
1478 * trees during the merge. For example, the ancestor entry may be null to
1479 * indicate that a file was added in both branches and must be resolved.
1481 * @param ancestor_entry the entry data for the ancestor of the conflict
1482 * @param our_entry the entry data for our side of the merge conflict
1483 * @param their_entry the entry data for their side of the merge conflict
1485 [CCode (cname = "git_index_conflict_add")]
1486 public Error conflict_add (IndexEntry? ancestor_entry, IndexEntry? our_entry, IndexEntry? their_entry);
1489 * Get the index entries that represent a conflict of a single file.
1491 * The values of this entry can be modified (except the paths)
1492 * and the changes will be written back to disk on the next
1495 * @param ancestor Pointer to store the ancestor entry
1496 * @param our Pointer to store the our entry
1497 * @param their Pointer to store the their entry
1498 * @param path path to search
1500 [CCode (cname = "git_index_conflict_get", instance_pos = 3.1)]
1501 public Error conflict_get (out unowned IndexEntry? ancestor, out unowned IndexEntry? our, out unowned IndexEntry? their, string path);
1504 * Remove all conflicts in the index (entries with a stage greater than 0.)
1506 [CCode (cname = "git_index_conflict_cleanup")]
1507 public void conflict_cleanup ();
1509 * Removes the index entries that represent a conflict of a single file.
1511 * @param path to search
1513 [CCode (cname = "git_index_conflict_remove")]
1514 public Error conflict_remove (string path);
1517 * Find the first index of any entries which point to given path in the Git
1520 * @param at_pos the address to which the position of the reuc entry is written (optional)
1521 * @param path path to search
1523 [CCode (cname = "git_index_find", instance_pos = 1.1)]
1524 public Error find (out size_t at_pos, string path);
1527 * Get a pointer to one of the entries in the index
1529 * This entry can be modified, and the changes will be written back to disk
1530 * on the next {@link write} call.
1532 * @param n the position of the entry
1533 * @return the entry; null if out of bounds
1535 [CCode (cname = "git_index_get_byindex")]
1536 public unowned IndexEntry? get (size_t n);
1539 * Get a pointer to one of the entries in the index
1541 * The values of this entry can be modified (except the path) and the
1542 * changes will be written back to disk on the next {@link write} call.
1544 * @param path path to search
1545 * @param stage stage to search
1547 [CCode (cname = "git_index_get_bypath")]
1548 public unowned IndexEntry? get_by_path (string path, int stage);
1551 * Remove all entries with equal path except last added
1553 [CCode (cname = "git_index_uniq")]
1554 public void make_unique ();
1557 * Update the contents of an existing index object in memory by reading
1558 * from the hard disk.
1560 [CCode (cname = "git_index_read")]
1561 public Error read ();
1564 * Read a tree into the index file with stats
1566 * The current index contents will be replaced by the specified tree.
1568 * @param tree tree to read
1570 [CCode (cname = "git_index_read_tree")]
1571 public Error read_tree (Tree tree);
1574 * Remove an entry from the index
1576 [CCode (cname = "git_index_remove")]
1577 public Error remove (string path, int stage);
1579 * Remove all entries from the index under a given directory
1581 * @param dir container directory path
1582 * @param stage stage to search
1584 [CCode (cname = "git_index_remove_directory")]
1585 public Error remove_directory (string dir, int stage);
1588 * Remove an index entry corresponding to a file on disk
1590 * The file path must be relative to the repository's working folder. It
1593 * If this file currently is the result of a merge conflict, this file will
1594 * no longer be marked as conflicting. The data about the conflict will be
1595 * moved to the "resolve undo" (REUC) section.
1597 * @param path filename to remove
1599 [CCode (cname = "git_index_remove_bypath")]
1600 public Error remove_path (string path);
1603 * Write an existing index object from memory back to disk using an atomic
1606 [CCode (cname = "git_index_write")]
1607 public Error write ();
1610 * Write the index as a tree
1612 * This method will scan the index and write a representation of its
1613 * current state back to disk; it recursively creates
1614 * tree objects for each of the subtrees stored in the index, but only
1615 * returns the OID of the root tree. This is the OID that can be used e.g.
1616 * to create a commit.
1618 * The index instance cannot be bare, and needs to be associated to an
1619 * existing repository.
1621 * The index must not contain any file in conflict.
1623 [CCode (cname = "git_index_write_tree", instance_pos = -1)]
1624 public Error write_tree (out object_id id);
1627 * Write the index as a tree to the given repository
1629 * This method will do the same as {@link write_tree}, but letting the user
1630 * choose the repository where the tree will be written.
1632 * The index must not contain any file in conflict.
1634 * @param id Pointer where to store OID of the the written tree
1635 * @param repo Repository where to write the tree
1637 [CCode (cname = "git_index_write_tree_to", instance_pos = 1.1)]
1638 public Error write_tree_to (out object_id id, Repository repo);
1641 [CCode (cname = "git_indexer_stream", free_function = "git_indexer_stream_free", has_type_id = false)]
1642 public class IndexerStream {
1644 * The packfile's hash
1646 * A packfile's name is derived from the sorted hashing of all object
1647 * names. This is only correct after the index has been finalized.
1649 public object_id? hash {
1650 [CCode (cname = "git_indexer_stream_hash")]
1654 * Create a new streaming indexer instance
1656 * @param indexer_stream where to store the indexer instance
1657 * @param path to the directory where the packfile should be stored
1659 [CCode (cname = "git_indexer_stream_new")]
1660 public static Error open (out IndexerStream indexer_stream, string path, TransferProgress transfer);
1663 * Add data to the indexer
1665 * @param data the data to add
1666 * @param stats stat storage
1668 [CCode (cname = "git_indexer_stream_add")]
1669 public Error add ([CCode (array_length_type = "size_t")] uint8[] data, transfer_progress stats);
1672 * Finalize the pack and index
1674 * Resolve any pending deltas and write out the index file
1676 [CCode (cname = "git_indexer_stream_finalize")]
1677 public Error finalize (transfer_progress stats);
1681 * Memory representation of a file entry in the index.
1683 [CCode (cname = "git_index_entry", has_type_id = false)]
1685 public class IndexEntry {
1686 public Attributes flags;
1687 public index_time ctime;
1688 public index_time mtime;
1689 public int64 file_size;
1690 [CCode (cname = "oid")]
1691 public object_id id;
1693 public uint16 flags_extended;
1701 * The stage number from a git index entry
1704 [CCode (cname = "git_index_entry_stage")]
1709 * A note attached to an object
1711 [CCode (cname = "git_note", free_function = "git_note_free", has_type_id = false)]
1715 * The message for this note
1717 public string message {
1718 [CCode (cname = "git_note_message")]
1723 * The note object OID
1725 public object_id? id {
1726 [CCode (cname = "git_note_oid")]
1730 [CCode (cname = "git_note_iterator ", free_function = "git_note_iterator_free", has_type_id = false)]
1732 public class NoteIterator {
1734 * Returns the current item and advance the iterator internally to the next
1737 [CCode (cname = "git_note_next", instance_pos = -1)]
1738 public Error next (out object_id note_id, out object_id annotated_id);
1741 * Representation of a generic object in a repository
1743 [CCode (cname = "git_object", free_function = "git_object_free", has_type_id = false)]
1745 public class Object {
1747 * The id (SHA1) of a repository object
1749 public object_id? id {
1750 [CCode (cname = "git_object_id")]
1755 * The object type of an object
1757 public ObjectType type {
1758 [CCode (cname = "git_object_type")]
1763 * The repository that owns this object
1765 public Repository repository {
1766 [CCode (cname = "git_object_owner")]
1770 * Recursively peel an object until an object of the specified type is met
1772 * @param target_type The type of the requested object
1774 [CCode (cname = "git_object_peel", instance_pos = 1.1)]
1775 public Error peel (out Object? peeled, ObjectType target_type);
1779 [CCode (cname = "git_packbuilder", free_function = "git_packbuilder_free", has_type_id = false)]
1780 public class PackBuilder {
1783 * The total number of objects the packbuilder will write out
1785 public uint32 count {
1786 [CCode (cname = "packbuilder_object_count")]
1790 * The number of objects the packbuilder has already written out
1792 public uint32 written {
1793 [CCode (cname = "git_packbuilder_written")]
1798 * Set number of threads to spawn
1800 * By default, libgit2 won't spawn any threads at all; when set to 0,
1801 * libgit2 will autodetect the number of CPUs.
1803 * @param n Number of threads to spawn
1804 * @return number of actual threads to be used
1806 [CCode (cname = "git_packbuilder_set_threads")]
1807 public uint set_threads (uint n);
1810 * Insert a single object
1812 * For an optimal pack it's mandatory to insert objects in recency order,
1813 * commits followed by trees and blobs.
1815 * @param id The oid of the commit
1816 * @param name The name
1818 [CCode (cname = "git_packbuilder_insert")]
1819 public Error insert (object_id id, string? name);
1821 * Insert a root tree object
1823 * This will add the tree as well as all referenced trees and blobs.
1825 * @param id The oid of the root tree
1827 [CCode (cname = "git_packbuilder_insert_tree")]
1828 public Error insert_tree (object_id id);
1831 * Write the new pack and the corresponding index to path
1833 * @param path Directory to store the new pack and index
1835 [CCode (cname = "git_packbuilder_write")]
1836 public Error write (string path);
1839 * Create the new pack and pass each object to the callback
1841 [CCode (cname = "git_packbuilder_foreach")]
1842 public Error for_each (PackBuilderForEach pack_builder_for_each);
1845 * The list of parents of a commit
1848 [CCode (cname = "git_commit", has_type_id = false)]
1849 public class Parents {
1851 * Get the number of parents of this commit
1854 [CCode (cname = "git_commit_parentcount")]
1859 * Get the id of a specified parent for a commit.
1861 * This is different from {@link Parents.lookup}, which will attempt
1862 * to load the parent commit from the ODB.
1864 * @param n the position of the parent
1865 * @return the id of the parent, null on error.
1867 [CCode (cname = "git_commit_parent_id")]
1868 public unowned object_id? get (uint n);
1871 * Get the specified parent of the commit.
1873 * @param parent where to store the parent commit
1874 * @param n the position of the parent
1876 [CCode (cname = "git_commit_parent", instance_pos = 1.2)]
1877 public Error lookup (out Commit parent, uint n);
1879 [CCode (cname = "git_diff_patch ", free_function = "git_diff_patch_free", has_type_id = false)]
1881 public class Patch {
1883 * The delta associated with a patch
1885 public diff_delta? delta {
1886 [CCode (cname = "git_diff_patch_delta")]
1890 * The number of hunks in a patch
1892 public size_t num_hunks {
1893 [CCode (cname = "git_diff_patch_num_hunks")]
1897 * Get the information about a hunk in a patch
1899 * Given a patch and a hunk index into the patch, this returns detailed
1900 * information about that hunk. Any of the output pointers can be passed
1901 * as NULL if you don't care about that particular piece of information.
1903 * @param range Range of the hunk
1904 * @param header Header string for hunk. Unlike the content for each line,
1905 * this will be NUL-terminated
1906 * @param lines_in_hunk Count of total lines in this hunk
1907 * @param hunk_idx Input index of hunk to get information about
1909 [CCode (cname = "git_diff_patch_get_hunk", instance_pos = 3.1)]
1910 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);
1912 * Get data about a line in a hunk of a patch.
1914 * Given a patch, a hunk index, and a line index in the hunk, this will
1915 * return a lot of details about that line. If you pass a hunk index
1916 * larger than the number of hunks or a line index larger than the number
1917 * of lines in the hunk, this will return -1.
1919 * @param old_lineno Line number in old file or -1 if line is added
1920 * @param new_lineno Line number in new file or -1 if line is deleted
1921 * @param hunk_idx The index of the hunk
1922 * @param line_of_hunk The index of the line in the hunk
1924 [CCode (cname = "git_diff_patch_get_line_in_hunk", instance_pos = 4.1)]
1925 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);
1927 * Get line counts of each type in a patch.
1929 * This helps imitate a '''diff --numstat''' type of output. For that
1930 * purpose, you only need the total additions and total_deletions values,
1931 * but we include the total context line count in case you want the total
1932 * number of lines of diff output that will be generated.
1934 * @param total_context Count of context lines in output.
1935 * @param total_additions Count of addition lines in output.
1936 * @param total_deletions Count of deletion lines in output.
1937 * @return Number of lines in hunk or -1 if invalid hunk index
1939 [CCode (cname = "git_diff_patch_line_stats", instance_pos = -1)]
1940 public int get_line_stats (out size_t total_context, out size_t total_additions, out size_t total_deletions);
1943 * Get the number of lines in a hunk.
1945 * @param hunk_idx Index of the hunk
1946 * @return Number of lines in hunk or -1 if invalid hunk index
1948 [CCode (cname = "git_diff_patch_num_lines_in_hunk")]
1949 public int num_lines_in_hunk (size_t hunk_idx);
1952 * Serialize the patch to text via callback.
1954 [CCode (cname = "git_diff_patch_print")]
1955 public Error patch_print (DiffOutput print);
1958 * Get the content of a patch as a single diff text.
1960 [CCode (cname = "git_diff_patch_to_str", instance_pos = -1)]
1961 public Error to_str (out string str);
1963 public string? to_string () {
1965 return to_str (out str) == Error.OK ? str : null;
1969 [CCode (cname = "git_push", free_function = "git_push_free", has_type_id = false)]
1972 * Check if remote side successfully unpacked
1974 public bool unpack_ok {
1975 [CCode (cname = "git_push_unpack_ok")]
1980 * Add a refspec to be pushed
1982 [CCode (cname = "git_push_add_refspec")]
1983 public Error add_refspec (string refspec);
1986 * Actually push all given refspecs
1988 * To check if the push was successful (i.e. all remote references have
1989 * been updated as requested), you need to call both {@link unpack_ok} and
1990 * {@link for_each}. The remote repository might have refused to update
1991 * some or all of the references.
1993 [CCode (cname = "git_push_finish")]
1994 public Error finish ();
1996 * Iterate over each status.
1998 * For each of the updated references, we receive a status report in the
1999 * form of '''ok refs/heads/master''' or '''ng refs/heads/master ///msg///'''.
2000 * If the message is not null, this means the reference has not been
2001 * updated for the given reason.
2004 [CCode (cname = "git_push_status_foreach")]
2005 public Error for_each (PushForEach push_for_each);
2007 * Set options on a push object
2009 * @param opts The options to set on the push object
2011 [CCode (cname = "git_push_set_options")]
2012 public Error set_options (push_options opts);
2014 * Update remote tips after a push
2016 [CCode (cname = "git_push_update_tips")]
2017 public Error update_tips ();
2019 [CCode (cname = "git_refdb", has_type_id = false, free_function = "git_refdb_free")]
2020 public class RefDb {
2022 * Suggests that the given refdb compress or optimize its references.
2024 * This mechanism is implementation specific. For on-disk reference
2025 * databases, for example, this may pack all loose references.
2027 [CCode (cname = "git_refdb_compress")]
2028 public Error compress ();
2031 * Sets the custom backend to an existing reference DB
2033 [CCode (cname = "git_refdb_set_backend")]
2034 public Error set_backend (owned refdb_backend backend);
2037 * In-memory representation of a reference.
2039 [CCode (cname = "git_reference", free_function = "git_reference_free", has_type_id = false)]
2041 public class Reference {
2043 * Check if a reflog exists for the specified reference.
2045 public bool has_log {
2046 [CCode (cname = "git_reference_has_log")]
2050 * Check if a reference is a local branch.
2052 public bool is_branch {
2053 [CCode (cname = "git_reference_is_branch")]
2058 * Determine if the current local branch is pointed at by HEAD.
2060 public bool is_head {
2061 [CCode (cname = "0 != git_branch_is_head")]
2066 * If a reference is a remote tracking branch
2068 public bool is_remote {
2069 [CCode (cname = "git_reference_is_remote")]
2074 * The full name of a reference
2076 public string name {
2077 [CCode (cname = "git_reference_name")]
2082 * The repository where a reference resides
2084 public Repository repository {
2085 [CCode (cname = "git_reference_owner")]
2090 * The full name to the reference pointed by this reference
2092 * Only available if the reference is symbolic
2094 public string? symbolic_target {
2095 [CCode (cname = "git_reference_symbolic_target")]
2100 * The id pointed to by a reference.
2102 * Only available if the reference is direct (i.e., not symbolic)
2104 public object_id? target {
2105 [CCode (cname = "git_reference_target")]
2110 * The type of a reference
2112 * Either direct, {@link ReferenceType.ID}, or symbolic, {@link ReferenceType.SYMBOLIC}
2114 public ReferenceType type {
2115 [CCode (cname = "git_reference_type")]
2119 * Create a new direct reference from an OID.
2121 * @param name the reference name
2122 * @param oid the object id for a direct reference
2123 * @param symbolic the target for a symbolic reference
2125 [CCode (cname = "git_reference__alloc")]
2126 public static Reference? alloc (string name, object_id id, object_id peel);
2129 * Create a new symbolic reference.
2131 * @param name the reference name
2132 * @param symbolic the target for a symbolic reference
2134 [CCode (cname = "git_reference__alloc_symbolic")]
2135 public static Reference? alloc_symbolic (string name, string target);
2137 * Ensure the reference name is well-formed.
2139 * Valid reference names must follow one of two patterns:
2141 * 1. Top-level names must contain only capital letters and underscores,
2142 * and must begin and end with a letter. (e.g. "HEAD", "ORIG_HEAD").
2143 * 2. Names prefixed with "refs/" can be almost anything. You must avoid
2144 * the characters '~', '^', ':', '\\', '?', '[', and '*', and the
2145 * sequences ".." and "@{" which have special meaning to revparse.
2147 [CCode (cname = "git_reference_is_valid_name")]
2148 public static bool is_valid_name (string refname);
2151 * Delete an existing branch reference.
2153 [CCode (cname = "git_branch_delete")]
2154 public static Error delete_branch (owned Reference reference);
2157 * Normalize the reference name by removing any leading slash (/)
2158 * characters and collapsing runs of adjacent slashes between name
2159 * components into a single slash.
2161 * Once normalized, if the reference name is valid, it will be returned in
2162 * the user allocated buffer.
2164 * @param buffer The buffer where the normalized name will be stored.
2165 * @param name name to be checked.
2166 * @param flags Flags to determine the options to be applied while checking
2167 * the validatity of the name.
2169 [CCode (cname = "git_reference_normalize_name")]
2170 public static Error normalize_name ([CCode (array_length_type = "size_t")] uint8[] buffer, string name, ReferenceFormat flags);
2173 * Compare two references.
2175 * @return 0 if the same, else a stable but meaningless ordering.
2177 [CCode (cname = "git_reference_cmp")]
2178 public int compare (Reference other);
2181 * Delete an existing reference
2183 * This method works for both direct and symbolic references.
2185 * The reference will be immediately removed on disk.
2187 [CCode (cname = "git_reference_delete")]
2188 public void @delete ();
2191 * Delete the reflog for the given reference
2193 [CCode (cname = "git_reflog_delete")]
2194 public Error delete_reflog ();
2197 * Return the name of the given local or remote branch.
2199 * The name of the branch matches the definition of the name for
2200 * {@link Repository.lookup_branch}. That is, if the returned name is
2201 * looked up then the reference is returned that was given to this
2204 * @param name where the pointer of branch name is stored;
2205 * this is valid as long as the ref is not freed.
2207 [CCode (cname = "git_branch_name", instance_pos = -1)]
2208 public Error get_branch_name (out unowned string name);
2211 * Read the reflog for the given reference
2213 * @param reflog where to put the reflog
2215 [CCode (cname = "git_reflog_read", instance_pos = -1)]
2216 public Error get_reflog (out ReferenceLog? reflog);
2218 * Return the reference supporting the remote tracking branch, given a
2221 * The input reference has to be located in the '''refs/heads''' namespace.
2224 [CCode (cname = "git_reference_remote_tracking_from_branch", instance_pos = -1)]
2225 public Error get_remote_tracking_from_branch (out Reference tracking_ref);
2227 * Return the reference supporting the remote tracking branch, given a
2228 * local branch reference.
2230 [CCode (cname = "git_branch_upstream", instance_pos = -1)]
2231 public Error get_upstream (out Reference? tracking);
2234 * Move/rename an existing branch reference.
2236 * @param new_branch_name Target name of the branch once the move
2237 * is performed; this name is validated for consistency.
2239 * @param force Overwrite existing branch.
2241 [CCode (cname = "git_branch_move", instance_pos = 1.1)]
2242 public Error move_branch (out Reference? moved, string new_branch_name, bool force);
2245 * Recursively peel an reference until an object of the specified type is
2248 * If you pass {@link ObjectType.ANY} as the target type, then the object
2249 * will be peeled until a non-tag object is met.
2251 * @param target_type The type of the requested object
2253 [CCode (cname = "git_reference_peel", instance_pos = 1.1)]
2254 public Error peel (out Object? peeled, ObjectType target_type);
2257 * Rename an existing reference
2259 * This method works for both direct and symbolic references.
2260 * The new name will be checked for validity and may be
2261 * modified into a normalized form.
2263 * The refernece will be immediately renamed in-memory
2266 * ''IMPORTANT:'' The user needs to write a proper reflog entry if the
2267 * reflog is enabled for the repository. We only rename the reflog if it
2271 [CCode (cname = "git_reference_rename", instance_pos = 1.1)]
2272 public Error rename (out Reference? renamed_reference, string new_name, bool force);
2275 * Resolve a symbolic reference
2277 * Thie method iteratively peels a symbolic reference
2278 * until it resolves to a direct reference to an id.
2280 * If a direct reference is passed as an argument,
2281 * that reference is returned immediately
2283 * @param resolved the peeled reference
2285 [CCode (cname = "git_reference_resolve", instance_pos = -1)]
2286 public Error resolve (out Reference resolved);
2289 * Create a new reference with the same name as the given reference but a
2290 * different symbolic target.
2292 * The reference must be a symbolic reference, otherwise this will fail.
2294 * The new reference will be written to disk, overwriting the given
2297 * @param id the new target id for the reference
2299 [CCode (cname = "git_reference_set_oid", instance_pos = 1.1)]
2300 public Error set_target (out Reference? retargeted, object_id id);
2303 * Set the symbolic target of a reference.
2305 * The reference must be a symbolic reference, otherwise this method will
2308 * The reference will be automatically updated in memory and on disk.
2310 * @param target The new target for the reference
2312 [CCode (cname = "git_reference_symbolic_set_target")]
2313 public Error set_symbolic_target (string target);
2316 * Set the upstream configuration for a given local branch
2318 * @param branch the branch to configure
2320 * @param upstream_name remote-tracking or local branch to set as
2321 * upstream. Pass null to unset.
2323 [CCode (cname = "git_branch_set_upstream")]
2324 public Error set_upstream (string? upstream_name);
2328 * Representation of a reference log
2330 [CCode (cname = "git_reflog", free_function = "git_reflog_free", has_type_id = false)]
2332 public class ReferenceLog {
2334 * The number of log entries in a reflog
2336 public size_t size {
2337 [CCode (cname = "git_reflog_entrycount")]
2342 * Add a new entry to the reflog.
2344 * If there is no reflog file for the given reference yet, it will be
2347 * @param id the id the reference is now pointing to
2348 * @param committer the signature of the committer
2349 * @param msg the reflog message
2351 [CCode (cname = "git_reflog_append")]
2352 public Error append (out object_id id, Signature committer, string? msg = null);
2355 * Remove an entry from the reflog by its index
2357 * To ensure there's no gap in the log history, when deleting an entry,
2358 * member old_oid of the previous entry (if any) will be updated with the
2359 * value of memeber new_oid of next entry.
2361 * @param idx the position of the entry to remove.
2363 * @param rewrite_previous_entry true to rewrite the history; 0 otherwise.
2366 [CCode (cname = "git_reflog_drop")]
2367 public Error drop (size_t idx, bool rewrite_previous_entry);
2370 * Lookup an entry by its index
2372 * @param idx the position to lookup
2373 * @return the entry; null if not found
2375 [CCode (cname = "git_reflog_entry_byindex")]
2376 public unowned ReferenceLogEntry? get (size_t idx);
2379 * Rename the reflog for the given reference
2381 * @param new_name the new name of the reference
2383 [CCode (cname = "git_reflog_rename")]
2384 public Error rename (string new_name);
2386 * Write an existing in-memory reflog object back to disk using an atomic
2389 * If there is no reflog file for the given reference yet, it will be
2392 [CCode (cname = "git_reflog_write")]
2393 public Error write ();
2397 * Representation of a reference log entry
2399 [CCode (cname = "git_reflog_entry", has_type_id = false)]
2401 public class ReferenceLogEntry {
2404 * The committer of this entry
2406 public Signature commiter {
2407 [CCode (cname = "git_reflog_entry_committer")]
2414 public string message {
2415 [CCode (cname = "git_reflog_entry_msg")]
2420 * The new id at this time
2422 public object_id? new_id {
2423 [CCode (cname = "git_reflog_entry_id_new")]
2430 public object_id? old_id {
2431 [CCode (cname = "git_reflog_entry_id_old")]
2437 * Reference to a remote repository
2439 [CCode (cname = "git_remote", free_function = "git_remote_free", has_type_id = false)]
2441 public class Remote {
2442 [CCode (cname = "git_remote_rename_problem_cb")]
2443 public delegate bool RenameProblem (string problematic_refspec);
2445 * The tag auto-follow setting
2447 public AutoTag autotag {
2448 [CCode (cname = "git_remote_autotag")]
2450 [CCode (cname = "git_remote_set_autotag")]
2455 * Choose whether to check the server's certificate (applies to HTTPS only)
2457 public bool check_cert {
2458 [CCode (cname = "git_remote_check_cert")]
2463 * Whether the remote is connected
2465 * Whether the remote's underlying transport is connected to the remote
2468 public bool is_connected {
2469 [CCode (cname = "git_remote_connected")]
2474 * The fetch refspec, if it exists
2476 public ref_spec? fetch_spec {
2477 [CCode (cname = "git_remote_fetchspec")]
2479 [CCode (cname = "git_remote_set_fetchspec")]
2486 public string? name {
2487 [CCode (cname = "git_remote_name")]
2492 * The push refspec, if it existsc
2494 public ref_spec? push_spec {
2495 [CCode (cname = "git_remote_pushspec")]
2497 [CCode (cname = "git_remote_set_pushspec")]
2502 * The statistics structure that is filled in by the fetch operation.
2504 public transfer_progress stats {
2505 [CCode (cname = "git_remote_stats")]
2510 * Update FETCH_HEAD on ever fetch.
2512 public bool update_fetchhead {
2513 [CCode (cname = "git_remote_update_fetchhead")]
2515 [CCode (cname = "git_remote_set_update_fetchhead")]
2522 [CCode (cname = "git_remote_url")]
2527 * Ensure the remote name is well-formed.
2529 * @param remote_name name to be checked.
2531 [CCode (cname = "git_remote_is_valid_name")]
2532 public static bool is_valid_name (string remote_name);
2535 * Return whether a string is a valid remote URL
2537 * @param url the url to check
2539 [CCode (cname = "git_remote_valid_url")]
2540 public static bool is_valid_url (string url);
2543 * Return whether the passed URL is supported by this version of the library.
2545 * @param url the url to check
2547 [CCode (cname = "git_remote_supported_url")]
2548 public static bool is_supported_url (string url);
2550 * Create a new push object
2552 [CCode (cname = "git_push_new", instance_pos = -1)]
2553 public Error create_push (out Push? push);
2556 * Open a connection to a remote
2558 * The transport is selected based on the URL. The direction argument is
2559 * due to a limitation of the git protocol (over TCP or SSH) which starts
2560 * up a specific binary which can only do the one or the other.
2562 * @param direction whether you want to receive or send data
2564 [CCode (cname = "git_remote_connect")]
2565 public Error connect (Direction direction);
2568 * Download the packfile
2570 * Negotiate what objects should be downloaded and download the packfile
2571 * with those objects.
2573 [CCode (cname = "git_remote_download")]
2574 public Error download (Progress progress);
2577 * Disconnect from the remote
2579 * Close the connection to the remote and free the underlying transport.
2581 [CCode (cname = "git_remote_disconnect")]
2582 public void disconnect ();
2585 * Get a list of refs at the remote
2587 * The remote (or more exactly its transport) must be connected.
2589 [CCode (cname = "git_remote_ls", instance_pos = -1)]
2590 public Error list (Head headcb);
2593 * Give the remote a new name
2595 * All remote-tracking branches and configuration settings for the remote
2598 * The new name will be checked for validity.
2600 * A temporary in-memory remote cannot be given a name with this method.
2602 * @param new_name the new name the remote should bear
2603 * @param rename_problem Optional callback to notify the consumer of fetch refspecs
2604 * that haven't been automatically updated and need potential manual tweaking.
2605 * @see Repository.create_tag
2607 [CCode (cname = "git_remote_rename")]
2608 public Error rename (string new_name, RenameProblem? rename_problem = null);
2610 * Save a remote to its repository's configuration
2612 * One can't save a in-memory remote. Doing so will result in a
2613 * {@link Error.INVALIDSPEC} being returned.
2615 [CCode (cname = "git_remote_save")]
2616 public Error save ();
2618 * Set the callbacks for a remote
2620 [CCode (cname = "git_remote_set_callbacks", simple_generics = true)]
2621 public Error set_callbacks<T> (remote_callbacks<T> callbacks);
2624 * Sets the owning repository for the remote. This is only allowed on
2627 [CCode (cname = "git_remote_set_repository")]
2628 public Error set_repository (Repository repo);
2631 * Sets a credentials acquisition callback for this remote.
2633 * If the remote is not available for anonymous access, then you must set
2634 * this callback in order to provide credentials to the transport at the
2635 * time of authentication failure so that retry can be performed.
2637 [CCode (cname = "git_remote_set_cred_acquire_cb")]
2638 public void set_cred_acquire (CredAcquire? cred_acquire);
2641 * Sets a custom transport for the remote. The caller can use this function
2642 * to bypass the automatic discovery of a transport by URL scheme (i.e.,
2643 * http, https, git) and supply their own transport to be used
2644 * instead. After providing the transport to a remote using this function,
2645 * the transport object belongs exclusively to that remote, and the remote will
2646 * free it when it is freed with git_remote_free.
2648 * @param transport the transport object for the remote to use
2650 [CCode (cname = "git_remote_set_transport")]
2651 public Error set_transport (transport transport);
2654 * Cancel the operation
2656 * At certain points in its operation, the network code checks whether the
2657 * operation has been cancelled and if so stops the operation.
2659 [CCode (cname = "git_remote_stop")]
2660 public void stop ();
2663 * Update the tips to the new state
2665 * Make sure that you only call this once you've successfully indexed or
2666 * expanded the packfile.
2668 [CCode (cname = "git_remote_update_tips")]
2669 public Error update_tips (Update update);
2673 * Representation of an existing git repository,
2674 * including all its object contents
2676 [CCode (cname = "git_repository", free_function = "git_repository_free", has_type_id = false)]
2678 public class Repository {
2679 public Attr attributes {
2680 [CCode (cname = "")]
2684 * Check if a repository is bare
2686 public bool is_bare {
2687 [CCode (cname = "git_repository_is_bare")]
2691 * Check if a repository's HEAD is detached
2693 * A repository's HEAD is detached when it points directly to a commit
2694 * instead of a branch.
2696 public bool is_head_detached {
2697 [CCode (cname = "git_repository_head_detached")]
2702 * Check if the current branch is an orphan
2704 * An orphan branch is one named from HEAD but which doesn't exist in
2705 * the refs namespace, because it doesn't have any commit to point to.
2707 public bool is_head_orphan {
2708 [CCode (cname = "git_repository_head_orphan")]
2713 * Check if a repository is empty
2715 * An empty repository has just been initialized and contains no commits.
2717 public bool is_empty {
2718 [CCode (cname = "git_repository_is_empty")]
2723 * The path to the repository.
2725 public string? path {
2726 [CCode (cname = "git_repository_path")]
2730 * Determines the status of a git repository (i.e., whether an operation
2731 * such as a merge or cherry-pick is in progress).
2733 public State state {
2734 [CCode (cname = "git_repository_state")]
2739 * The working directory for this repository
2741 * If the repository is bare, this is null.
2743 * If this repository is bare, setting its working directory will turn it
2744 * into a normal repository, capable of performing all the common workdir
2745 * operations (checkout, status, index manipulation, etc).
2747 public string? workdir {
2748 [CCode (cname = "git_repository_workdir")]
2753 * Clone a remote repository, and checkout the branch pointed to by the remote
2756 * @param origin_url repository to clone from
2757 * @param dest_path local directory to clone to
2758 * @param clone_opts configuration options for the clone.
2760 [CCode (cname = "git_clone")]
2761 public static Error clone (out Repository? repo, string origin_url, string dest_path, clone_opts? clone_opts = null);
2764 * Look for a git repository and copy its path in the given buffer. The lookup start
2765 * from base_path and walk across parent directories if nothing has been found. The
2766 * lookup ends when the first repository is found, or when reaching a directory
2767 * referenced in ceiling_dirs or when the filesystem changes (in case across_fs
2770 * The method will automatically detect if the repository is bare (if there is
2773 * @param repository_path The buffer which will contain the found path.
2775 * @param start_path The base path where the lookup starts.
2777 * @param across_fs If true, then the lookup will not stop when a filesystem device change
2778 * is detected while exploring parent directories.
2780 * @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.
2782 public static Error discover ([CCode (array_length_type = "size_t")] char[] repository_path, string start_path, bool across_fs = true, string? ceiling_dirs = null);
2785 * Creates a new Git repository in the given folder.
2787 * @param repo the repo which will be created or reinitialized
2788 * @param path the path to the repository
2789 * @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.
2791 [CCode (cname = "git_repository_init")]
2792 public static Error init (out Repository repo, string path, bool is_bare);
2794 * Create a new Git repository in the given folder with extended controls.
2796 * This will initialize a new git repository (creating the path if
2797 * requested by flags) and working directory as needed. It will
2798 * auto-detect the case sensitivity of the file system and if the file
2799 * system supports file mode bits correctly.
2801 * @param repo_path The path to the repository.
2802 * @param opts Pointer to git_repository_init_options struct.
2804 [CCode (cname = "git_repository_init_ext")]
2805 public static Error init_ext (out Repository? repo, string repo_path, init_options opts);
2808 * Create a new repository with neither backends nor config object
2810 * Note that this is only useful if you wish to associate the repository
2811 * with a non-filesystem-backed object database and config store.
2813 [CCode (cname = "git_repository_new")]
2814 public static Error @new (out Repository? repo);
2816 * Open a git repository.
2818 * The path argument must point to an existing git repository
2819 * folder. The repository can be normal (having a //.git// directory)
2820 * or bare (having objects, index, and HEAD directly).
2821 * The method will automatically detect if path is a normal
2822 * or bare repository or fail is path is neither.
2824 * @param repository the repo which will be opened
2825 * @param path the path to the repository
2827 [CCode (cname = "git_repository_open")]
2828 public static Error open (out Repository? repository, string path);
2831 * Open a bare repository on the serverside.
2833 * This is a fast open for bare repositories that will come in handy if
2834 * you're hosting git repositories and need to access them efficiently.
2836 * @param bare_path Direct path to the bare repository
2838 [CCode (cname = "git_repository_open_bare")]
2839 public static Error open_bare (out Repository? repository, string bare_path);
2842 * Find and open a repository with extended controls.
2844 [CCode (cname = "git_repository_open_ext")]
2845 public static Error open_ext (out Repository? repository, string start_path, OpenFlags flags, string ceiling_dirs);
2847 * Add ignore rules for a repository.
2849 * Excludesfile rules (i.e. .gitignore rules) are generally read from
2850 * .gitignore files in the repository tree or from a shared system file
2851 * only if a "core.excludesfile" config value is set. The library also
2852 * keeps a set of per-repository internal ignores that can be configured
2853 * in-memory and will not persist. This function allows you to add to
2854 * that internal rules list.
2856 * @param rules Text of rules, a la the contents of a .gitignore file. It
2857 * is okay to have multiple rules in the text; if so, each rule should be
2858 * terminated with a newline.
2860 [CCode (cname = "git_ignore_add_rule")]
2861 public Error add_ignore (string rules);
2863 * Set up a new git submodule for checkout.
2865 * This does '''git submodule add''' up to the fetch and checkout of the
2866 * submodule contents. It preps a new submodule, creates an entry in
2867 * .gitmodules and creates an empty initialized repository either at the
2868 * given path in the working directory or in .git/modules with a gitlink
2869 * from the working directory to the new repo.
2871 * To fully emulate '''git submodule add''' call this function, then open
2872 * the submodule repo and perform the clone step as needed. Lastly, call
2873 * {@link Submodule.add_finalize} to wrap up adding the new submodule and
2874 * .gitmodules to the index to be ready to commit.
2876 * @param submodule The newly created submodule ready to open for clone
2877 * @param url URL for the submodules remote
2878 * @param path Path at which the submodule should be created
2879 * @param use_gitlink Should workdir contain a gitlink to the repo in
2880 * .git/modules vs. repo directly in workdir.
2882 [CCode (cname = "git_submodule_add_setup", instance_pos = 1.1)]
2883 public Error add_submodule_setup (out Submodule? submodule, string url, string path, bool use_gitlink);
2886 * Remove all the metadata associated with an ongoing git merge, including
2887 * MERGE_HEAD, MERGE_MSG, etc.
2889 [CCode (cname = "git_repository_merge_cleanup")]
2890 public Error cleanup_merge ();
2893 * Clear ignore rules that were explicitly added.
2895 * Resets to the default internal ignore rules. This will not turn off
2896 * rules in .gitignore files that actually exist in the filesystem.
2898 * The default internal ignores ignore '''.''', '''..''' and '''.git''' entries.
2900 public Error clear_internal_ignores ();
2903 * Updates files in the index and the working tree to match the commit pointed to by HEAD.
2905 * @param opts specifies checkout options
2907 [CCode (cname = "git_checkout_head")]
2908 public Error checkout_head (checkout_opts? opts = null);
2910 * Updates files in the working tree to match the content of the index.
2912 * @param opts specifies checkout options
2913 * @param index index to be checked out (or null to use repository index)
2915 [CCode (cname = "git_checkout_index")]
2916 public Error checkout_index (Index? index = null, checkout_opts? opts = null);
2918 * Updates files in the index and working tree to match the content of a
2921 * @param treeish a commit, tag or tree which content will be used to
2922 * update the working directory
2923 * @param opts specifies checkout options
2925 [CCode (cname = "git_checkout_tree")]
2926 public Error checkout_tree (Object treeish, checkout_opts? opts = null);
2928 * Count the number of unique commits between two commit objects
2930 * There is no need for branches containing the commits to have any
2931 * upstream relationship, but it helps to think of one as a branch and the
2932 * other as its upstream, the ahead and behind values will be what git
2933 * would report for the branches.
2935 * @param ahead number of unique commits in upstream
2936 * @param behind number of unique commits in local
2937 * @param local one of the commits
2938 * @param upstream the other commit
2940 [CCode (cname = "git_graph_ahead_behind", instance_pos = 2.1)]
2941 public Error count_ahead_behind (out size_t ahead, out size_t behind, object_id local, object_id upstream);
2943 * Write an in-memory buffer to the ODB as a blob
2945 * @param id return the id of the written blob
2946 * @param buffer data to be written into the blob
2948 [CCode (cname = "git_blob_create_frombuffer", instance_pos = 1.2)]
2949 public Error create_blob_from_buffer (object_id id, [CCode (array_length_type = "size_t")] uint8[] buffer);
2951 * Write a loose blob to the Object Database from a provider of chunks of
2954 * @param id Return the id of the written blob
2955 * @param hint_path will help to determine what git filters should be
2956 * applied to the object before it can be placed to the object database.
2958 [CCode (cname = "git_blob_create_fromchunks", instance_pos = 1.2)]
2959 public Error create_blob_from_chunks (object_id id, string? hint_path, ChunkSource source);
2962 * Read a file from the filesystem and write its content to the Object
2963 * Database as a loose blob
2965 * @param id return the id of the written blob
2966 * @param path file from which the blob will be created
2968 [CCode (cname = "git_blob_create_fromdisk", instance_pos = 1.2)]
2969 public Error create_blob_from_disk (out object_id id, string path);
2972 * Read a file from the working folder of a repository
2973 * and write it to the object database as a loose blob
2975 * This repository cannot be bare.
2977 * @param id return the id of the written blob
2978 * @param path file from which the blob will be created, relative to the repository's working dir
2980 [CCode (cname = "git_blob_create_fromworkdir", instance_pos = 1.2)]
2981 public Error create_blob_from_file (object_id id, string path);
2984 * Create a new branch pointing at a target commit
2986 * A new direct reference will be created pointing to this target commit.
2987 * If forced and a reference already exists with the given name, it'll be
2990 * @param branch_name Name for the branch; this name is
2991 * validated for consistency. It should also not conflict with
2992 * an already existing branch name.
2994 * @param target Object to which this branch should point. This object must
2995 * belong to the given repository and can either be a commit or a tag. When
2996 * a tag is being passed, it should be dereferencable to a commit which oid
2997 * will be used as the target of the branch.
2999 * @param force Overwrite existing branch.
3001 [CCode (cname = "git_branch_create", instance_pos = 1.2)]
3002 public Error create_branch (out Reference? branch, string branch_name, Commit target, bool force = false);
3005 * Create a new commit in the repository using {@link Object}
3006 * instances as parameters.
3008 * The message will not be cleaned up.
3010 * @param id the id of the newly created commit
3012 * @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.
3013 * @param author Signature representing the author and the author time of this commit
3014 * @param committer Signature representing the committer and the commit time of this commit
3015 * @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.
3016 * @param message Full message for this commit
3017 * @param tree The tree that will be used as the tree for the commit. This tree object must also be owned by this repository.
3018 * @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.
3019 * @see prettify_message
3021 [CCode (cname = "git_commit_create", instance_pos = 1.2)]
3022 public Error create_commit (out 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);
3025 * Create a new commit in the repository using a variable argument list.
3027 * The parents for the commit are specified as a variable arguments. Note
3028 * that this is a convenience method which may not be safe to export for
3029 * certain languages or compilers
3031 * The message will be cleaned up from excess whitespace it will be made
3032 * sure that the last line ends with a new line.
3034 * All other parameters remain the same.
3036 * @see create_commit
3038 [CCode (cname = "git_commit_create_v", instance_pos = 1.2)]
3039 public Error create_commit_v (out object_id id, string update_ref, Signature author, Signature committer, string message_encoding, string message, Tree tree, int parent_count, ...);
3042 * Create new commit in the repository from a list of `git_oid` values
3044 * This is a dangerous API in that the parents list is not checked for
3047 * @see create_commit
3049 [CCode (cname = "git_commit_create_from_oids", instance_pos = 1.1)]
3050 public Error create_from_oids (out object_id id, string? update_ref, Signature author, Signature committer, string? message_encoding, string message, object_id tree, [CCode (array_length_pos = 7.8)] object_id? [] parents);
3053 * Create a new lightweight tag pointing at a target object
3055 * A new direct reference will be created pointing to this target object.
3056 * If //force// is true and a reference already exists with the given name,
3057 * it'll be replaced.
3059 * The message will be cleaned up from excess whitespace
3060 * it will be made sure that the last line ends with a new line.
3062 * @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.
3064 * @param tag_name Name for the tag; this name is validated for consistency. It should also not conflict with an already existing tag name.
3066 * @param target Object to which this tag points. This object must belong to this repository.
3068 * @param force Overwrite existing references
3070 * @return on success, a proper reference is written in the ///refs/tags// folder, pointing to the provided target object
3073 [CCode (cname = "git_tag_create_lightweight", instance_pos = 1.2)]
3074 public Error create_lightweight_tag (object_id id, string tag_name, Object target, bool force);
3077 * Add a note for an object
3079 * @param note_id the object id of the note crated
3080 * @param author signature of the notes commit author
3081 * @param committer signature of the notes commit committer
3082 * @param notes_ref ID reference to update (optional); defaults to "refs/notes/commits"
3083 * @param id The ID of the object
3084 * @param note The note to add for the object
3085 * @param force Overwrite existing note
3087 [CCode (cname = "git_note_create", instance_pos = 1.2)]
3088 public Error create_note (out object_id note_id, Signature author, Signature committer, string? notes_ref, object_id id, string note, bool force = false);
3091 * Creates a new iterator for notes.
3093 * @param notes_ref canonical name of the reference to use (optional);
3094 * defaults to "refs/notes/commits"
3096 [CCode (cname = "git_note_iterator_new", instance_pos = 1.1)]
3097 public Error create_note_iterator (out NoteIterator? iterator, string? notes_ref = null);
3100 * Initialize a new packbuilder
3102 * @param pack_builder The new packbuilder object
3104 [CCode (cname = "git_packbuilder_new", instance_pos = -1)]
3105 public Error create_pack_builder (out PackBuilder? pack_builder);
3108 * Create a new reference database with no backends.
3110 * Before the Ref DB can be used for read/writing, a custom database
3111 * backend must be manually set using {@link RefDb.set_backend}.
3113 [CCode (cname = "git_refdb_new", instance_pos = -1)]
3114 public Error create_refdb (out RefDb? refdb);
3117 * Create a new object id reference.
3119 * The reference will be created in the repository and written to the disk.
3121 * @param reference the newly created reference
3122 * @param name The name of the reference
3123 * @param id The object id pointed to by the reference.
3124 * @param force Overwrite existing references
3126 [CCode (cname = "git_reference_create", instance_pos = 1.2)]
3127 public Error create_reference (out unowned Reference reference, string name, object_id id, bool force);
3130 * Add a remote with the default fetch refspec to the repository's configuration.
3132 * This calls {@link Remote.save} before returning.
3134 * @param remote the resulting remote
3135 * @param name the remote's name
3136 * @param url the remote's url
3138 [CCode (cname = "git_remote_create", instance_pos = 1.2)]
3139 public Error create_remote (out Remote? remote, string name, string url);
3141 * Create a remote with the given refspec in memory.
3143 * You can use this when you have a URL instead of a remote's name. Note
3144 * that in-memory remotes cannot be converted to persisted remotes.
3146 * @param remote the newly created remote reference
3147 * @param fetch the fetch refspec to use for this remote; null for defaults
3148 * @param url the remote repository's URL
3150 [CCode (cname = "git_remote_create_inmemory", instance_pos = 1.2)]
3151 public Error create_remote_in_memory (out Remote? remote, string? fetch, string url);
3154 * Create a new symbolic reference.
3156 * The reference will be created in the repository and written to the disk.
3158 * @param reference the newly created reference
3159 * @param name The name of the reference
3160 * @param target The target of the reference
3161 * @param force Overwrite existing references
3163 [CCode (cname = "git_reference_symbolic_create", instance_pos = 1.2)]
3164 public Error create_symbolic_reference (out unowned Reference reference, string name, string target, bool force);
3167 * Create a new tag in the repository from an object
3169 * A new reference will also be created pointing to this tag object. If
3170 * //force// is true and a reference already exists with the given name,
3171 * it'll be replaced.
3173 * The tag name will be checked for validity. You must avoid the characters
3174 * ~, ^, :, \, ?, [, and *, and the sequences '''..''' and '''@{''' which
3175 * have special meaning to revparse.
3177 * @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.
3178 * @param tag_name Name for the tag; this name is validated for consistency. It should also not conflict with an already existing tag name.
3179 * @param target Object to which this tag points. This object must belong to this repository.
3180 * @param tagger Signature of the tagger for this tag, and of the tagging time
3181 * @param message Full message for this tag
3182 * @param force Overwrite existing references
3183 * @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
3185 [CCode (cname = "git_tag_create", instance_pos = 1.2)]
3186 public Error create_tag (object_id id, string tag_name, Object target, Signature tagger, string message, bool force);
3189 * Create a new tag in the repository from a buffer
3191 * @param id Pointer where to store the id of the newly created tag
3192 * @param buffer Raw tag data
3193 * @param force Overwrite existing tags
3196 [CCode (cname = "git_tag_create_frombuffer", instance_pos = 1.2)]
3197 public Error create_tag_from_buffer (object_id id, string buffer, bool force);
3200 * Delete an existing tag reference.
3202 * @param tag_name Name of the tag to be deleted; this name is validated for consistency.
3204 [CCode (cname = "git_tag_delete")]
3205 public Error delete_tag (string tag_name);
3210 * If the HEAD is already detached and points to a commit, the call is successful.
3212 * If the HEAD is already detached and points to a tag, the HEAD is updated
3213 * into making it point to the peeled commit, and the call is successful.
3215 * If the HEAD is already detached and points to a non commitish, the HEAD
3216 * is unaletered, and an error is returned.
3218 * Otherwise, the HEAD will be detached and point to the peeled commit.
3220 [CCode (cname = "git_repository_detach_head")]
3221 public Error detach_head ();
3224 * Compute a difference between two tree objects.
3226 * @param diff The diff that will be allocated.
3227 * @param old_tree A tree to diff from.
3228 * @param new_tree A tree to diff to.
3229 * @param opts Structure with options to influence diff or null for defaults.
3231 [CCode (cname = "git_diff_tree_to_tree", instance_pos = 1.1)]
3232 public Error diff_tree_to_tree (out DiffList? diff, Tree old_tree, Tree new_tree, diff_options? opts = null);
3235 * Compute a difference between a tree and the index.
3237 * @param diff The diff that will be allocated.
3238 * @param old_tree A tree object to diff from.
3239 * @param opts Structure with options to influence diff or null for defaults.
3241 [CCode (cname = "git_diff_tree_to_index", instance_pos = 1.1)]
3242 public Error diff_tree_to_index (out DiffList? diff, Tree old_tree, diff_options? opts = null);
3245 * Compute a difference between the working directory and the index.
3247 * @param diff A pointer to a git_diff_list pointer that will be allocated.
3248 * @param opts Structure with options to influence diff or null for defaults.
3250 [CCode (cname = "git_diff_index_to_workdir", instance_pos = 1.1)]
3251 public Error diff_index_to_workdir (out DiffList? diff, diff_options? opts = null);
3254 * Compute a difference between the working directory and a tree.
3256 * Please note: this is //not// the same as '''git diff //treeish//'''.
3257 * Running '''git diff HEAD''' or the like actually uses information from
3258 * the index, along with the tree and working directory info.
3260 * This function returns strictly the differences between the tree and the
3261 * The tree you provide will be used for the {@link diff_delta.old_file}
3262 * side of the delta, and the working directory will be used for the
3263 * {@link diff_delta.new_file} side.
3265 * Files contained in the working directory, regardless of the state of
3266 * files in the index. It may come as a surprise, but there is no direct
3267 * equivalent in core git.
3269 * This is //not// the same as '''git diff HEAD''' or '''git diff <SHA>'''.
3270 * Those commands diff the tree, the index, and the workdir. To emulate
3271 * those functions, call {@link diff_tree_to_index} and
3272 * {@link diff_index_to_workdir}, then call {@link DiffList.merge} on the
3275 * If this seems confusing, take the case of a file with a staged deletion
3276 * where the file has then been put back into the working dir and modified.
3277 * The tree-to-workdir diff for that file is 'modified', but core git would
3278 * show status 'deleted' since there is a pending deletion in the index.
3280 * @param old_tree A tree to diff from.
3281 * @param opts Structure with options to influence diff or NULL for defaults.
3283 [CCode (cname = "git_diff_workdir_to_tree", instance_pos = 1.1)]
3284 public Error diff_tree_to_workdir (out DiffList? diff, Tree old_tree, diff_options? opts = null);
3287 * Remove a single stashed state from the stash list.
3288 * @param index The position within the stash list. 0 points to the
3289 * most recent stashed state.
3291 [CCode (cname = "git_stash_drop")]
3292 public Error drop_stash (size_t index);
3295 * Iterate over each entry in the FETCH_HEAD file.
3297 [CCode (cname = "git_repository_fetchhead_foreach")]
3298 public Error for_each_fetchhead (FetchHeadForEach fetch_head_for_each);
3301 * If a merge is in progress, iterate over each commit ID in the MERGE_HEAD
3304 [CCode (cname = "git_repository_mergehead_foreach")]
3305 public Error for_each_merge_head (MergeHeadForEach merge_head_for_each);
3308 * Perform an operation on each reference in the repository
3310 * The processed references may be filtered by type, or using a bitwise OR
3311 * of several types. Use the magic value {@link ReferenceType.LISTALL} to
3312 * obtain all references, including packed ones.
3314 * @param list_flags Filtering flags for the reference listing.
3315 * @param reference_for_each Function which will be called for every listed ref
3317 [CCode (cname = "git_reference_foreach")]
3318 public Error for_each_reference (ReferenceType list_flags, ReferenceForEach reference_for_each);
3320 * Loop over all the references and issue a callback for each one which
3321 * name matches the given glob pattern.
3323 * @param list_flags Filtering flags for the reference listing.
3324 * @param reference_for_each to invoke per found reference.
3326 [CCode (cname = "git_reference_foreach_glob")]
3327 public Error for_each_reference_glob (string glob, ReferenceType list_flags, ReferenceForEach reference_for_each);
3330 * Iterate over all submodules of a repository.
3332 [CCode (cname = "git_submodule_foreach")]
3333 public Error for_each_submodule (SubmoduleForEach submodule_for_each);
3335 * Iterate over each tag in the repository.
3337 [CCode (cname = "git_tag_foreach")]
3338 public Error for_each_tag (TagForEach tag_for_each);
3341 * Find a merge base between two commits
3343 * @param merge_base the OID of a merge base between 'one' and 'two'
3344 * @param one one of the commits
3345 * @param two the other commit
3347 [CCode (cname = "git_merge_base", instance_pos = 1.2)]
3348 public Error find_merge_base (out object_id merge_base, object_id one, object_id two);
3351 * Find a merge base given a list of commits
3353 * @param id the ID of a merge base considering all the commits
3354 * @param input ids of the commits
3356 [CCode (cname = "git_merge_base_many", instance_pos = 1.1)]
3357 public Error find_merge_base_many (out object_id id, [CCode (array_length_type = "size_t")] object_id[] input);
3360 * Loop over all the notes within a specified namespace.
3361 * @param notes_ref OID reference to read from (optional); defaults to "refs/notes/commits".
3363 [CCode (cname = "git_note_foreach")]
3364 public Error for_each_note (string? notes_ref, NoteForEach note_for_each);
3367 * Loop over all the stashed states.
3369 * The most recent stash state will be enumerated first.
3371 [CCode (cname = "git_stash_foreach")]
3372 public Error for_each_stash (StashForEach stash_for_each);
3375 * Gather file statuses and run a callback for each one.
3377 * The callback is passed the path of the file, the status and the data
3378 * pointer passed to this function. If the callback returns something other
3379 * than {@link Error.OK}, this function will return that value.
3381 * @param status_for_each the function to call on each file
3382 * @return {@link Error.OK} or the return value of the callback
3384 [CCode (cname = "git_status_foreach")]
3385 public Error for_each_status (StatusForEach status_for_each);
3388 * Gather file status information and run callbacks as requested.
3390 [CCode (cname = "git_status_foreach_ext")]
3391 public Error for_each_status_ext (status_options opts, StatusForEach status_for_each);
3394 * Get the configuration file for this repository.
3396 * If a configuration file has not been set, the default
3397 * config set for the repository will be returned, including
3398 * global and system configurations (if they are available).
3400 * @param config the repository's configuration
3402 [CCode (cname = "git_repository_config", instance_pos = -1)]
3403 public Error get_config (out Config config);
3406 * Get the Object Database for this repository.
3408 * If a custom ODB has not been set, the default database for the
3409 * repository will be returned (the one located in //.git/objects//).
3411 [CCode (cname = "git_repository_odb", instance_pos = -1)]
3412 public Error get_db (out Database.Handle db);
3415 * Get file status for a single file
3417 * @param status the status value
3418 * @param path the file to retrieve status for, rooted at the repo's workdir
3419 * @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
3421 [CCode (cname = "git_status_file", instance_pos = 1.2)]
3422 public Error get_file_status (out Status status, string path);
3425 * Retrieve and resolve the reference pointed at by HEAD.
3427 * @param head the reference which will be retrieved
3429 [CCode (cname = "git_repository_head", instance_pos = -1)]
3430 public Error get_head (out Reference head);
3433 * Get the index file for this repository.
3435 * If a custom index has not been set, the default
3436 * index for the repository will be returned (the one
3437 * located in //.git/index//).
3439 * If a custom index has not been set, the default
3440 * index for the repository will be returned (the one
3441 * located in //.git/index//).
3444 [CCode (cname = "git_repository_index", instance_pos = -1)]
3445 public void get_index (out Index index);
3448 * Get the information for a particular remote
3450 * The name will be checked for validity.
3451 * @param remote the new remote object
3452 * @param name the remote's name
3455 [CCode (cname = "git_remote_load", instance_pos = 1.2)]
3456 public Error get_remote (out Remote remote, string name);
3459 * Return the name of remote that the remote tracking branch belongs to.
3461 * @param remote_name The buffer which will be filled with the name of the
3462 * remote. Pass null if you just want to get the needed size of the name of
3463 * the remote as the output value.
3465 * @param canonical_branch_name name of the remote tracking branch.
3467 * @return Number of characters in the reference name including the
3468 * trailing NUL byte; {@link Error.NOTFOUND} when no remote matching remote
3469 * was found, {@link Error.AMBIGUOUS} when the branch maps to several
3470 * remotes, otherwise an error code.
3472 [CCode (cname = "git_branch_remote_name", insance_pos = 1.2)]
3473 public int get_branch_remote_name ([CCode (array_length_type = "size_t")] uint8[]? remote_name, string canonical_branch_name);
3476 * Get the Reference Database Backend for this repository.
3478 * If a custom refsdb has not been set, the default database for the
3479 * repository will be returned (the one that manipulates loose and packed
3480 * references in the '''.git''' directory).
3482 [CCode (cname = "git_repository_refdb", instance_pos = -1)]
3483 public Error get_refdb (out RefDb? refdb);
3486 * Get a list of the configured remotes for a repo
3488 * @param remotes_list a string array with the names of the remotes
3490 [CCode (cname = "git_remote_list", instance_pos = -1)]
3491 public Error get_remote_list (out string_array remotes_list);
3494 * Fill a list with all the tags in the Repository
3496 * @param tag_names where the tag names will be stored
3498 [CCode (cname = "git_tag_list", instance_pos = -1)]
3499 public Error get_tag_list (string_array tag_names);
3502 * Fill a list with all the tags in the Repository which name match a
3505 * If an empty pattern is provided, all the tags will be returned.
3507 * @param tag_names the tag names will be stored
3508 * @param pattern standard shell-like (fnmatch) pattern
3510 [CCode (cname = "git_tag_list_match", instance_pos = -1)]
3511 public Error get_tag_list_match (out string_array tag_names, string pattern);
3514 * Return the name of the reference supporting the remote tracking branch,
3515 * given the name of a local branch reference.
3517 * @param tracking_branch_name The buffer which will be filled with the
3518 * name of the reference, or null if you just want to get the needed size
3519 * of the name of the reference as the output value.
3521 * @param canonical_branch_name name of the local branch.
3523 * @return number of characters in the reference name including the
3524 * trailing NUL byte; otherwise an error code.
3526 [CCode (cname = "git_branch_upstream_name", instance_pos = 1.3)]
3527 public int get_tracking_upstream_name ([CCode (array_length_type = "size_t")] char[]? tracking_branch_name, string canonical_branch_name);
3530 * Allocate a new revision walker to iterate through a repo.
3532 * This revision walker uses a custom memory pool and an internal commit
3533 * cache, so it is relatively expensive to allocate.
3535 * For maximum performance, this revision walker should be reused for
3538 * This revision walker is ''not'' thread safe: it may only be used to walk
3539 * a repository on a single thread; however, it is possible to have several
3540 * revision walkers in several different threads walking the same
3543 * @param walker the new revision walker
3545 [CCode (cname = "git_revwalk_new", instance_pos = -1)]
3546 public Error get_walker (out RevisionWalker walker);
3549 * Calculate hash of file using repository filtering rules.
3551 * If you simply want to calculate the hash of a file on disk with no filters,
3552 * you can just use the {@link object_id.hashfile} API. However, if you
3553 * want to hash a file in the repository and you want to apply filtering
3554 * rules (e.g. crlf filters) before generating the SHA, then use this
3557 * @param path Path to file on disk whose contents should be hashed. This can be a relative path.
3558 * @param type The object type to hash
3559 * @param as_path The path to use to look up filtering rules. If this is
3560 * null, then the path parameter will be used instead. If this is passed as
3561 * the empty string, then no filters will be applied when calculating the
3564 [CCode (cname = "git_repository_hashfile", instance_pos = 1.1)]
3565 public Error hashfile (out object_id id, string path, ObjectType type, string? as_path = null);
3568 * Iterate over the branches in the repository.
3570 * @param list_flags Filtering flags for the branch listing.
3572 [CCode (cname = "git_branch_foreach")]
3573 public Error for_each_branch (BranchType list_flags, Branch branch);
3575 * Test if the ignore rules apply to a given path.
3577 * This function checks the ignore rules to see if they would apply to the
3578 * given file. This indicates if the file would be ignored regardless of
3579 * whether the file is already in the index or commited to the repository.
3581 * One way to think of this is if you were to do '''git add .''' on the
3582 * directory containing the file, would it be added or not?
3584 * @param path the file to check ignores for, relative to the repo's
3587 [CCode (cname = "git_ignore_path_is_ignored", instance_pos = 1.1)]
3588 public Error is_path_ignored (out bool ignored, string path);
3590 [CCode (cname = "git_branch_foreach", instance_pos = 1.2)]
3591 public Error list_branches (out string_array branch_names, BranchType list_flags);
3594 * Fill a list with all the references that can be found
3597 * The listed references may be filtered by type, or using
3598 * a bitwise OR of several types. Use the magic value
3599 * {@link ReferenceType.LISTALL} to obtain all references, including
3602 * @param array where the reference names will be stored
3603 * @param list_flags Filtering flags for the reference listing.
3605 [CCode (cname = "git_reference_listall", instance_pos = 1.2)]
3606 public Error list_all (out string_array array, ReferenceType list_flags);
3609 * Convert a tree entry to the object it points too.
3611 * @param object pointer to the converted object
3612 * @param entry a tree entry
3614 [CCode (cname = "git_tree_entry_to_object", instance_pos = 1.2)]
3615 public Error load (out Object object, TreeEntry entry);
3618 * Lookup a blob object from a repository.
3620 * @param blob the looked up blob
3621 * @param id identity of the blob to locate.
3623 [CCode (cname = "git_blob_lookup", instance_pos = 1.2)]
3624 public Error lookup_blob (out Blob blob, object_id id);
3627 * Lookup a blob object from a repository, given a prefix of its identifier
3630 * @see lookup_object_by_prefix
3632 * @param blob the looked up blob
3633 * @param id identity of the blob to locate.
3634 * @param len the length of the short identifier
3636 [CCode (cname = "git_blob_lookup_prefix", instance_pos = 1.2)]
3637 public Error lookup_blob_by_prefix (out Blob blob, object_id id, size_t len);
3639 * Lookup a branch by its name.
3641 * @param branch_name Name of the branch to be looked-up; this name is
3642 * validated for consistency.
3644 [CCode (cname = "git_branch_lookup", instance_pos = 1.1)]
3645 public Error lookup_branch (out Reference? branch, string branch_name, BranchType branch_type);
3648 * Lookup a commit object from a repository.
3650 * @param commit the looked up commit
3651 * @param id identity of the commit to locate. If the object is an annotated tag it will be peeled back to the commit.
3653 [CCode (cname = "git_commit_lookup", instance_pos = 1.2)]
3654 public Error lookup_commit (out Commit commit, object_id id);
3657 * Lookup a commit object from a repository, given a prefix of its
3658 * identifier (short id).
3660 * @see lookup_object_by_prefix
3662 * @param commit the looked up commit
3663 * @param id identity of the commit to locate. If the object is an annotated tag it will be peeled back to the commit.
3664 * @param len the length of the short identifier
3666 [CCode (cname = "git_commit_lookup_prefix", instance_pos = 1.2)]
3667 public Error lookup_commit_by_prefix (out Commit commit, object_id id, size_t len);
3670 * Lookup a reference to one of the objects in a repostory.
3672 * The //type// parameter must match the type of the object in the ODB; the
3673 * method will fail otherwise. The special value {@link ObjectType.ANY}
3674 * may be passed to let the method guess the object's type.
3676 * @param object the looked-up object
3677 * @param id the unique identifier for the object
3678 * @param type the type of the object
3679 * @return a reference to the object
3681 [CCode (cname = "git_object_lookup", instance_pos = 1.2)]
3682 public Error lookup_object (out Object object, object_id id, ObjectType type);
3685 * Lookup a reference to one of the objects in a repostory, given a prefix
3686 * of its identifier (short id).
3688 * The object obtained will be so that its identifier matches the first
3689 * //len// hexadecimal characters (packets of 4 bits) of the given //id//.
3690 * //len// must be at least {@link object_id.MIN_PREFIX_LENGTH}, and long
3691 * enough to identify a unique object matching the prefix; otherwise the
3694 * The //type// parameter must match the type of the object in the ODB; the
3695 * method will fail otherwise. The special value {@link ObjectType.ANY}
3696 * may be passed to let the method guess the object's type.
3698 * @param object where to store the looked-up object
3699 * @param id a short identifier for the object
3700 * @param len the length of the short identifier
3701 * @param type the type of the object
3703 [CCode (cname = "git_object_lookup_prefix", instance_pos = 1.2)]
3704 public Error lookup_object_by_prefix (out Object object, object_id id, size_t len, ObjectType type);
3707 * Lookup a reference by its name in a repository.
3709 * @param reference the looked-up reference
3710 * @param name the long name for the reference (e.g., HEAD, ref/heads/master, refs/tags/v0.1.0, ...)
3712 [CCode (cname = "git_reference_lookup", instance_pos = 1.2)]
3713 public Error lookup_reference (out Reference reference, string name);
3716 * Lookup a reference by name and resolve immediately to an ID.
3718 * @param name The long name for the reference
3720 [CCode (cname = "git_reference_name_to_id", instance_pos = 1.2)]
3721 public Error lookup_reference_to_id (out object_id id, string name);
3724 * Lookup submodule information by name or path.
3726 * Given either the submodule name or path (they are ususally the same),
3727 * this returns a structure describing the submodule.
3729 * @param name The name of the submodule. Trailing slashes will be ignored.
3731 [CCode (cname = "git_submodule_lookup", instance_pos = 1.2)]
3732 public Error lookup_submodule (out unowned Submodule? submodule, string name);
3735 * Lookup a tag object from the repository.
3737 * @param tag pointer to the looked up tag
3738 * @param id identity of the tag to locate.
3740 [CCode (cname = "git_tag_lookup", instance_pos = 1.2)]
3741 public Error lookup_tag (out Tag tag, object_id id);
3744 * Lookup a tag object from the repository, given a prefix of its
3745 * identifier (short id).
3747 * @see lookup_object_by_prefix
3749 * @param tag pointer to the looked up tag
3750 * @param id identity of the tag to locate.
3751 * @param len the length of the short identifier
3753 [CCode (cname = "git_tag_lookup_prefix", instance_pos = 1.2)]
3754 public Error prefix_lookup_tag (out Tag tag, object_id id, uint len);
3757 * Lookup a tree object from the repository.
3759 * @param tree the looked up tree
3760 * @param id identity of the tree to locate.
3762 [CCode (cname = "git_tree_lookup", instance_pos = 1.2)]
3763 public Error lookup_tree (out Tree tree, object_id id);
3766 * Lookup a tree object from the repository, given a prefix of its
3767 * identifier (short id).
3769 * @see lookup_object_by_prefix
3771 * @param tree the looked up tree
3772 * @param id identity of the tree to locate.
3773 * @param len the length of the short identifier
3775 [CCode (cname = "git_tree_lookup_prefix", instance_pos = 1.2)]
3776 public Error lookup_tree_by_prefix (out Tree tree, object_id id, uint len);
3779 * Create a new reference database and automatically add
3780 * the default backends:
3782 * - git_refdb_dir: read and write loose and packed refs from disk,
3783 * assuming the repository dir as the folder
3785 [CCode (cname = "git_refdb_open", instance_pos = -1)]
3786 public Error open_refdb (out RefDb? refdb);
3789 * Find an object, as specified by a revision string. See the gitrevisions
3790 * manual page, or the documentation for '''git rev-parse''' for
3791 * information on the syntax accepted.
3793 * @param spec the textual specification for an object
3795 [CCode (cname = "git_revparse_single", instance_pos = 1.1)]
3796 public Error parse (out Object? obj, string spec);
3799 * Parse a revision string for //from//, //to//, and intent.
3801 * See the gitrevisions manual page or
3802 * [[http://git-scm.com/docs/git-rev-parse.html#_specifying_revisions|specifying revisions]]
3803 * for information on the syntax accepted.
3805 * @param spec the rev-parse spec to parse
3807 [CCode (cname = "git_revparse", instance_pos = 1.1)]
3808 public Error parse_rev (out revspec revspec, string spec);
3811 * Read the note for an object
3812 * @param notes_ref ID reference to use (optional); defaults to "refs/notes/commits"
3813 * @param id ID of the object
3815 [CCode (cname = "git_note_read", instance_pos = 1.2)]
3816 public Error read_note (out Note? note, string? notes_ref, object_id id);
3818 * Get the default notes reference for a repository
3820 [CCode (cname = "git_note_default_ref", instance_pos = -1)]
3821 public Error read_note_default_ref (out unowned string note);
3824 * Reread all submodule info.
3826 * Call this to reload all cached submodule information for the repo.
3828 [CCode (cname = "git_submodule_reload_all")]
3829 public Error reload_submodules ();
3832 * Remove the note for an object
3834 * @param notes_ref ID reference to use (optional); defaults to "refs/notes/commits"
3835 * @param author signature of the notes commit author
3836 * @param committer signature of the notes commit committer
3837 * @param id the id which note's to be removed
3839 [CCode (cname = "git_note_remove")]
3840 public Error remove_note (string? notes_ref, Signature author, Signature committer, object_id id);
3843 * Sets the current head to the specified commit oid and optionally resets
3844 * the index and working tree to match.
3846 * When specifying a Soft kind of reset, the head will be moved to the commit.
3848 * Specifying a Mixed kind of reset will trigger a Soft reset and the index
3849 * will be replaced with the content of the commit tree.
3851 * @param target Object to which the Head should be moved to. This object
3852 * must belong to this repository and can either be a {@link Commit} or a
3853 * {@link Tag}. When a {@link Tag} is being passed, it should be
3854 * dereferencable to a {@link Commit} which oid will be used as the target
3856 * @param reset_type Kind of reset operation to perform.
3858 [CCode (cname = "git_reset")]
3859 public Error reset (Object target, ResetType reset_type);
3862 * Updates some entries in the index from the target commit tree.
3864 * The scope of the updated entries is determined by the paths
3867 * @param target The committish which content will be used to reset the
3868 * content of the index. Passing null will result in removing entries in
3869 * the index matching the provided pathspecs.
3871 * @param pathspecs List of pathspecs to operate on.
3873 [CCode (cname = "git_reset_default")]
3874 public Error reset_default (Object? target, string_array pathspecs);
3877 * Save the local modifications to a new stash.
3879 * @param id id of the commit containing the stashed state. This commit is
3880 * also the target of the direct reference refs/stash.
3881 * @param stasher The identity of the person performing the stashing.
3882 * @param message description along with the stashed state.
3884 [CCode (cname = "git_stash_save", instance_pos = 1.1)]
3885 public Error save_stash (out object_id id, Signature stasher, string? message = null, StashFlag flags = StashFlag.DEFAULT);
3888 * Set the configuration file for this repository
3890 * This configuration file will be used for all configuration
3891 * queries involving this repository.
3893 [CCode (cname = "git_repository_set_config")]
3894 public void set_config (Config config);
3897 * Set the Object Database for this repository
3899 * The ODB will be used for all object-related operations involving this
3902 [CCode (cname = "git_repository_set_odb")]
3903 public void set_db (Database.Handle db);
3905 * Make the repository HEAD point to the specified reference.
3907 * If the provided reference points to a Tree or a Blob, the HEAD is
3908 * unaltered and an error is returned.
3910 * If the provided reference points to a branch, the HEAD will point to
3911 * that branch, staying attached, or become attached if it isn't yet. If
3912 * the branch doesn't exist yet, no error will be return. The HEAD will
3913 * then be attached to an unborn branch.
3915 * Otherwise, the HEAD will be detached and will directly point to the
3918 * @param refname Canonical name of the reference the HEAD should point at
3920 [CCode (cname = "git_repository_set_head")]
3921 public Error set_head (string refname);
3924 * Make the repository HEAD directly point to the Commit.
3926 * If the provided committish cannot be found in the repository, the HEAD
3927 * is unaltered and {@link Error.NOTFOUND} is returned.
3929 * If the provided commitish cannot be peeled into a commit, the HEAD is
3930 * unaltered and and error is returned.
3932 * Otherwise, the HEAD will eventually be detached and will directly point to
3933 * the peeled Commit.
3935 * @param commitish Object id of the Commit the HEAD should point to
3936 * @return 0 on success, or an error code
3938 [CCode (cname = "git_repository_set_head_detached")]
3939 public Error set_head_detached (object_id commitish);
3942 * Set the index file for this repository
3944 * This index will be used for all index-related operations
3945 * involving this repository.
3947 [CCode (cname = "git_repository_set_index")]
3948 public void set_index (Index index);
3951 * Set the Reference Database Backend for this repository
3953 * The refdb will be used for all reference related operations involving
3956 [CCode (cname = "git_repository_set_refdb")]
3957 public void set_refdb (RefDb refdb);
3960 * Set the working directory.
3961 * @param workdir The path to a working directory
3962 * @param update_gitlink Create/update gitlink in workdir and set config
3963 * "core.worktree" (if workdir is not the parent of the .git directory)
3965 [CCode (cname = "git_repository_set_workdir")]
3966 public Error set_workdir (string workdir, bool update_gitlink);
3969 * Test if the ignore rules apply to a given file.
3971 * This function simply checks the ignore rules to see if they would apply
3972 * to the given file. Unlike {@link get_file_status}, this indicates if
3973 * the file would be ignored regardless of whether the file is already in
3974 * the index or in the repository.
3976 * @param path the file to check ignores for, rooted at the repo's workdir
3977 * @param ignored false if the file is not ignored, true if it is
3978 * @return {@link Error.OK} if the ignore rules could be processed
3979 * for the file (regardless of whether it exists or not), or an error if
3982 [CCode (cname = "git_status_should_ignore", instance_pos = 1.2)]
3983 public Error should_ignore (out bool ignored, string path);
3986 * Write the contents of the tree builder as a tree object
3988 * The tree builder will be written to the repositrory, and it's
3989 * identifying SHA1 hash will be stored in the id pointer.
3991 * @param id Pointer where to store the written id
3992 * @param builder Tree builder to write
3994 [CCode (cname = "git_treebuilder_write", instance_pos = 1.2)]
3995 public Error write (object_id id, TreeBuilder builder);
3999 * An in-progress walk through the commits in a repo
4001 [CCode (cname = "git_revwalk", free_function = "git_revwalk_free", has_type_id = false)]
4003 public class RevisionWalker {
4006 * The repository on which this walker is operating.
4008 public Repository repository {
4009 [CCode (cname = "git_revwalk_repository")]
4014 * Mark a commit (and its ancestors) uninteresting for the output.
4016 * The given id must belong to a commit on the walked repository.
4018 * The resolved commit and all its parents will be hidden from the output
4019 * on the revision walk.
4021 * @param id the id of commit that will be ignored during the traversal
4023 [CCode (cname = "git_revwalk_hide")]
4024 public Error hide (object_id id);
4027 * Hide the OID pointed to by a reference
4029 * The reference must point to a commit.
4031 * @param refname the referece to hide
4033 [CCode (cname = "git_revwalk_hide_ref")]
4034 public Error hide_ref (string refname);
4037 * Get the next commit from the revision walk.
4039 * The initial call to this method is ''not'' blocking when iterating through
4040 * a repo with a time-sorting mode.
4042 * Iterating with topological or inverted modes makes the initial call
4043 * blocking to preprocess the commit list, but this block should be mostly
4044 * unnoticeable on most repositories (topological preprocessing times at
4045 * 0.3s on the git.git repo).
4047 * The revision walker is reset when the walk is over.
4049 * @param id where to store the id of the next commit
4051 [CCode (cname = "git_revwalk_next", instance_pos = -1)]
4052 public Error next (out object_id id);
4055 * Mark a commit to start traversal from.
4057 * The given id must belong to a commit on the walked repository.
4059 * The given commit will be used as one of the roots when starting the
4060 * revision walk. At least one commit must be pushed the repository before
4061 * a walk can be started.
4063 * @param id the id of the commit to start from.
4065 [CCode (cname = "git_revwalk_push")]
4066 public Error push (object_id id);
4069 * Push and hide the respective endpoints of the given range.
4071 * The range should be of the form //commit//..//commit//
4072 * where each //commit// is in the form accepted by
4073 * {@link Repository.parse}. The left-hand commit will be hidden and the
4074 * right-hand commit pushed.
4076 * @param range the range
4077 * @see Repository.parse
4080 [CCode (cname = "git_revwalk_push_range")]
4081 public Error push_range (string range);
4084 * Push the OID pointed to by a reference
4086 * The reference must point to a commit.
4088 * @param refname the referece to push
4090 [CCode (cname = "git_revwalk_push_ref")]
4091 public Error push_ref (string refname);
4094 * Push matching references
4096 * The OIDs pinted to by the references that match the given glob
4097 * pattern will be pushed to the revision walker.
4099 * A leading 'refs/' is implied it not present as well as a trailing
4100 * '/ *' if the glob lacks '?', '*' or '['.
4102 * @param glob the glob pattern references should match
4104 [CCode (cname = "git_revwalk_push_glob")]
4105 public Error push_glob (string glob);
4108 * Push the repository's HEAD
4110 [CCode (cname = "git_revwalk_push_head")]
4111 public Error push_head ();
4114 * Reset the revision walker for reuse.
4116 * This will clear all the pushed and hidden commits, and leave the walker
4117 * in a blank state (just like at creation) ready to receive new commit
4118 * pushes and start a new walk.
4120 * The revision walk is automatically reset when a walk is over.
4122 [CCode (cname = "git_revwalk_reset")]
4123 public void reset ();
4126 * Change the sorting mode when iterating through the repository's
4129 * Changing the sorting mode resets the walker.
4131 * @param sort combination of sort flags
4133 [CCode (cname = "git_revwalk_sorting")]
4134 public void set_sorting (Sorting sort);
4137 * Hide matching references.
4139 * The OIDs pinted to by the references that match the given glob
4140 * pattern and their ancestors will be hidden from the output on the
4143 * A leading 'refs/' is implied it not present as well as a trailing
4144 * '/ *' if the glob lacks '?', '*' or '['.
4146 * @param glob the glob pattern references should match
4148 [CCode (cname = "git_revwalk_hide_glob")]
4149 public Error hide_glob (string glob);
4152 * Hide the repository's HEAD
4154 [CCode (cname = "git_revwalk_hide_head")]
4155 public Error hide_head ();
4159 * An action signature (e.g. for committers, taggers, etc)
4161 [CCode (cname = "git_signature", free_function = "git_signature_free", copy_function = "git_signature_dup", has_type_id = false)]
4163 public class Signature {
4165 * Email of the author
4167 public string email;
4169 * Full name of the author
4173 * Time when the action happened
4178 * Create a new action signature.
4180 * Note: angle brackets characters are not allowed in either the name or
4182 * @param sig new signature, null in case of error
4183 * @param name name of the person
4184 * @param email email of the person
4185 * @param time time when the action happened
4186 * @param offset timezone offset in minutes for the time
4188 [CCode (cname = "git_signature_new")]
4189 public static int create (out Signature? sig, string name, string email, int64 time, int offset);
4192 * Create a new action signature with a timestamp of now.
4194 * @param sig new signature, null in case of error
4195 * @param name name of the person
4196 * @param email email of the person
4198 [CCode (cname = "git_signature_now")]
4199 public static int create_now (out Signature? sig, string name, string email);
4203 * Description of submodule
4205 * This record describes a submodule found in a repository. There
4206 * should be an entry for every submodule found in the HEAD and for
4207 * every submodule described in .gitmodules.
4209 [CCode (cname = "git_submodule", has_type_id = false)]
4211 public class Submodule {
4213 * The name of the submodule from .gitmodules.
4215 public string name {
4216 [CCode (cname = "git_submodule_name")]
4220 * The path to the submodule from the repo working directory.
4222 * It is almost always the same as {@link name}.
4224 public string path {
4225 [CCode (cname = "git_submodule_path")]
4229 * The url for the submodule.
4231 * If deleted but not commited, this will be null.
4233 public string? url {
4234 [CCode (cname = "git_submodule_url")]
4236 [CCode (cname = "git_submodule_set_url")]
4240 * Get the OID for the submodule in the index.
4242 public object_id? index_id {
4243 [CCode (cname = "git_submodule_index_id")]
4247 * Get the OID for the submodule in the current HEAD tree.
4249 public object_id? head_id {
4250 [CCode (cname = "git_submodule_head_id")]
4254 * Whether or not to fetch submodules of submodules recursively.
4256 public bool fetch_recurse {
4257 [CCode (cname = "git_submodule_fetch_recurse_submodules")]
4259 [CCode (cname = "git_submodule_set_fetch_recurse_submodules")]
4263 * The containing repository for a submodule.
4265 * This returns a pointer to the repository that contains the submodule.
4267 public Repository repository {
4268 [CCode (cname = "git_submodule_owner")]
4273 * Get the OID for the submodule in the current working directory.
4275 * This returns the OID that corresponds to looking up 'HEAD' in the
4276 * checked out submodule. If there are pending changes in the index or
4277 * anything else, this won't notice that. You should check
4278 * {@link status} for a more complete picture about the state of the
4279 * working directory.
4281 public object_id? wd_id {
4282 [CCode (cname = "git_submodule_wd_id")]
4287 * The ignore rule for the submodule.
4289 [CCode (cname = "git_submodule_ignore")]
4290 public SubmoduleIgnore ignore {
4291 [CCode (cname = "git_submodule_ignore")]
4293 [CCode (cname = "git_submodule_set_ignore")]
4298 * The update rule for the submodule.
4300 public SubmoduleUpdate update {
4301 [CCode (cname = "git_submodule_update")]
4303 [CCode (cname = "git_submodule_set_update")]
4308 * Resolve the setup of a new git submodule.
4310 * This should be called on a submodule once you have called add setup and
4311 * done the clone of the submodule. This adds the .gitmodules file and the
4312 * newly cloned submodule to the index to be ready to be committed (but
4313 * doesn't actually do the commit).
4315 [CCode (cname = "git_submodule_add_finalize")]
4316 public Error add_finalize ();
4319 * Add current submodule HEAD commit to index of superproject.
4321 * @param write_index if this should immediately write the index file. If
4322 * you pass this as false, you will have to explicitly call {@link Index.write}
4323 * on it to save the change.
4325 [CCode (cname = "git_submodule_add_to_index")]
4326 public Error add_to_index (bool write_index);
4329 * Copy submodule info into ".git/config" file.
4331 * Just like "git submodule init", this copies information about the
4332 * submodule into ".git/config". You can use the accessor functions above
4333 * to alter the in-memory git_submodule object and control what is written
4334 * to the config, overriding what is in .gitmodules.
4336 * @param overwrite By default, existing entries will not be overwritten,
4337 * but setting this to true forces them to be updated.
4339 [CCode (cname = "git_submodule_init")]
4340 public Error init (bool overwrite);
4343 * Get the locations of submodule information.
4345 * This is a bit like a very lightweight version of {@link status}.
4346 * It just returns a made of the first four submodule status values (i.e.
4347 * the ones like {@link SubmoduleStatus.IN_HEAD}, etc) that tell you where
4348 * the submodule data comes from (i.e. the HEAD commit, gitmodules file,
4351 * This can be useful if you want to know if the submodule is present in
4352 * the working directory at this point in time, etc.
4354 [CCode (cname = "git_submodule_location", instance_pos = -1)]
4355 public Error location (out SubmoduleStatus status);
4358 * Copy submodule remote info into submodule repo.
4360 * This copies the information about the submodules URL into the checked
4361 * out submodule config, acting like "git submodule sync". This is useful
4362 * if you have altered the URL for the submodule (or it has been altered by
4363 * a fetch of upstream changes) and you need to update your local repo.
4365 [CCode (cname = "git_submodule_sync")]
4366 public Error sync ();
4369 * Open the repository for a submodule.
4371 * This will only work if the submodule is checked out into the working
4374 [CCode (cname = "git_submodule_open", instance_pos = -1)]
4375 public Error open (out Repository? repo);
4378 * Reread submodule info from config, index, and HEAD.
4380 * Call this to reread cached submodule information for this submodule if
4381 * you have reason to believe that it has changed.
4383 [CCode (cname = "git_submodule_reload")]
4384 public Error reload ();
4387 * Write submodule settings to .gitmodules file.
4389 * This commits any in-memory changes to the submodule to the gitmodules
4390 * file on disk. You may also be interested in `git_submodule_init()`
4391 * which writes submodule info to ".git/config" (which is better for local
4392 * changes to submodule settings) and/or `git_submodule_sync()` which
4393 * writes settings about remotes to the actual submodule repository.
4395 [CCode (cname = "git_submodule_save")]
4396 public Error save ();
4399 * Get the status for a submodule.
4401 * This looks at a submodule and tries to determine the status.
4403 [CCode (cname = "git_submodule_status", instance_pos = -1)]
4404 public Error status (out SubmoduleStatus status);
4408 * Parsed representation of a tag object.
4410 [CCode (cname = "git_tag", free_function = "git_tag_free", has_type_id = false)]
4412 public class Tag : Object {
4416 public object_id? id {
4417 [CCode (cname = "git_tag_id")]
4422 * The message of a tag
4424 public string message {
4425 [CCode (cname = "git_tag_message")]
4432 public string name {
4433 [CCode (cname = "git_tag_name")]
4438 * The tagger (author) of a tag
4440 public Signature tagger {
4441 [CCode (cname = "git_tag_tagger")]
4446 * The id of the tagged object of a tag
4448 public object_id? target_id {
4449 [CCode (cname = "git_tag_target_id")]
4454 * The type of a tag's tagged object
4456 public ObjectType target_type {
4457 [CCode (cname = "git_tag_target_type")]
4462 * Get the tagged object of a tag
4464 * This method performs a repository lookup for the given object and
4467 * @param target where to store the target
4469 [CCode (cname = "git_tag_target", instance_pos = -1)]
4470 public Error lookup_target (out Object target);
4473 * Recursively peel a tag until a non-tag-object is met
4475 [CCode (cname = "git_tag_peel", instance_pos = -1)]
4476 public Error peel (out Object result);
4480 * Representation of a tree object.
4482 [CCode (cname = "git_tree", free_function = "git_tree_free", has_type_id = false)]
4484 public class Tree : Object {
4488 public object_id? id {
4489 [CCode (cname = "git_tree_id")]
4493 public Repository repository {
4494 [CCode (cname = "git_tree_owner")]
4499 * Get the number of entries listed in a tree
4501 public size_t size {
4502 [CCode (cname = "git_tree_entrycount")]
4507 * Lookup a tree entry by its position in the tree
4509 * @param idx the position in the entry list
4510 * @return the tree entry; null if not found
4512 [CCode (cname = "git_tree_entry_byindex")]
4513 public unowned TreeEntry? get (size_t idx);
4515 * Lookup a tree entry by SHA value.
4517 * Warning: this must examine every entry in the tree, so it is not fast.
4519 * @param id the sha being looked for
4520 * @return the tree entry; null if not found
4522 [CCode (cname = "git_tree_entry_byoid")]
4523 public unowned TreeEntry? get_by_id (object_id id);
4526 * Lookup a tree entry by its filename
4528 * @param filename the filename of the desired entry
4529 * @return the tree entry; null if not found
4531 [CCode (cname = "git_tree_entry_byname")]
4532 public unowned TreeEntry? get_by_name (string filename);
4535 * Retrieve a subtree contained in a tree, given its relative path.
4537 * @param path Path to the tree entry from which to extract the last tree object
4538 * @return {@link Error.OK} on success; {@link Error.NOTFOUND} if the path does not lead to an entry; otherwise, an error code
4540 [CCode (cname = "git_tree_entry_bypath", instance_pos = 1.2)]
4541 public Error get_by_path (out TreeEntry entry, string path);
4544 * Traverse the entries in a tree and its subtrees in post or pre order
4546 * The entries will be traversed in the specified order, children subtrees
4547 * will be automatically loaded as required, and the callback will be
4548 * called once per entry with the current (relative) root for the entry and
4549 * the entry data itself.
4551 * If the callback returns a negative value, the passed entry will be
4552 * skiped on the traversal.
4554 * @param mode Traversal mode (pre or post-order)
4555 * @param tree_walker Function to call on each tree entry
4557 [CCode (cname = "git_tree_walk")]
4558 public Error walk (WalkMode mode, TreeWalker tree_walker);
4562 * Constructor for in-memory trees
4564 [CCode (cname = "git_treebuilder", free_function = "git_treebuilder_free", has_type_id = false)]
4566 public class TreeBuilder {
4568 * The number of entries listed in a treebuilder.
4571 [CCode (cname = "git_treebuilder_entrycount")]
4576 * Create a new tree builder.
4578 * The tree builder can be used to create or modify trees in memory and
4579 * write them as tree objects to the database.
4581 * If the source parameter is not null, the tree builder will be
4582 * initialized with the entries of the given tree.
4584 * If the source parameter is null, the tree builder will have no entries
4585 * and will have to be filled manually.
4587 * @param builder where to store the tree builder
4588 * @param source source tree to initialize the builder (optional)
4590 [CCode (cname = "git_treebuilder_create")]
4591 public static Error create (out TreeBuilder builder, Tree? source = null);
4594 * Clear all the entires in the builder
4596 [CCode (cname = "git_treebuilder_clear")]
4597 public void clear ();
4600 * Filter the entries in the tree
4602 * The filter will be called for each entry in the tree with an entry. If
4603 * the callback returns true, the entry will be filtered (removed from the
4605 * @param filter function to filter entries
4607 [CCode (cname = "git_treebuilder_filter")]
4608 public void filter (Filter filter);
4611 * Add or update an entry to the builder
4613 * Insert a new entry for the given filename in the builder with the given
4616 * If an entry named filename already exists, its attributes will be
4617 * updated with the given ones.
4619 * @param entry where to store the entry (optional)
4620 * @param filename Filename of the entry
4621 * @param id SHA1 id of the entry
4622 * @param attributes Folder attributes of the entry
4623 * @return 0 on success; error code otherwise
4625 [CCode (cname = "git_treebuilder_insert", instance_pos = 1.2)]
4626 public Error insert (out unowned TreeEntry? entry = null, string filename, object_id id, Attributes attributes);
4629 * Get an entry from the builder from its filename
4630 * @param filename Name of the entry
4631 * @return the entry; null if not found
4633 [CCode (cname = "git_treebuilder_get")]
4634 public unowned TreeEntry? get (string filename);
4637 * Remove an entry from the builder by its filename
4639 * @param filename Filename of the entry to remove
4641 [CCode (cname = "git_treebuilder_remove")]
4642 public Error remove (string filename);
4646 * Representation of each one of the entries in a tree object.
4648 [CCode (cname = "git_tree_entry", has_type_id = false, free_function = "git_tree_entry_free", copy_function = "git_tree_entry_dup")]
4650 public class TreeEntry {
4653 * The id of the object pointed by the entry
4655 public unowned object_id? id {
4656 [CCode (cname = "git_tree_entry_id")]
4661 * The filename of a tree entry
4663 public string name {
4664 [CCode (cname = "git_tree_entry_name")]
4669 * The UNIX file attributes of a tree entry
4671 public FileMode mode {
4672 [CCode (cname = "git_tree_entry_filemode")]
4677 * The type of the object pointed by the entry
4679 public ObjectType type {
4680 [CCode (cname = "git_tree_entry_type")]
4684 * Compare two tree entries
4686 * @param that second tree entry
4687 * @return <0 if this is before that, 0 if this == that, >0 if this is after that
4689 [CCode (cname = "git_tree_entry_cmp")]
4690 public int cmp (TreeEntry that);
4693 * Create a new tree builder.
4695 * The tree builder can be used to create or modify trees in memory and
4696 * write them as tree objects to the database.
4698 * The tree builder will be initialized with the entries of the given tree.
4700 * @param builder where to store the tree builder
4702 [CCode (cname = "git_treebuilder_create", instance_pos = -1)]
4703 public Error create_builder (out TreeBuilder builder);
4705 * Create a copy of a tree entry.
4707 [CCode (cname = "git_tree_entry_dup")]
4708 public TreeEntry dup ();
4712 * List of unmerged index entries
4714 [CCode (cname = "git_index", has_type_id = false)]
4716 public class ReucIndex {
4718 * The count of unmerged entries currently in the index
4721 [CCode (cname = "git_index_reuc_entrycount")]
4725 * Adds a resolve undo entry for a file based on the given parameters.
4727 * The resolve undo entry contains the OIDs of files that were involved in
4728 * a merge conflict after the conflict has been resolved. This allows
4729 * conflicts to be re-resolved later.
4731 * If there exists a resolve undo entry for the given path in the index, it
4734 * This method will fail in bare index instances.
4736 * @param path filename to add
4737 * @param ancestor_mode mode of the ancestor file
4738 * @param ancestor_id oid of the ancestor file
4739 * @param our_mode mode of our file
4740 * @param our_id oid of our file
4741 * @param their_mode mode of their file
4742 * @param their_id oid of their file
4744 [CCode (cname = "git_index_reuc_add")]
4745 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);
4748 * Remove all resolve undo entries from the index
4750 [CCode (cname = "git_index_reuc_clear")]
4751 public void clear ();
4754 * Finds the resolve undo entry that points to the given path in the Git
4757 * @param path path to search
4758 * @return an index >= 0 if found, -1 otherwise
4760 [CCode (cname = "git_index_reuc_find")]
4761 public Error find (string path);
4764 * Get an unmerged entry from the index.
4766 * @param n the position of the entry
4767 * @return a pointer to the unmerged entry; null if out of bounds
4769 [CCode (cname = "git_index_reuc_get_byindex")]
4770 public unowned index_reuc_entry? get (uint n);
4773 * Get an unmerged entry from the index.
4775 * @param path path to search
4776 * @return the unmerged entry; null if not found
4778 [CCode (cname = "git_index_reuc_get_bypath")]
4779 public unowned index_reuc_entry? get_by_path (string path);
4782 * Remove an resolve undo entry from the index
4784 * @param n position of the resolve undo entry to remove
4786 [CCode (cname = "git_index_reuc_remove")]
4787 public Error remove (size_t n);
4789 [CCode (cname = "git_checkout_opts", has_type_id = false, default_value = "GIT_CHECKOUT_OPTS_INIT")]
4790 public struct checkout_opts {
4791 [CCode (cname = "GIT_CHECKOUT_OPTS_VERSION")]
4792 public const uint VERSION;
4794 public uint version;
4795 public unowned CheckoutStategy checkout_strategy;
4796 public bool disable_filters;
4800 * If set to 0, the default is 0755 used.
4802 public int dir_mode;
4806 * If set to 0, the default is 0644 is used.
4808 public int file_mode;
4810 * File open(3) flags.
4812 * If set to 0, the default is O_CREAT | O_TRUNC | O_WRONLY is used.
4814 public int file_open_flags;
4815 public CheckoutNotify notify_flags;
4816 [CCode (cname = "notify_cb", delegate_target_cname = "notify_payload")]
4817 public unowned CheckoutNotify? notify;
4820 * Notify the consumer of checkout progress.
4822 [CCode (cname = "progress_cb", delegate_target_cname = "progress_payload")]
4823 public unowned Progress? progress;
4826 * When not null, arrays of fnmatch pattern specifying which paths should be taken into account
4828 public string_array paths;
4830 * Expected content of workdir, defaults to HEAD
4832 public unowned Tree? baseline;
4834 * Alternative checkout path to workdir
4836 public unowned string? target_directory;
4839 [CCode (cname = "git_config_entry", has_type_id = false)]
4840 public struct config_entry {
4842 public string @value;
4843 public ConfigLevel level;
4847 * Clone options structure
4849 [CCode (cname = "git_clone_options", has_type_id = false, default_value = "GIT_CLONE_OPTIONS_INIT")]
4850 public struct clone_opts {
4851 [CCode (cname = "GIT_CLONE_OPTIONS_VERSION")]
4852 public const uint VERSION;
4853 public uint version;
4854 public checkout_opts checkout_opts;
4856 * False to create a standard repo, true for a bare repo.
4859 [CCode (cname = "fetch_progress_cb", delegate_target_cname = "fetch_progress_payload")]
4860 public unowned TransferProgress? fetch_progress;
4863 * The name given to the "origin" remote.
4865 * The default is "origin".
4867 public string? remote_name;
4869 * The URL to be used for pushing.
4871 * If unset, the fetch URL will be used.
4873 public string? pushurl;
4875 * The fetch specification to be used for fetching.
4877 * If unset, "+refs/heads/ *:refs/remotes/<remote_name>/ *"
4879 public string? fetch_spec;
4881 * The fetch specification to be used for pushing.
4883 * If unset, the same spec as for fetching.
4885 public string? push_spec;
4887 * Callback to be used if credentials are required during the initial
4890 [CCode (cname = "git_cred_acquire_cb", delegate_target_cname = "cred_acquire_payload")]
4891 public unowned CredAcquire cred_acquire;
4893 * A custom transport to be used for the initial fetch.
4895 * If unset, the transport autodetected from the URL.
4897 public unowned transport? transport;
4898 public TransportFlags transport_flags;
4900 * May be used to specify custom progress callbacks for the origin remote
4901 * before the fetch is initiated.
4903 public unowned remote_callbacks? remote_callbacks;
4905 * May be used to specify the autotag setting before the initial fetch.
4907 AutoTag remote_autotag;
4909 * Gives the name of the branch to checkout.
4911 * If unset, use the remote's HEAD.
4913 public string? checkout_branch;
4916 [CCode (cname = "git_cvar_map", has_type_id = false)]
4917 public struct config_var_map {
4918 public ConfigVar cvar_type;
4919 public string? str_match;
4920 public int map_value;
4922 [CCode (cname = "git_cred")]
4923 public struct cred {
4924 public CredTypes credtype;
4925 public CredFree free;
4928 * Creates a new plain-text username and password credential object.
4930 * @param username The username of the credential.
4931 * @param password The password of the credential.
4933 [CCode (cname = "git_cred_userpass_plaintext_new")]
4934 public static Error create_userpass_plaintext (out cred? cred, string username, string password);
4936 [CCode (cname = "git_cred_userpass_payload", has_type_id = false)]
4937 public struct cred_userpass {
4938 public string username;
4939 public string password;
4941 * Method usable as {@link CredAcquire}.
4943 * This calls {@link cred.create_userpass_plaintext} unless the protocol
4944 * has not specified {@link CredTypes.USERPASS_PLAINTEXT} as an allowed
4947 * @param cred The newly created credential object.
4948 * @param url The resource for which we are demanding a credential.
4949 * @param username_from_url The username that was embedded in a "user@host"
4950 * remote url, or null if not included.
4952 [CCode (cname = "git_cred_userpass", instance_pos = -1)]
4953 public Error acquire (out cred? cred, string url, string? username_from_url, CredTypes allowed_types);
4957 * Description of changes to one entry.
4959 * When iterating over a diff list object, this will be passed to most
4960 * callback functions and you can use the contents to understand exactly what
4963 * The {@link diff_delta.old_file} repesents the "from" side of the diff and
4964 * the {@link diff_delta.new_file} repesents to "to" side of the diff. What
4965 * those means depend on the function that was used to generate the diff and
4966 * will be documented below. You can also use the {@link DiffFlags.REVERSE}
4967 * flag to flip it around.
4969 * Although the two sides of the delta are named "old_file" and "new_file",
4970 * they actually may correspond to entries that represent a file, a symbolic
4971 * link, a submodule commit id, or even a tree (if you are tracking type
4972 * changes or ignored/untracked directories).
4974 * Under some circumstances, in the name of efficiency, not all fields will
4975 * be filled in, but we generally try to fill in as much as possible.
4977 [CCode (cname = "git_diff_delta", has_type_id = false)]
4978 public struct diff_delta {
4979 public diff_file old_file;
4980 public diff_file new_file;
4981 public DeltaType status;
4983 * For RENAMED and COPIED, value 0-100
4985 public uint similarity;
4986 public DiffFlag flags;
4990 * Description of one side of a diff.
4991 * Although this is called a "file", it may actually represent a file, a
4992 * symbolic link, a submodule commit id, or even a tree (although that only
4993 * if you are tracking type changes or ignored/untracked directories).
4997 [CCode (cname = "git_diff_file", has_type_id = false)]
4998 public struct diff_file {
5002 * If the entry represents an absent side of a diff (e.g., the {@link diff_delta.old_file}
5003 * of a {@link DeltaType.ADDED} delta), then the oid will be zeroes.
5005 [CCode (cname = "oid")]
5006 public object_id id;
5008 * The path to the entry relative to the working directory of the
5012 public FileMode mode;
5014 * The size of the entry in bytes.
5017 public DiffFlag flags;
5021 * Structure describing options about how the diff should be executed.
5023 * Setting all values of the structure to zero will yield the default
5024 * values. Similarly, passing NULL for the options structure will
5025 * give the defaults. The default values are marked below.
5027 * Most of the parameters here are not actually supported at this time.
5029 [CCode (cname = "git_diff_options", has_type_id = false, default_value = "GIT_DIFF_OPTIONS_INIT")]
5030 public struct diff_options {
5031 [CCode (cname = "GIT_DIFF_OPTIONS_VERSION")]
5032 public const uint VERSION;
5034 * Version for the struct
5036 public uint version;
5037 public DiffFlags flags;
5039 * Number of lines of context to show around diffs
5041 public uint16 context_lines;
5043 * Min lines between diff hunks to merge them
5045 public uint16 interhunk_lines;
5047 * "Directory" to prefix to old file names (default "a")
5049 public string? old_prefix;
5051 * "Directory" to prefix to new file names (default "b")
5053 public string? new_prefix;
5055 * Array of paths / patterns to constrain diff
5057 * Defaults to all paths
5059 public string_array pathspec;
5061 * Maximum blob size to diff, above this treated as binary
5063 * Defaults to 512 MB.
5065 public uint64 max_size;
5069 * Structure describing a hunk of a diff.
5071 [CCode (cname = "git_diff_range", has_type_id = false)]
5072 public struct diff_range {
5073 public int old_start;
5074 public int old_lines;
5075 public int new_start;
5076 public int new_lines;
5079 [CCode (cname = "git_diff_find_options", has_type_id = false, default_value = "GIT_DIFF_FIND_OPTIONS_INIT ")]
5080 public struct find_options {
5081 [CCode (cname = "GIT_DIFF_FIND_OPTIONS_VERSION")]
5082 public const uint VERSION;
5083 public uint version;
5084 public DiffFind flags;
5086 * Similarity to consider a file renamed (default 50)
5088 public uint16 rename_threshold;
5090 * Similarity of modified to be eligible rename source (default 50)
5092 public uint16 rename_from_rewrite_threshold;
5094 * Similarity to consider a file a copy (default 50)
5096 public uint16 copy_threshold;
5098 * Similarity to split modify into delete/add pair (default 60)
5100 public uint16 break_rewrite_threshold;
5102 * Maximum similarity sources to examine (e.g., diff's '''-l''' option or
5103 * the '''diff.renameLimit''' config) (default 200)
5105 public size_t rename_limit;
5109 * Time used in a index entry
5111 [CCode (cname = "git_index_time", has_type_id = false)]
5112 public struct index_time {
5113 public int64 seconds;
5114 public uint nanoseconds;
5118 * A resolve undo entry in the index.
5120 [CCode (cname = "git_index_reuc_entry", has_type_id = false)]
5121 public struct index_reuc_entry {
5123 [CCode (cname = "oid")]
5124 public object_id id[3];
5129 * Extended options structure for {@link Repository.init_ext}.
5131 * This contains extra options that enable additional initialization
5134 [CCode (cname = "git_repository_init_options", has_type_id = false, default_value = "GIT_REPOSITORY_INIT_OPTIONS_INIT")]
5135 public struct init_options {
5137 * Use permissions configured by umask - the default.
5139 [CCode (cname = "GIT_REPOSITORY_INIT_SHARED_UMASK")]
5140 public const uint32 MODE_SHARED_UMASK;
5142 * Use '''--shared=group''' behavior, chmod'ing the new repo to be group
5143 * writable and "g+sx" for sticky group assignment.
5145 [CCode (cname = "GIT_REPOSITORY_INIT_SHARED_GROUP")]
5146 public const uint32 MODE_SHARED_GROUP;
5148 * Use '''--shared=all''' behavior, adding world readability.
5150 [CCode (cname = "GIT_REPOSITORY_INIT_SHARED_ALL")]
5151 public const uint32 MODE_SHARED_ALL;
5152 [CCode (cname = "GIT_REPOSITORY_INIT_OPTIONS_VERSION")]
5153 public const uint VERSION;
5154 public uint version;
5155 public InitFlag flags;
5157 * The UNIX file mode.
5159 * The standard values are {@link MODE_SHARED_UMASK},
5160 * {@link MODE_SHARED_GROUP}, or {@link MODE_SHARED_ALL}, but a custom
5161 * value may be used instead.
5165 * The path to the working dir or null for default (i.e., the repoistory
5166 * path's parent on non-bare repos).
5168 * If this is relative path, it will be evaluated relative to the
5171 * If this is not the natural working directory, a .git gitlink file will
5172 * be created here linking to the repoitory path.
5174 public string? workdir_path;
5176 * If set, this will be used to initialize the '''description''' file in
5177 * the repository, instead of using the template content.
5179 public string? description;
5181 * When {@link InitFlag.EXTERNAL_TEMPLATE} is set, this contains the path
5182 * to use for the template directory.
5184 * If this is null, the config or default directory options will be used
5187 public string? template_path;
5189 * The name of the head to point HEAD at. If null, then this will be
5190 * treated as '''master''' and the HEAD ref will be set to
5191 * '''refs/heads/master'''. If this begins with '''refs/''' it will be
5192 * used verbatim; otherwise '''refs/heads/''' will be prefixed.
5194 public string? initial_head;
5196 * If this is non-null, then after the rest of the repository
5197 * initialization is completed, an '''origin''' remote will be added
5198 * pointing to this URL.
5200 public string? origin_url;
5204 * Unique identity of any object (commit, tree, blob, tag).
5206 [CCode (cname = "git_oid", has_type_id = false)]
5207 public struct object_id {
5209 * Raw binary formatted id
5213 [CCode (cname = "GIT_OID_HEX_ZERO")]
5214 public const string HEX_ZERO;
5217 * Size (in bytes) of a raw/binary id
5219 [CCode (cname = "GIT_OID_RAWSZ")]
5220 public const int RAW_SIZE;
5223 * Size (in bytes) of a hex formatted id
5225 [CCode (cname = "GIT_OID_HEXSZ")]
5226 public const int HEX_SIZE;
5229 * Minimum length (in number of hex characters,
5230 * (i.e., packets of 4 bits) of an id prefix
5232 [CCode (cname = "GIT_OID_MINPREFIXLEN")]
5233 public const int MIN_PREFIX_LENGTH;
5236 * Parse a hex formatted null-terminated string.
5238 * @param id id structure the result is written into.
5239 * @param str input hex string; must be at least 4 characters long.
5241 [CCode (cname = "git_oid_fromstrp")]
5242 public static Error from_string (out object_id id, string str);
5245 * Parse a hex formatted object id
5247 * @param id id structure the result is written into.
5248 * @param str input hex string; must be pointing at the start of the hex
5249 * sequence and have at least the number of bytes needed for an id encoded
5250 * in hex (40 bytes).
5251 * @return {@link Error.OK} if valid, {@link Error.NOTID} on failure.
5253 [CCode (cname = "git_oid_fromstr")]
5254 public static Error from_string_exact (out object_id id, string str);
5257 * Parse N characters of a hex formatted object id
5259 * If N is odd, N-1 characters will be parsed instead.
5260 * The remaining space in the git_oid will be set to zero.
5262 * @param id id structure the result is written into.
5263 * @param data input hex string
5264 * @return {@link Error.OK} if valid.
5266 [CCode (cname = "git_oid_fromstrn")]
5267 public static Error from_array (out object_id id, [CCode (array_length_type = "size_t")] uint8[] data);
5270 * Copy an already raw id
5272 [CCode (cname = "git_oid_fromraw")]
5273 public static void from_raw (out object_id id, [CCode (array_length = false)] uint8[] raw);
5276 * Format an id into a hex string.
5278 * @param str output hex string; must be pointing at the start of the hex
5279 * sequence and have at least the number of bytes needed for an id encoded
5280 * in hex (40 bytes). Only the id digits are written; a nul terminator must
5281 * be added by the caller if it is required.
5283 [CCode (cname = "git_oid_fmt", instance_pos = -1)]
5284 public void to_buffer ([CCode (array_length = false)] char[] str);
5287 * Format an id into a loose-object path string.
5289 * The resulting string is "aa/...", where "aa" is the first two
5290 * hex digitis of the id and "..." is the remaining 38 digits.
5292 * @param str output hex string; must be pointing at the start of the hex
5293 * sequence and have at least the number of bytes needed for an oid encoded
5294 * in hex (41 bytes). Only the id digits are written; a nul terminator
5295 * must be added by the caller if it is required.
5297 [CCode (cname = "git_oid_pathfmt", instance_pos = -1)]
5298 public void to_path ([CCode (array_length = false)] char[] str);
5301 * Format an id into a string.
5303 * @return the string; null if memory is exhausted.
5305 [CCode (cname = "git_oid_allocfmt")]
5306 public string? to_string ();
5309 * Format an id into a buffer as a hex format string.
5311 * If the buffer is smaller than {@link HEX_SIZE}+1, then the resulting
5312 * id string will be truncated to data.length-1 characters. If there are
5313 * any input parameter errors, then a pointer to an empty string is returned,
5314 * so that the return value can always be printed.
5316 * @param buffer the buffer into which the id string is output.
5317 * @return the out buffer pointer, assuming no input parameter errors,
5318 * otherwise a pointer to an empty string.
5320 [CCode (cname = "git_oid_tostr", instance_pos = -1)]
5321 public unowned string to_string_buffer ([CCode (array_length_type = "size_t")] char[] buffer);
5324 * Copy an id from one structure to another.
5326 * @param dest id structure the result is written into.
5327 * @param src id structure to copy from.
5329 [CCode (cname = "git_oid_cpy")]
5330 public static void copy (out object_id dest, object_id src);
5333 * Copy an id from one structure to another.
5335 * @param dest id structure the result is written into.
5337 [CCode (cname = "git_oid_cpy", instance_pos = -1)]
5338 public void copy_to (out object_id dest);
5341 * Compare two id structures.
5343 * @param a first id structure.
5344 * @param b second id structure.
5345 * @return <0, 0, >0 if a < b, a == b, a > b.
5347 [CCode (cname = "git_oid_cmp")]
5348 public static int compare (object_id a, object_id b);
5351 * Compare two id structures.
5353 * @param b second id structure.
5354 * @return <0, 0, >0 if a < b, a == b, a > b.
5356 [CCode (cname = "git_oid_cmp")]
5357 public int compare_to (object_id b);
5360 * Compare the first //len// hexadecimal characters (packets of 4 bits)
5361 * of two id structures.
5363 * @param a first id structure.
5364 * @param b second id structure.
5365 * @param len the number of hex chars to compare
5366 * @return 0 in case of a match
5368 [CCode (cname = "git_oid_ncmp")]
5369 public static int compare_n (object_id a, object_id b, size_t len);
5372 * Compare the first //len// hexadecimal characters (packets of 4 bits)
5373 * of two id structures.
5375 * @param b second id structure.
5376 * @param len the number of hex chars to compare
5377 * @return 0 in case of a match
5379 [CCode (cname = "git_oid_ncmp")]
5380 public int compare_n_to (object_id b, size_t len);
5383 * Check if an oid equals an hex formatted object id.
5385 * @param str input hex string of an object id.
5386 * @return {@link Error.OK} in case of a match, {@link Error.ERROR} otherwise.
5388 [CCode (cname = "git_oid_streq")]
5389 public Error compare_string (string str);
5391 * Compare two oid structures for equality
5393 * @param a first id structure.
5394 * @param b second id structure.
5395 * @return true if equal, false otherwise
5397 [CCode (cname = "git_oid_equal")]
5398 public static bool equal (object_id a, object_id b);
5400 * Compare two oid structures for equality
5402 * @param b second id structure.
5403 * @return true if equal, false otherwise
5405 [CCode (cname = "git_oid_equal")]
5406 public bool equal_to (object_id b);
5409 * Determine the id of a buffer containing an object
5411 * The resulting id will the itentifier for the data
5412 * buffer as if the data buffer it were to written to the ODB.
5414 * @param id the resulting id.
5415 * @param data data to hash
5416 * @param type of the data to hash
5418 [CCode (cname = "git_odb_hash")]
5419 public static Error from_data (out object_id id, [CCode (array_length_type = "size_t")] uint8[] data, ObjectType type);
5422 * Read a file from disk and determine the id
5424 * Read the file and compute the id have if it were
5425 * written to the database as an object of the given type.
5426 * Similar functionality to git's //git hash-object// without
5429 * @param id id structure the result is written into.
5430 * @param path file to read and determine object id for
5431 * @param type the type of the object that will be hashed
5433 [CCode (cname = "git_odb_hashfile")]
5434 public static Error hashfile (out object_id id, string path, ObjectType type);
5436 * Check is an oid is all zeros.
5438 [CCode (cname = "git_oid_iszero")]
5439 public bool is_zero ();
5442 * Controls the behavior of a {@link Push} object.
5444 [CCode (cname = "git_push_options", has_type_id = false, default_value = "GIT_PUSH_OPTIONS_INIT")]
5445 public struct push_options {
5446 [CCode (cname = "GIT_PUSH_OPTIONS_VERSION")]
5447 public const uint VERSION;
5448 public uint version;
5450 * If the transport being used to push to the remote requires the creation
5451 * of a pack file, this controls the number of worker threads used by the
5452 * packbuilder when creating that pack file to be sent to the remote.
5454 * If set to false, the packbuilder will auto-detect the number of threads
5455 * to create. The default value is true.
5457 public bool pb_parallelism;
5459 [CCode (cname = "struct git_refdb_backend", default_value = "GIT_ODB_BACKEND_INIT", has_type_id = false)]
5460 public struct refdb_backend {
5461 [CCode (cname = "GIT_ODB_BACKEND_VERSION")]
5462 public const uint VERSION;
5463 public uint version;
5464 public RefDbCompress? compress;
5465 public RefDbDelete @delete;
5466 public RefDbExists exists;
5467 public RefDbForEach @foreach;
5468 public RefDbForEachGlob? foreach_glob;
5469 public RefDbFree? free;
5470 public RefDbLookup lookup;
5471 public RefDbWrite write;
5473 * Constructors for default refdb backend.
5475 [CCode (cname = "git_refdb_backend_fs")]
5476 public static Error create_backend_fs (out refdb_backend? backend, Repository repo, RefDb refdb);
5479 * Reference specification (i.e., some kind of local or remote branch)
5481 [CCode (cname = "git_refspec", has_type_id = false, destroy_function = "")]
5482 public struct ref_spec {
5484 * The destination specifier
5486 public string destination {
5487 [CCode (cname = "git_refspec_dst")]
5491 * The force update setting
5493 public bool is_forced {
5494 [CCode (cname = "git_refspec_force")]
5499 * The source specifier
5501 public string source {
5502 [CCode (cname = "git_refspec_src")]
5507 * Check if a refspec's source descriptor matches a reference name
5509 * @param refname the name of the reference to check
5511 [CCode (cname = "git_refspec_src_matches")]
5512 public bool matches_source (string refname);
5515 * Check if a refspec's destination descriptor matches a reference
5517 * @param refname the name of the reference to check
5519 [CCode (cname = "git_refspec_dst_matches")]
5520 public bool matches_destination (string refname);
5523 * Transform a target reference to its source reference following the refspec's rules
5525 * @param refname where to store the source reference name
5526 * @param name the name of the reference to transform
5528 [CCode (cname = "git_refspec_rtransform", instance_pos = 1.2)]
5529 public Error rtransform ([CCode (array_length_type = "size_t")] uint8[] refname, string name);
5532 * Transform a reference to its target following the refspec's rules
5534 * @param buffer where to store the target name
5535 * @param name the name of the reference to transform
5536 * @return {@link Error.OK}, {@link Error.SHORTBUFFER} or another error
5538 [CCode (cname = "git_refspec_transform", instance_pos = 1.3)]
5539 public Error transform ([CCode (array_length_type = "size_t")] char[] buffer, string name);
5541 * Get the refspec's string
5543 [CCode (cname = "git_refspec_string")]
5544 public unowned string to_string ();
5548 * Remote head description, given out on //ls// calls.
5550 [CCode (cname = "struct git_remote_head", has_type_id = false)]
5551 public struct remote_head {
5553 [CCode (cname = "oid")]
5554 public object_id id;
5555 [CCode (cname = "loid")]
5556 public object_id l_id;
5557 public unowned string name;
5560 [CCode (cname = "git_remote_callbacks", simple_generics = true, default_value = "GIT_REMOTE_CALLBACKS_INIT", has_type_id = false)]
5561 public struct remote_callbacks<T> {
5562 [CCode (cname = "GIT_REMOTE_CALLBACKS_VERSION")]
5563 public const uint VERSION;
5565 public uint version;
5566 public RemoteProgress<T>? progress;
5567 public RemoteCompletion<T>? completion;
5568 public RemoteUpdateTips<T>? update_tips;
5570 [CCode (simple_generics = true)]
5576 [CCode (cname = "git_revspec", has_type_id = false)]
5577 public struct revspec {
5579 * The left element of the revspec
5583 * The right element of the revspec
5590 * The smart transport knows how to speak the git protocol, but it has no
5591 * knowledge of how to establish a connection between it and another
5592 * endpoint, or how to move data back and forth.
5594 * For this, a subtransport interface is declared, and the smart transport
5595 * delegates this work to the subtransports. Three subtransports are
5596 * implemented: git, http, and winhttp. (The http and winhttp transports each
5597 * implement both http and https.)
5599 * Subtransports can either be persistent or stateless (request/response).
5600 * The smart transport handles the differences in its own logic.
5602 [CCode (cname = "git_smart_subtransport")]
5603 public struct smart_subtransport {
5604 public SubTransportAction action;
5607 * Subtransports are guaranteed a call to {@link close} between calls to
5608 * {@link action}, except for the following two natural progressions of
5609 * actions against a constant URL.
5611 * 1. {@link SmartService.UPLOADPACK_LS} → {@link SmartService.UPLOADPACK}
5612 * 2. {@link SmartService.RECEIVEPACK_LS} → {@link SmartService.RECEIVEPACK}
5614 public SubTransportClose close;
5615 public SubTransportFree free;
5617 [CCode (cname = "git_smart_subtransport_definition")]
5618 public struct smart_subtransport_definition {
5620 * Create an instance of the smart transport.
5622 * @param owner The {@link Remote} which will own this transport
5624 [CCode (cname = "git_transport_smart", instance_pos = -1)]
5625 public Error create_transport (out transport? transport, Remote owner);
5628 * The function to use to create the subtransport
5630 public CreateSubTransport callback;
5633 * Is the protocol is stateless.
5635 * For example, http:// is stateless, but git:// is not.
5637 [CCode (cname = "rpc")]
5641 * A stream used by the smart transport to read and write data from a
5644 [CCode (cname = "git_smart_subtransport_stream")]
5645 public struct smart_subtransport_stream {
5647 * The owning subtransport
5649 public unowned smart_subtransport? subtransport;
5650 public SubTransportStreamRead read;
5651 public SubTransportStreamWrite write;
5652 public SubTransportStreamFree free;
5654 [CCode (cname = "git_status_options", has_type_id = false, default_value = "GIT_STATUS_OPTIONS_INIT")]
5655 public struct status_options {
5656 [CCode (cname = "GIT_STATUS_OPTIONS_VERSION")]
5657 public const uint VERSION;
5659 public uint version;
5661 StatusControl flags;
5663 * The path patterns to match (using fnmatch-style matching), or just an
5664 * array of paths to match exactly if {@link DiffFlags.DISABLE_PATHSPEC_MATCH}
5665 * is specified in the flags.
5667 string_array pathspec;
5671 * Collection of strings
5673 [CCode (cname = "git_strarray", destroy_function = "git_strarray_free", has_type_id = false)]
5674 public struct string_array {
5675 [CCode (array_length_cname = "count", array_length_type = "size_t")]
5677 [CCode (cname = "git_strarray_copy", instance_pos = -1)]
5678 public Error copy (out string_array target);
5682 * Time in a signature
5684 [CCode (cname = "git_time", has_type_id = false)]
5685 public struct time {
5687 * time in seconds from epoch
5691 * timezone offset, in minutes
5695 [CCode (cname = "git_transfer_progress", has_type_id = false)]
5696 public struct transfer_progress {
5697 public uint total_objects;
5698 public uint indexed_objects;
5699 public uint received_objects;
5700 public size_t received_bytes;
5702 [CCode (cname = "git_transport", has_type_id = false, default_value = "GIT_TRANSPORT_INIT ")]
5703 public struct transport {
5704 [CCode (cname = "GIT_TRANSPORT_VERSION")]
5705 public const uint VERSION;
5706 public uint version;
5708 * Set progress and error callbacks
5710 public TransportSetCallbacks set_callbacks;
5712 * Connect the transport to the remote repository, using the given
5715 public TransportConnect connect;
5717 * This function may be called after a successful call to {@link connect}.
5719 * The provided callback is invoked for each ref discovered on the remote
5722 public TransportList ls;
5724 * Executes the push whose context is in a {@link Push} object.
5726 public TransportPush push;
5728 * The function performs a negotiation to calculate the wants list for the
5731 * This function may be called after a successful call to {@link connect},
5732 * when the direction is FETCH.
5734 public TransportNegotiatFetch negotiate_fetch;
5736 * This function retrieves the pack file for the fetch from the remote end.
5738 * This function may be called after a successful call to
5739 * {@link negotiate_fetch}, when the direction is FETCH.
5741 public TransportDownloadPack download_pack;
5743 * Checks to see if the transport is connected
5745 public TransportIsConnected is_connected;
5747 * Reads the flags value previously passed into {@link connect}
5749 public TransportReadFlags read_flags;
5751 * Cancels any outstanding transport operation
5753 public TransportCancel cancel;
5755 * This function is the reverse of {@link connect} – it terminates the
5756 * connection to the remote end.
5758 public TransportClose close;
5760 * Frees/destructs the transport object.
5762 public TransportFree free;
5765 * Function to use to create a transport from a URL.
5767 * The transport database is scanned to find a transport that implements
5768 * the scheme of the URI (e.g., git:// or http://) and a transport object
5769 * is returned to the caller.
5771 * @param owner The {@link Remote} which will own this transport
5772 * @param url The URL to connect to
5774 [CCode (cname = "git_transport_new")]
5775 public static Error create (out transport? transport, Remote owner, string url);
5778 * Create an instance of the dummy transport.
5780 * @param owner The {@link Remote} which will own this transport
5781 * @param payload You must pass null for this parameter.
5783 [CCode (cname = "git_transport_dummy")]
5784 public static Error create_dummy (out transport? transport, Remote owner, void* payload = null);
5786 * Create an instance of the local transport.
5788 * @param owner The {@link Remote} which will own this transport
5789 * @param payload You must pass null for this parameter.
5791 [CCode (cname = "git_transport_local")]
5792 public static Error create_local (out transport? transport, Remote owner, void* payload = null);
5795 * Create an instance of the http subtransport.
5797 * This subtransport also supports https. On Win32, this subtransport may
5798 * be implemented using the WinHTTP library.
5800 [CCode (cname = "git_smart_subtransport_http", instance_pos = -1)]
5801 public Error create_http_subtransport (out smart_subtransport? subtransport);
5804 * Create an instance of the git subtransport.
5806 [CCode (cname = "git_smart_subtransport_git", instance_pos = -1)]
5807 public Error create_git_subtransport (out smart_subtransport? subtransport);
5811 * Default port for git: protocol.
5813 [CCode (cname = "GIT_DEFAULT_PORT")]
5814 public const string DEFAULT_PORT;
5817 * The separator used in path list strings.
5819 * For instance, in the //$PATH// environment variable). A semi-colon ";"
5820 * is used on Windows, and a colon ":" for all other systems.
5822 [CCode (cname = "GIT_PATH_LIST_SEPARATOR")]
5823 public const char PATH_LIST_SEPARATOR;
5826 * The maximum length of a git valid git path.
5828 [CCode (cname = "GIT_PATH_MAX")]
5829 public const int PATH_MAX;
5831 [CCode (cname = "uint32_t", cprefix = "GIT_ATTR_CHECK_", has_type_id = false)]
5833 public enum AttrCheck {
5835 * Reading values from index and working directory.
5837 * When checking attributes, it is possible to check attribute files
5838 * in both the working directory (if there is one) and the index (if
5839 * there is one). You can explicitly choose where to check and in
5840 * which order using the following flags.
5842 * Core git usually checks the working directory then the index,
5843 * except during a checkout when it checks the index first. It will
5844 * use index only for creating archives or for a bare repo (if an
5845 * index has been specified for the bare repo).
5849 * @see FILE_THEN_INDEX
5853 * @see FILE_THEN_INDEX
5857 * Using the system attributes file.
5859 * Normally, attribute checks include looking in the /etc (or system
5860 * equivalent) directory for a `gitattributes` file. Passing this
5861 * flag will cause attribute checks to ignore that file.
5867 * States for a file in the index
5869 [CCode (cname = "int", cprefix = "GIT_IDXENTRY_", has_type_id = false)]
5871 public enum Attributes {
5889 [CCode (cname = "git_remote_autotag_option_t", cprefix = "GIT_REMOTE_DOWNLOAD_TAGS_", has_type_id = false)]
5890 public enum AutoTag {
5898 * Basic type of any Git branch.
5900 [CCode (cname = "git_branch_t", cprefix = "GIT_BRANCH_", has_type_id = false)]
5902 public enum BranchType {
5907 * Combinations of these values describe the capabilities of libgit2.
5909 [CCode (cname = "git_cap_t", cprefix = "GIT_CAP_", has_type_id = false)]
5910 public enum Capabilities {
5912 * Libgit2 was compiled with thread support.
5914 * Note that thread support is still to be seen as a 'work in progress'.
5918 * Libgit2 supports the https protocol.
5920 * This requires the OpenSSL library to be found when compiling libgit2.
5924 * Query compile time options for libgit2.
5926 [CCode (cname = "git_libgit2_capabilities")]
5927 public static Capabilities get ();
5930 * Options for which cases to invoke notification callback.
5932 [CCode (cname = "git_checkout_notify_t", has_type_id = false, cprefix = "GIT_CHECKOUT_NOTIFY_")]
5934 public enum CheckoutNotify {
5937 * Invokes callback on conflicting paths.
5941 * Invokes callback to notify about "dirty" files, i.e. those that do not
5942 * need an update but no longer match the baseline. Core git displays
5943 * these files when checkout runs, but won't stop the checkout.
5947 * Invokes callback to notify for any changed file.
5951 * Invokes callback to notify about untracked files.
5955 * Invokes callback to notify about ignored files.
5962 * Control what checkout does with files
5964 * No flags does a "dry run" where no files will be modified.
5966 * Checkout groups the working directory content into 3 classes of files: (1)
5967 * files that don't need a change, and files that do need a change that
5968 * either (2) we are allowed to modifed or (3) we are not. The flags you
5969 * pass in will decide which files we are allowed to modify.
5971 * By default, checkout is not allowed to modify any files. Anything needing
5972 * a change would be considered a conflict.
5974 * If any files need update but are disallowed by the strategy, normally
5975 * checkout calls the conflict callback (if given) and then aborts.
5977 * Any unmerged entries in the index are automatically considered conflicts.
5979 [CCode (cname = "git_checkout_strategy_t", has_type_id = false, cprefix = "GIT_CHECKOUT_")]
5981 public enum CheckoutStategy {
5983 * Dry run, no actual updates
5987 * Allow safe updates that cannot overwrite uncommited data
5991 * Allow safe updates plus creation of missing files
5995 * Allow all updates to force working directory to look like index
5999 * Allow checkout to make safe updates even if conflicts are found
6001 * It is okay to update the files that are allowed by the strategy even if
6002 * there are conflicts. The conflict callbacks are still made, but
6003 * non-conflicting files will be updated.
6007 * Remove untracked files not in index (that are not ignored)
6011 * Remove ignored files not in index
6015 * Only update existing files, don't create new ones
6019 * Normally checkout updates index entries as it goes; this stops that
6023 * Don't refresh index/config/etc before doing checkout
6027 * Treat pathspec as simple list of exact match file paths
6029 DISABLE_PATHSPEC_MATCH,
6031 * Ignore directories in use, they will be left empty.
6033 SKIP_LOCKED_DIRECTORIES,
6035 * Allow checkout to skip unmerged files (NOT IMPLEMENTED)
6040 * For unmerged files, checkout stage 3 from index (NOT IMPLEMENTED)
6044 * Recursively checkout submodules with same options (NOT IMPLEMENTED)
6048 * Recursively checkout submodules if HEAD moved in super repo (NOT IMPLEMENTED)
6050 UPDATE_SUBMODULES_IF_CHANGED
6054 * Priority level of a config file.
6056 * These priority levels correspond to the natural escalation logic (from
6057 * higher to lower) when searching for config entries in git.git.
6059 [CCode (cname = "git_config_level_t", cprefix = "GIT_CONFIG_LEVEL_", has_type_id = false)]
6060 public enum ConfigLevel {
6062 * System-wide configuration file.
6066 * XDG compatible configuration file: '''.config/git/config'''
6070 * User-specific configuration file, also called global configuration file.
6074 * Repository specific configuration file.
6078 * Represents the highest level of a config file.
6083 [CCode (cname = "git_cvar_t", cprefix = "GIT_CVAR_", has_type_id = false)]
6084 public enum ConfigVar {
6091 [CCode (cname = "git_credtype_t", cprefix = "GIT_CREDTYPE_", has_type_id = false)]
6093 public enum CredTypes {
6098 * What type of change is described?
6100 [CCode (cname = "git_delta_t", cprefix = "GIT_DELTA_", has_type_id = false)]
6101 public enum DeltaType {
6103 * Use in queries to include all delta types.
6105 [CCode (cname = "(-1)")]
6112 * Entry does not exist in old version
6116 * Entry does not exist in new version
6120 * Entry content changed between old and new
6124 * Entry was renamed between old and new
6128 * Entry was copied from another old entry
6132 * Entry is ignored item in workdir
6136 * Entry is untracked item in workdir
6140 * Type of entry changed between old and new
6144 * Look up the single character abbreviation for a delta status code.
6146 * When you call {@link DiffList.print_compact} it prints single letter
6147 * codes into the output such as 'A' for added, 'D' for deleted, 'M' for
6148 * modified, etc. It is sometimes convenient to convert a {@link DeltaType}
6149 * value into these letters for your own purposes. This function does just
6150 * that. By the way, unmodified will return a space (i.e. ' ').
6152 [CCode (cname = "git_diff_status_char")]
6153 public char to_char ();
6156 * Flags that can be set for the file on side of a diff.
6158 [CCode (cname = "uint32", cprefix = "GIT_DIFF_FLAG_", has_type_id = false)]
6160 public enum DiffFlag {
6162 * File(s) treated as binary data
6166 * File(s) treated as text data
6170 * Id value is known correct
6172 [CCode (cname = "GIT_DIFF_FLAG_VALID_OID")]
6176 * Control the behavior of diff rename/copy detection.
6178 [CCode (cname = "unsigned int", cprefix = "GIT_DIFF_FIND_", has_type_id = false)]
6180 public enum DiffFind {
6186 * Consider old side of modified for renames?
6188 RENAMES_FROM_REWRITES,
6194 * Consider unmodified as copy sources?
6196 COPIES_FROM_UNMODIFIED,
6198 * Split large rewrites into delete/add pairs.
6202 * Turn on all finding features
6206 * Measure similarity ignoring leading whitespace (default)
6208 IGNORE_LEADING_WHITESPACE,
6210 * Measure similarity ignoring all whitespace
6214 * Measure similarity including all data
6216 DONT_IGNORE_WHITESPACE,
6218 * Measure similarity only by comparing SHAs (fast and cheap)
6223 [CCode (cname = "uint32_t", cprefix = "GIT_DIFF_", has_type_id = false)]
6225 public enum DiffFlags {
6227 * Normal diff, the default
6231 * Reverse the sides of the diff
6235 * Treat all files as text, disabling binary attributes & detection
6239 * Ignore all whitespace
6243 * Ignore changes in amount of whitespace
6245 IGNORE_WHITESPACE_CHANGE,
6247 * Ignore whitespace at end of line
6249 IGNORE_WHITESPACE_EOL,
6251 * Exclude submodules from the diff completely
6255 * Use the "patience diff" algorithm (currently unimplemented)
6259 * Include ignored files in the diff list
6263 * Include untracked files in the diff list
6267 * Include unmodified files in the diff list
6271 * Even with the {@link INCLUDE_UNTRACKED} flag, when an untracked
6272 * directory is found, only a single entry for the directory is added to
6273 * the diff list; with this flag, all files under the directory will be
6276 RECURSE_UNTRACKED_DIRS,
6278 * If the pathspec is set in the diff options, this flags means to apply it
6279 * as an exact match instead of as an fnmatch pattern.
6281 DISABLE_PATHSPEC_MATCH,
6283 * Use case insensitive filename comparisons
6287 * When generating patch text, include the content of untracked files
6289 INCLUDE_UNTRACKED_CONTENT,
6291 * Disable updating of the binary flag in delta records. This is useful
6292 * when iterating over a diff if you don't need hunk and data callbacks and
6293 * want to avoid having to load file completely.
6297 * Normally, a type change between files will be converted into a DELETED
6298 * record for the old and an ADDED record for the new; this options enabled
6299 * the generation of TYPECHANGE delta records.
6303 * Even with {@link INCLUDE_TYPECHANGE}, blob to tree changes still
6304 * generally show as a DELETED blob. This flag tries to correctly label
6305 * blob to tree transitions as TYPECHANGE records with the new file's mode
6308 * Note: the tree SHA will not be available.
6310 INCLUDE_TYPECHANGE_TREES,
6312 * Ignore file mode changes
6316 * Even with {@link INCLUDE_IGNORED}, an entire ignored directory will be
6317 * marked with only a single entry in the diff list; this flag adds all
6318 * files under the directory as IGNORED entries, too.
6320 RECURSE_IGNORED_DIRS,
6322 * Core Git scans inside untracked directories, labeling them IGNORED if
6323 * they are empty or only contain ignored files.
6325 * A directory is consider UNTRACKED only if it has an actual untracked
6326 * file in it. This scan is extra work for a case you often don't care
6327 * about. This flag makes libgit2 immediately label an untracked directory
6328 * as UNTRACKED without looking inside it (which differs from core Git).
6329 * Of course, ignore rules are still checked for the directory itself.
6331 FAST_UNTRACKED_DIRS,
6332 /** Treat all files as binary, disabling text diffs */
6338 * Line origin constants.
6340 * These values describe where a line came from and will be passed to
6341 * the {@link DiffLine} when iterating over a diff. There are some
6342 * special origin contants at the end that are used for the text
6343 * output callbacks to demarcate lines that are actually part of
6344 * the file or hunk headers.
6346 [CCode (cname = "char", cprefix = "GIT_DIFF_LINE_", has_type_id = false)]
6347 public enum DiffLineType {
6358 [CCode (cname = "")]
6359 public char to_char ();
6363 * Transfer direction in a transport
6365 [CCode (cname = "int", cprefix = "GIT_DIR_", has_type_id = false)]
6366 public enum Direction {
6371 * Return codes for many functions.
6373 [CCode (cname = "git_error_t", cprefix = "GIT_E", has_type_id = false)]
6375 [CCode (cname = "GIT_OK")]
6377 [CCode (cname = "GIT_ERROR")]
6380 * Input does not exist in the scope searched
6384 * A reference with this name already exists
6388 * The given integer literal is too large to be parsed
6392 * The given short {@link object_id} is ambiguous
6398 * Skip and passthrough the given ODB backend
6402 * The buffer is too short to satisfy the request
6406 * The revsion walk is complete.
6418 [CCode (cname = "git_error_class", cprefix = "GITERR_", has_type_id = false)]
6419 public enum ErrClass {
6443 * Set the error message string for this thread.
6445 * This function is public so that custom ODB backends and the like can
6446 * relay an error message through libgit2. Most regular users of libgit2
6447 * will never need to call this function -- actually, calling it in most
6448 * circumstances (for example, calling from within a callback function)
6449 * will just end up having the value overwritten by libgit2 internals.
6451 * This error message is stored in thread-local storage and only applies to
6452 * the particular thread that this libgit2 call is made from.
6454 * {@link ErrClass.OS} has a special behavior: we attempt to append the
6455 * system default error message for the last OS error that occurred and
6456 * then clear the last error. The specific implementation of looking up
6457 * and clearing this last OS error will vary by platform.
6459 * @param message The formatted error message to keep
6461 [CCode (cname = "giterr_set_str")]
6462 void raise (string message);
6465 * The UNIX file mode associated with a {@link TreeEntry}.
6467 * Consult the mode_t manual page.
6469 [CCode (cname = "unsigned int", cheader_filename = "sys/stat.h", cprefix = "S_I", has_type_id = false)]
6471 public enum FileMode {
6473 * This is the mask to isolate only the F modes.
6481 * A character device
6505 * Read, write, and execute by owner
6521 * Read, write, and execute by group
6537 * Read, write, and execute by others
6553 * Set user-id on execution
6557 * Set group-id on execution
6561 * Restricted delition on directories
6564 [CCode (cname = "S_ISBLK")]
6565 public bool is_block_dev ();
6566 [CCode (cname = "S_ISCHR")]
6567 public bool is_char_dev ();
6568 [CCode (cname = "S_ISDIR")]
6569 public bool is_dir ();
6570 [CCode (cname = "S_ISFIFO")]
6571 public bool is_fifo ();
6572 [CCode (cname = "S_ISREG")]
6573 public bool is_regular ();
6574 [CCode (cname = "S_ISLNK")]
6575 public bool is_link ();
6576 [CCode (cname = "S_ISSOCK")]
6577 public bool is_sock ();
6579 * Converts the format mode to an ls-style long mode.
6581 public string to_string () {
6583 switch (this & FileMode.FMT) {
6584 case FileMode.FBLK :
6588 case FileMode.FCHR :
6592 case FileMode.FDIR :
6596 case FileMode.FIFO :
6600 case FileMode.FLNK :
6604 case FileMode.FREG :
6608 case FileMode.FSOCK :
6616 attr[1] = check_mode (FileMode.RUSR, 'r');
6617 attr[2] = check_mode (FileMode.WUSR, 'w');
6618 attr[3] = check_mode_x (FileMode.RUSR, FileMode.SUID, 's');
6619 attr[4] = check_mode (FileMode.RGRP, 'r');
6620 attr[5] = check_mode (FileMode.WGRP, 'w');
6621 attr[6] = check_mode_x (FileMode.RGRP, FileMode.SGID, 's');
6622 attr[7] = check_mode (FileMode.ROTH, 'r');
6623 attr[8] = check_mode (FileMode.WOTH, 'w');
6624 attr[9] = check_mode_x (FileMode.ROTH, FileMode.SVTX, 't');
6626 return ((string) attr).dup ();
6628 char check_mode (FileMode mode, char symbol) {
6629 return mode in this ? symbol : '-';
6631 char check_mode_x (FileMode mode, FileMode modifier, char symbol) {
6632 if ((mode | modifier) in this) {
6633 return symbol.tolower ();
6635 if (modifier in this) {
6636 return symbol.toupper ();
6638 return mode in this ? 'x' : '-';
6642 * Capabilities of system that affect index actions.
6645 [CCode (cname = "unsigned int", cprefix = "GIT_INDEXCAP_", has_type_id = false)]
6646 public enum IndexCapability {
6651 * Read capabilites from the config of the owner object, looking at
6652 * '''core.ignorecase''', '''core.filemode''', '''core.symlinks'''.
6657 * Extra behaviors to {@link Repository.init_ext}.
6659 * In every case, the default behavior is the flag not set.
6662 [CCode (cname = "uint32_t", cprefix = "GIT_REPOSITORY_INIT_", has_type_id = false)]
6664 public enum InitFlag {
6666 * Create a bare repository with no working directory.
6670 * Return an {@link Error.EXISTS} error if the path appears to already be
6671 * an git repository.
6675 * Normally a '''/.git/''' will be appended to the repo path for non-bare
6676 * repos (if it is not already there), but passing this flag prevents that
6681 * Make the path (and working directory) as needed.
6683 * Init is always willing to create the '''.git''' directory even without
6684 * this flag. This flag tells init to create the trailing component of the
6685 * repo and workdir paths as needed.
6689 * Recursively make all components of the repo and workdir paths as
6694 * libgit2 normally uses internal templates to initialize a new repo. This
6695 * flags enables external templates, looking the '''template_path''' from
6696 * the options if set, or the '''init.templatedir''' global config if not,
6697 * or falling back on '''/usr/share/git-core/templates''' if it exists.
6702 * Basic type (loose or packed) of any git object
6704 [CCode (cname = "git_otype", cprefix = "GIT_OBJ_", has_type_id = false)]
6705 public enum ObjectType {
6707 * Object can be any of the following
6715 * Reserved for future use
6723 * A tree (directory listing) object
6727 * A file revision object
6731 * An annotated tag object
6735 * Reserved for future use
6739 * A delta, base is given by an offset
6743 * A delta, base is given by {@link object_id}
6747 * Convert an object type to its string representation
6749 [CCode (cname = "git_object_type2string")]
6750 public unowned string to_string ();
6753 * Parse a string containing an object type
6755 * @param str the string to convert
6756 * @return the corresponding object type
6758 [CCode (cname = "git_object_string2type")]
6759 public static ObjectType from_string (string str);
6762 * Determine if the given this type is a valid loose object type
6764 * @return true if the type represents a valid loose object type, false otherwise.
6766 [CCode (cname = "git_object_typeisloose")]
6767 public bool is_loose ();
6770 * Get the size in bytes for the structure which holding this object type
6772 [CCode (cname = "git_object__size")]
6773 public size_t get_size ();
6776 [CCode (cname = "unsigned int", cprefix = "GIT_REPOSITORY_OPEN_", has_type_id = false)]
6778 public enum OpenFlags {
6782 [CCode (cname = "unsigned int", cprefix = "GIT_REF_FORMAT_", has_type_id = false)]
6784 public enum ReferenceFormat {
6787 * Control whether one-level refnames are accepted
6789 * (i.e., refnames that do not contain multiple /-separated components)
6793 * Interpret the provided name as a reference pattern for a refspec (as
6794 * used with remote repositories).
6796 * If this option is enabled, the name is allowed to contain a single *
6797 * (<star>) in place of a one full pathname component (e.g., foo/<star>/bar
6798 * but not foo/bar<star>).
6803 * Basic type of any Git reference.
6805 [CCode (cname = "git_rtype", cprefix = "GIT_REF_", has_type_id = false)]
6807 public enum ReferenceType {
6813 * A reference which points at an object id
6815 [CCode (cname = "GIT_REF_OID")]
6818 * A reference which points at another reference
6824 * Which operation remote operation has finished.
6826 [CCode (cname = "git_remote_completion_type", cprefix = "GIT_REMOTE_COMPLETION_", has_type_id = false)]
6827 public enum CompletionType {
6834 * Kinds of reset operation.
6836 [CCode (cname = "git_reset_type", cprefix = "GIT_RESET_", has_type_id = false)]
6837 public enum ResetType {
6844 * The intended behavior of the spec passed to {@link Repository.parse_rev}.
6846 [CCode (cname = "unsigned int", has_type_id = false, cprefix = "GIT_REVPARSE_")]
6847 public enum RevParse {
6849 * The spec targeted a single object.
6853 * The spec targeted a range of commits.
6857 * The spec used the '...' operator, which invokes special semantics.
6863 * Actions that the smart transport can ask a subtransport to perform
6865 [CCode (cname = "git_smart_service_t", cprefix = "GIT_SERVICE_", has_type_id = false)]
6866 public enum SmartService {
6874 * Sort order for revision walking.
6876 [CCode (cname = "int", cprefix = "GIT_SORT_", has_type_id = false)]
6878 public enum Sorting {
6880 * Sort the repository contents in no particular ordering;
6881 * this sorting is arbitrary, implementation-specific
6882 * and subject to change at any time.
6883 * This is the default sorting for new walkers.
6887 * Sort the repository contents in topological order
6888 * (parents before children); this sorting mode
6889 * can be combined with time sorting.
6893 * Sort the repository contents by commit time;
6894 * this sorting mode can be combined with
6895 * topological sorting.
6899 * Iterate through the repository contents in reverse
6900 * order; this sorting mode can be combined with
6905 [CCode (cname = "unsigned int", cprefix = "GIT_STASH_", has_type_id = false)]
6907 public enum StashFlag {
6910 * All changes already added to the index are left intact in the working
6915 * All untracked files are also stashed and then cleaned up from the
6920 * All ignored files are also stashed and then cleaned up from the working
6926 [CCode (cname = "int", cprefix = "GIT_REPOSITORY_STATE_", has_type_id = false)]
6937 APPLY_MAILBOX_OR_REBASE
6941 * Working directory file status
6943 [CCode (cname = "int", cprefix = "GIT_STATUS_", has_type_id = false)]
6944 public enum Status {
6955 * Select the files on which to report status.
6957 [CCode (cname = "git_status_show_t", has_type_id = false, cprefix = "GIT_STATUS_SHOW_")]
6958 public enum StatusShow {
6960 * The rough equivalent of '''git status --porcelain''' where each file
6961 * will receive a callback indicating its status in the index and in the
6966 * Only make callbacks for index side of status.
6968 * The status of the index contents relative to the HEAD will be given.
6972 * Only make callbacks for the workdir side of status, reporting the status
6973 * of workdir content relative to the index.
6977 * Behave like index-only followed by workdir-only, causing two callbacks
6978 * to be issued per file (first index then workdir).
6980 * This is slightly more efficient than making separate calls. This makes
6981 * it easier to emulate the output of a plain '''git status'''.
6987 * Flags to control status callbacks
6989 [CCode (cname = "unsigned int", cprefix = "GIT_STATUS_OPT_", has_type_id = false)]
6990 public enum StatusControl {
6992 * Callbacks should be made on untracked files.
6994 * These will only be made if the workdir files are included in the status
6999 * Ignored files should get callbacks.
7001 * These callbacks will only be made if the workdir files are included in
7002 * the status "show" option. Right now, there is no option to include all
7003 * files in directories that are ignored completely.
7007 * Callbacks should be made even on unmodified files.
7011 * Directories which appear to be submodules should just be skipped over.
7015 * The contents of untracked directories should be included in the status.
7017 * Normally if an entire directory is new, then just the top-level
7018 * directory will be included (with a trailing slash on the entry name).
7019 * Given this flag, the directory itself will not be included, but all the
7022 RECURSE_UNTRACKED_DIRS,
7026 [CCode (cname = "git_submodule_update_t", cprefix = "GIT_SUBMODULE_UPDATE_", has_type_id = false)]
7027 public enum SubmoduleUpdate {
7035 [CCode (cname = "git_submodule_ignore_t", cpreifx = "GIT_SUBMODULE_IGNORE_", has_type_id = false)]
7036 public enum SubmoduleIgnore {
7038 * The working directory will be consider clean so long as there is a
7039 * checked out version present.
7043 * Only check if the HEAD of the submodule has moved for status.
7045 * This is fast since it does not need to scan the working tree of the
7050 * Examines the contents of the working tree but untracked files will not
7051 * count as making the submodule dirty.
7055 * Consider any change to the contents of the submodule from a clean
7056 * checkout to be dirty, including the addition of untracked files.
7058 * This is the default if unspecified.
7066 * Submodule info is contained in 4 places: the HEAD tree, the index, config
7067 * files (both .git/config and .gitmodules), and the working directory. Any
7068 * or all of those places might be missing information about the submodule
7069 * depending on what state the repo is in. We consider all four places to
7070 * build the combination of status flags.
7072 * There are four values that are not really status, but give basic info
7073 * about what sources of submodule data are available. These will be
7074 * returned even if {@link Submodule.ignore} is set to {@link SubmoduleIgnore.ALL}.
7076 * * {@link IN_HEAD} superproject head contains submodule
7077 * * {@link IN_INDEX} superproject index contains submodule
7078 * * {@link IN_CONFIG} superproject gitmodules has submodule
7079 * * {@link IN_WD} superproject workdir has submodule
7081 * The following values will be returned so long as ignore is not {@link SubmoduleIgnore.ALL}.
7083 * * {@link INDEX_ADDED} in index, not in head
7084 * * {@link INDEX_DELETED} in head, not in index
7085 * * {@link INDEX_MODIFIED} index and head don't match
7086 * * {@link WD_UNINITIALIZED} workdir contains empty directory
7087 * * {@link WD_ADDED} in workdir, not index
7088 * * {@link WD_DELETED} in index, not workdir
7089 * * {@link WD_MODIFIED} index and workdir head don't match
7091 * The following can only be returned if ignore is {@link SubmoduleIgnore.NONE} or {@link SubmoduleIgnore.UNTRACKED}.
7093 * * {@link WD_INDEX_MODIFIED} submodule workdir index is dirty
7094 * * {@link WD_WD_MODIFIED} submodule workdir has modified files
7096 * Lastly, the following will only be returned for ignore {@link SubmoduleIgnore.NONE}.
7098 * * {@link WD_UNTRACKED} wd contains untracked files
7100 [CCode (cname = "unsigned int", has_type_id = false, cprefix = "GIT_SUBMODULE_STATUS_")]
7101 public enum SubmoduleStatus {
7116 [CCode (cname = "GIT_SUBMODULE_STATUS_IS_INDEX_UNMODIFIED")]
7117 public bool is_index_unmodified ();
7118 [CCode (cname = "GIT_SUBMODULE_STATUS_IS_UNMODIFIED")]
7119 public bool is_unmodified ();
7120 [CCode (cname = "GIT_SUBMODULE_STATUS_IS_WD_DIRTY")]
7121 public bool is_wd_dirty ();
7122 [CCode (cname = "GIT_SUBMODULE_STATUS_IS_WD_UNMODIFIED")]
7123 public bool is_wd_unmodified ();
7126 * Available tracing levels.
7128 * When tracing is set to a particular level, callers will be provided
7129 * tracing at the given level and all lower levels.
7131 [CCode (cname = "git_trace_level_t", cprefix = "GIT_TRACE_", has_type_id = false)]
7134 * No tracing will be performed.
7138 * Severe errors that may impact the program's execution
7142 * Errors that do not impact the program's execution
7146 * Warnings that suggest abnormal data
7150 * Informational messages about program execution
7154 * Detailed data that allows for debugging
7158 * Exceptionally detailed debugging data
7162 * Sets the system tracing configuration to the specified level with the
7163 * specified callback.
7165 * When system events occur at a level equal to, or lower than, the given
7166 * level they will be reported to the given callback.
7168 [CCode (cname = "git_trace_set")]
7169 public Error setup (Tracer tracer);
7171 [CCode (cname = "int", cprefix = "GIT_TRANSPORTFLAGS_", has_type_id = false)]
7172 public enum TransportFlags {
7175 * If the connection is secured with SSL/TLS, the authenticity of the
7176 * server certificate should not be verified.
7182 * Tree traversal modes
7184 [CCode (cname = "git_treewalk_mode", cprefix = "GIT_TREEWALK_", has_type_id = false)]
7185 public enum WalkMode {
7190 [CCode (cname = "git_attr_foreach_cb", has_type_id = false)]
7191 public delegate Error AttributeForEach (string name, string? val);
7192 [CCode (cname = "git_branch_foreach_cb")]
7193 public delegate int Branch (string branch_name, BranchType branch_type);
7195 * Callback for notification of a file during checkout.
7198 * Notification callbacks are made prior to modifying any files on disk.
7200 * @return true to cancel the checkout; false otherwise.
7202 [CCode (cname = "git_checkout_notify_cb", has_type_id = false)]
7203 public delegate bool CheckoutNotifier (CheckoutNotify why, string path, diff_file baseline, diff_file target, diff_file workdir);
7206 * The implementation of the callback has to respect the
7209 * @param content will have to be filled. The maximum number of bytes that
7210 * the buffer can accept per call is the length of the array.
7212 * @return The callback is expected to return the number of bytes
7213 * written to content. When there is no more data to stream, the callback
7214 * should return 0. This will prevent it from being invoked anymore. When an
7215 * error occurs, the callback should return -1.
7217 [CCode (cname = "git_blob_chunk_cb")]
7218 public delegate int ChunkSource ([CCode (array_length_type = "size_t")] uint8[] content);
7220 [CCode (cname = "git_config_foreach_cb")]
7221 public delegate int ConfigForEach (config_entry entry);
7223 * made on files where the index differs from the working
7224 * directory but the rules do not allow update.
7226 * All such callbacks will be made before any changes are made to the
7227 * working directory.
7228 * @return true to abort the checkout.
7230 public delegate bool Conflict (string conflicting_path, object_id index_id, uint index_mode, uint wd_mode);
7232 * A function which creates a new subtransport for the smart transport
7234 [CCode (cname = "git_smart_subtransport_cb", has_target = false)]
7235 public delegate Error CreateSubTransport (out smart_subtransport? subtransport, transport owner);
7237 * Signature of a function which creates a transport
7239 [CCode (cname = "git_transport_cb")]
7240 public delegate Error CreateTransport (out transport? transport, Remote owner);
7243 * Signature of a function which acquires a credential object.
7245 * @param cred The newly created credential object.
7246 * @param url The resource for which we are demanding a credential.
7247 * @param allowed_types A bitmask stating which cred types are OK to return.
7249 [CCode (cname = "git_cred_acquire_cb", has_type_id = false)]
7250 public delegate Error CredAcquire (out cred? cred, string url, CredTypes allowed_types);
7251 [CCode (has_target = false, has_type_id = false)]
7252 public delegate void CredFree (owned cred cred);
7255 * When printing a diff, callback that will be made to output each line of
7257 * @return true to stop iteration
7259 [CCode (cname = "git_diff_data_cb", simple_generics = true, has_target = false, has_type_id = false)]
7260 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);
7262 * When iterating over a diff, callback that will be made per file.
7264 [CCode (cname = "git_diff_file_cb", simple_generics = true, has_target = false, has_type_id = false)]
7265 public delegate Error DiffFile<T> (diff_delta delta, float progress, T context);
7268 * When iterating over a diff, callback that will be made per hunk.
7270 [CCode (cname = "git_diff_hunk_cb", simple_generics = true, has_target = false, has_type_id = false)]
7271 public delegate Error DiffHunk<T> (diff_delta delta, diff_range range, [CCode (array_length_type = "size_t")] char[] header, T context);
7274 * When iterating over a diff, callback that will be made per text diff
7276 * @return true to stop iteration
7278 [CCode (cname = "git_diff_line_fn", simple_generics = true, has_target = false, has_type_id = false)]
7279 public delegate bool DiffLine<T> (T context, diff_delta delta, DiffLineType line_origin, [CCode (array_length_type = "size_t")] uint8[] content);
7281 * Diff notification callback function.
7283 * The callback will be called for each file, just before the {@link
7284 * DeltaType} gets inserted into the diff list.
7286 * When the callback:
7287 * - returns < 0, the diff process will be aborted.
7288 * - returns > 0, the delta will not be inserted into the diff list, but the
7289 * diff process continues.
7290 * - returns 0, the delta is inserted into the diff list, and the diff process
7293 [CCode (cname = "git_diff_notify_cb", has_type_id = false)]
7294 public delegate int DiffNotify (DiffList diff_so_far, diff_delta delta_to_add, string matched_pathspec);
7297 * When printing a diff, callback that will be made to output each line of
7299 * @return true to stop iteration
7301 [CCode (cname = "git_diff_data_cb", has_type_id = false)]
7302 public delegate bool DiffOutput (diff_delta delta, diff_range range, DiffLineType line_origin, [CCode (array_length_type = "size_t")] char[] formatted_output);
7303 [CCode (cname = "git_repository_fetchhead_foreach_cb")]
7304 public delegate bool FetchHeadForEach (string ref_name, string remote_url, object_id id, bool is_merge);
7306 [CCode (cname = "git_treebuilder_filter_cb", has_type_id = false)]
7307 public delegate bool Filter (TreeEntry entry);
7308 [CCode (cname = "git_headlist_cb", has_type_id = false)]
7309 public delegate int Head (remote_head head);
7310 [CCode (cname = "git_repository_mergehead_foreach_cb", has_type_id = false)]
7311 public delegate bool MergeHeadForEach (object_id id);
7313 * Called to process a note.
7314 * @param blob_id id of the blob containing the message
7315 * @param annotated_object_id id of the git object being annotated
7317 [CCode (cname = "git_note_foreach_cb", has_type_id = false)]
7318 public delegate Error NoteForEach (object_id blob_id, object_id annotated_object_id);
7319 [CCode (cname = "git_odb_foreach_cb", has_type_id = false)]
7320 public delegate Error ObjectIdForEach (object_id id);
7321 [CCode (cname = "git_packbuilder_foreach_cb", has_type_id = false)]
7322 public delegate int PackBuilderForEach ([CCode (array_length_type = "size_t")] uint8[] buffer);
7323 public delegate bool PushForEach (string ref_spec, string msg);
7324 [CCode (cname = "git_checkout_progress_cb")]
7325 public delegate void Progress (string path, size_t completed_steps, size_t total_steps);
7328 * Suggests that the given refdb compress or optimize its references.
7330 * This mechanism is implementation specific. (For on-disk reference
7331 * databases, this may pack all loose references.)
7333 [CCode (has_target = false, has_type_id = false)]
7334 public delegate Error RefDbCompress (refdb_backend backend);
7336 * Deletes the given reference from the refdb.
7338 [CCode (has_target = false, has_type_id = false)]
7339 public delegate Error RefDbDelete (refdb_backend backend, Reference reference);
7341 * Queries the refdb backend to determine if the given ref_name
7344 [CCode (has_target = false, has_type_id = false)]
7345 public delegate Error RefDbExists (out bool exists, refdb_backend backend, string ref_name);
7347 * Enumerates each reference in the refdb.
7349 [CCode (has_target = false, has_type_id = false)]
7350 public delegate Error RefDbForEach (refdb_backend backend, ReferenceType list_flags, ReferenceForEach @foreach);
7352 * Enumerates each reference in the refdb that matches the given glob string.
7354 [CCode (has_target = false, has_type_id = false)]
7355 public delegate Error RefDbForEachGlob (refdb_backend backend, string glob, ReferenceType list_flags, ReferenceForEach @foreach);
7357 * Frees any resources held by the refdb.
7359 [CCode (has_target = false, has_type_id = false)]
7360 public delegate void RefDbFree (owned refdb_backend backend);
7362 * Queries the refdb backend for a given reference.
7364 [CCode (has_target = false, has_type_id = false)]
7365 public delegate Error RefDbLookup (out Reference? reference, refdb_backend backend, string ref_name);
7367 * Writes the given reference to the refdb.
7369 [CCode (has_target = false, has_type_id = false)]
7370 public delegate Error RefDbWrite (refdb_backend backend, Reference reference);
7372 [CCode (cname = "git_reference_foreach_cb", has_type_id = false)]
7373 public delegate bool ReferenceForEach (string refname);
7374 [CCode (simple_generics = true, has_type_id = false)]
7375 public delegate void RemoteProgress<T> (uint8[] str, T data);
7376 [CCode (has_target = false, simple_generics = true, has_type_id = false)]
7377 public delegate Error RemoteCompletion<T> (CompletionType type, T data);
7378 [CCode (has_target = false, simple_generics = true, has_type_id = false)]
7379 public delegate Error RemoteUpdateTips<T> (string refname, object_id a, object_id b, T data);
7381 * When iterating over all the stashed states, callback that will be issued
7384 * @param index The position within the stash list. 0 points to the most
7385 * recent stashed state.
7386 * @param message The stash message.
7387 * @param stash_id The commit id of the stashed state.
7388 * @return 0 on success, GIT_EUSER on non-zero callback, or error code
7390 [CCode (cname = "git_stash_cb")]
7391 public delegate Error StashForEach (size_t index, string message, object_id stash_id);
7393 * Function to receive status on individual files
7395 * @param file the relative path to the file from the root of the repository.
7397 [CCode (cname = "git_status_cb", has_type_id = false)]
7398 public delegate Error StatusForEach (string file, Status status);
7399 public delegate Error SubmoduleForEach (string name);
7400 [CCode (cname = "git_tag_foreach_cb", has_type_id = false)]
7401 public delegate bool TagForEach (string name, object_id id);
7403 * An instance for a tracing function
7405 [CCode (cname = "git_trace_callback", has_type_id = false, has_target = false)]
7406 public delegate void Tracer (Trace level, string msg);
7408 * Type for progress callbacks during indexing.
7410 * @param stats Structure containing information about the state of the transfer
7411 * @return an error to cancel the transfer.
7413 [CCode (cname = "git_transfer_progress_callback", has_type_id = false)]
7414 public delegate Error TransferProgress (transfer_progress stats);
7416 [CCode (has_target = false, has_type_id = false)]
7417 public delegate void TransportCancel (transport transport);
7418 [CCode (has_target = false, has_type_id = false)]
7419 public delegate Error TransportClose (transport transport);
7420 [CCode (has_target = false, has_type_id = false)]
7421 public delegate Error TransportConnect (transport transport, string url, CredAcquire cred_acquire, Direction direction, TransportFlags flags);
7422 [CCode (has_target = false, has_type_id = false)]
7423 public delegate Error TransportDownloadPack (transport transport, Repository repo, out transfer_progress stats, Progress progress);
7424 [CCode (has_target = false, has_type_id = false)]
7425 public delegate void TransportFree (owned transport? transport);
7426 [CCode (has_target = false, has_type_id = false)]
7427 public delegate bool TransportIsConnected (transport transport);
7428 [CCode (has_target = false, has_type_id = false)]
7429 public delegate Error TransportList (transport transport, Head list);
7430 [CCode (cname = "git_transport_message_cb", has_type_id = false, has_target = false, simple_generics = true)]
7431 public delegate void TransportMessage<T> (uint8[] message, T data);
7432 [CCode (has_target = false, has_type_id = false)]
7433 public delegate Error TransportNegotiatFetch (transport transport, Repository repo, [CCode (array_length_type = "size_t")] remote_head[] refs);
7434 [CCode (has_target = false, has_type_id = false)]
7435 public delegate Error TransportPush (transport transport, Push push);
7436 [CCode (has_target = false, has_type_id = false)]
7437 public delegate Error TransportReadFlags (transport transport, out TransportFlags flags);
7438 [CCode (has_target = false, has_type_id = false)]
7439 public delegate Error TransportSetCallbacks<T> (transport transport, TransportMessage<T> progress, TransportMessage<T> error, T data);
7441 [CCode (has_target = false, has_type_id = false)]
7442 public delegate Error SubTransportAction (out smart_subtransport_stream? stream, smart_subtransport transport, string url, SmartService action);
7443 [CCode (has_target = false, has_type_id = false)]
7444 public delegate Error SubTransportClose (smart_subtransport transport);
7445 [CCode (has_target = false, has_type_id = false)]
7446 public delegate void SubTransportFree (owned smart_subtransport? transport);
7447 [CCode (has_target = false, has_type_id = false)]
7448 public delegate void SubTransportStreamFree (owned smart_subtransport_stream? stream);
7449 [CCode (has_target = false, has_type_id = false)]
7450 public delegate Error SubTransportStreamRead (smart_subtransport_stream stream, [CCode (array_length_type = "size_t")] uint8[] buffer, out size_t bytes_read);
7451 [CCode (has_target = false, has_type_id = false)]
7452 public delegate Error SubTransportStreamWrite (smart_subtransport_stream stream, [CCode (array_length_type = "size_t")] uint8[] buffer);
7454 [CCode (cname = "git_treewalk_cb", has_type_id = false)]
7455 public delegate int TreeWalker (string root, TreeEntry entry);
7456 [CCode (has_target = false)]
7457 public delegate Error Update (string refname, object_id old, object_id @new);
7460 * Clean up message from excess whitespace and make sure that the last line
7461 * ends with a new line.
7463 * @param message_out The buffer which will be filled with the cleaned up
7465 * @param message The message to be prettified.
7467 * @param strip_comments remove lines starting with a "#".
7469 [CCode (cname = "git_message_prettify")]
7470 public Error prettify_message ([CCode (array_length_type = "size_t")] uint8[] message_out, string message, bool strip_comments);
7473 [CCode (cname = "git_libgit2_opt_t", cprefix = "GIT_OPT_")]
7474 private enum _Option {
7477 GET_MWINDOW_MAPPED_LIMIT,
7482 SET_CACHE_OBJECT_LIMIT,
7483 SET_MWINDOW_MAPPED_LIMIT,
7487 [CCode (cname = "git_libgit2_opts")]
7488 public Error opts (...);
7490 public size_t get_mwindow_mapped_limit () {
7492 _Option.GET_MWINDOW_MAPPED_LIMIT.opts (out s);
7496 * Set the maximum amount of memory that can be mapped at any time by the
7499 public void set_mwindow_mapped_limit (size_t size) {
7500 _Option.SET_MWINDOW_MAPPED_LIMIT.opts (size);
7503 * Set the maximum mmap window size.
7505 public size_t get_mwindow_size () {
7507 _Option.GET_MWINDOW_SIZE.opts (out s);
7510 public void set_mwindow_size (size_t size) {
7511 _Option.SET_MWINDOW_SIZE.opts (size);
7514 * Get the size of the libgit2 odb cache.
7516 public size_t get_odb_cache_size () {
7518 _Option.GET_ODB_CACHE_SIZE.opts (out s);
7522 * Set the size of the of the libgit2 odb cache.
7524 * This needs to be done before {@link Repository.open} is called, since
7525 * it initializes the odb layer. Defaults to 128.
7527 public void set_odb_cache_size (size_t size = 128) {
7528 _Option.SET_ODB_CACHE_SIZE.opts (size);
7531 * Set the search path for a given level of config data.
7533 * @param level must be one of {@link ConfigLevel.SYSTEM},
7534 * {@link ConfigLevel_GLOBAL}, or {@link ConfigLevel.XDG}.
7536 public string get_search_path (ConfigLevel level) {
7537 uint8[] buffer = new uint8[64];
7538 while (_Option.GET_SEARCH_PATH.opts (level, (void *) buffer, (size_t) buffer.length) == Error.BUFS) {
7539 buffer = new uint8[buffer.length * 2];
7541 return ((string) buffer).dup ();
7543 public void set_search_path (ConfigLevel level, string path) {
7544 _Option.SET_SEARCH_PATH.opts (level, path);
7549 * Set the error message to a special value for memory allocation failure.
7551 * The normal {@link ErrClass.raise} function attempts to duplicate the
7552 * string that is passed in. This is not a good idea when the error in
7553 * question is a memory allocation failure. That circumstance has a special
7554 * setter function that sets the error string to a known and statically
7555 * allocated internal value.
7557 [CCode (cname = "giterr_set_oom")]
7558 public void raise_oom ();
7560 [CCode (cname = "char*", has_type_id = false)]
7562 private struct unstr {
7563 [CCode (cname = "strdup")]
7564 public string dup ();