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