Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master
7382 lines (6932 sloc) 236.301 kb
/*
* libgit2 Vala binding
*
* Homepage: http://libgit2.github.com/
* VAPI Homepage: https://github.com/apmasell/vapis/blob/master/libgit2.vapi
* VAPI Maintainer: Andre Masella <andre@masella.name>
*
* This file is part of libgit2, distributed under the GNU GPL v2 with
* a Linking Exception. For full terms see the included COPYING file.
*/
/**
* Library to access the contents of git repositories
*
* libgit2 can access and manipulate the contents of git repositories. To begin, create an instance of a {@link Git.Repository} like so:
* {{{
* Git.Repository? repo;
* if (Git.Repository.open(out repo, "/path/to/repo") != Git.Error.OK) {
* stderr.printf("Could not open repository because: %s\n", Git.ErrorInfo.get_last().message);
* return false;
* }
* }}}
* Then use the methods of //repo// to access the repository.
*/
[CCode(cheader_filename = "git2.h")]
namespace Git {
namespace Configuration {
/**
* Generic backend that implements the interface to
* access a configuration file
*/
[CCode(cname = "git_config_backend", has_type_id = false, default_value = "GIT_CONFIG_BACKEND_INIT")]
public struct backend {
[CCode(cname = "GIT_CONFIG_BACKEND_VERSION")]
public const uint VERSION;
public uint version;
public unowned Config cfg;
public Delete @delete;
[CCode(cname = "foreach")]
public ForEach for_each;
public Free free;
public Get @get;
[CCode(cname = "get_multivar")]
public GetMulti get_multi;
[CCode(cname = "refersh")]
public Refresh refresh;
public Open open;
public Set @set;
public SetMulti set_multi;
}
[CCode(cname = "git_config_file_delete_cb", has_type_id = false, has_target = false)]
public delegate int Delete(backend backend, string key);
[CCode(cname = "git_config_file_foreach_cb", has_type_id = false, has_target = false)]
public delegate int ForEach(backend backend, string regex, ConfigForEach config_for_each);
[CCode(cname = "git_config_file_free_cb", has_type_id = false, has_target = false)]
public delegate void Free(backend backend);
[CCode(cname = "git_config_file_get_cb", has_type_id = false, has_target = false)]
public delegate int Get(backend backend, string key, out string value);
[CCode(cname = "git_config_file_get_mulivar_cb", has_type_id = false, has_target = false)]
public delegate int GetMulti(backend backend, string key, string? regexp, Setter func);
[CCode(cname = "git_config_file_refresh", has_type_id = false, has_target = false)]
public delegate Error Refresh(backend backend);
[CCode(cname = "git_config_file_set_cb", has_type_id = false, has_target = false)]
public delegate int Setter(string val);
[CCode(cname = "git_config_file_open_cb", has_type_id = false, has_target = false)]
public delegate int Open(backend backend);
[CCode(cname = "git_config_file_set_cb", has_type_id = false, has_target = false)]
public delegate int Set(backend backend, string key, string value);
[CCode(cname = "git_config_file_set_multivar_cb", has_type_id = false, has_target = false)]
public delegate int SetMulti(backend backend, string name, string regexp, string val);
}
namespace Database {
/**
* An open object database handle
*/
[CCode(cname = "git_odb", free_function = "git_odb_close", has_type_id = false)]
[Compact]
public class Handle {
/**
* Create a new object database with no backends.
*
* Before the ODB can be used for read/writing, a custom database
* backend must be manually added using {@link Handle.add_backend}.
*
* @param db location to store the database pointer, if opened. Set to null if the open failed.
*/
[CCode(cname = "git_odb_new")]
public static Error create(out Handle? db);
/**
* Create a new object database and automatically add
* the two default backends.
*
* Automatically added are:
* - {@link backend.create_loose}: read and write loose object files
* from disk, assuming //objects_dir// as the Objects folder
*
* - {@link backend.create_pack}: read objects from packfiles,
* assuming //objects_dir// as the Objects folder which
* contains a //pack// folder with the corresponding data
*
* @param db location to store the database pointer, if opened.
* Set to null if the open failed.
* @param objects_dir path of the backends' //objects// directory.
*/
[CCode(cname = "git_odb_open")]
public static Error open(out Handle db, string objects_dir);
/**
* Add a custom backend to an existing Object DB; this
* backend will work as an alternate.
*
* Alternate backends are always checked for objects ''after''
* all the main backends have been exhausted.
*
* The backends are checked in relative ordering, based on the
* value of the //priority// parameter.
*
* Writing is disabled on alternate backends.
*
* @param backend the backend instance
* @param priority Value for ordering the backends queue
*/
[CCode(cname = "git_odb_add_alternate")]
public Error add_alternate(backend backend, int priority);
/**
* Add a custom backend to an existing Object DB
*
* The backends are checked in relative ordering, based on the
* value of the //priority// parameter.
* @param backend the backend instance
* @param priority Value for ordering the backends queue
*/
[CCode(cname = "git_odb_add_backend")]
public Error add_backend(backend backend, int priority);
/**
* Determine if the given object can be found in the object database.
*
* @param id the object to search for.
*/
[CCode(cname = "git_odb_exists")]
public bool contains(object_id id);
/**
* Create a "fake" repository to wrap an object database
*
* Create a repository object to wrap an object database to be used with
* the API when all you have is an object database. This doesn't have any
* paths associated with it, so use with care.
*/
[CCode(cname = "git_repository_wrap_odb", instance_pos = -1)]
public Error create_repository(out Repository? repository);
/**
* List all objects available in the database
*
* The callback will be called for each object available in the
* database. Note that the objects are likely to be returned in the index
* order, which would make accessing the objects in that order inefficient.
*/
[CCode(cname = "git_odb_foreach")]
public Error for_each(ObjectIdForEach object_for_each);
/**
* Read an object from the database.
*
* This method queries all available ODB backends
* trying to read the given id.
*
* @param obj pointer where to store the read object
* @param id identity of the object to read.
*/
[CCode(cname = "git_odb_read", instance_pos = 1.2)]
public Error read(out Object obj, object_id id);
/**
* Read an object from the database, given a prefix
* of its identifier.
*
* This method queries all available ODB backends
* trying to match the //len// first hexadecimal
* characters of the //short_id//.
* The remaining //({@link object_id.HEX_SIZE}-len)*4// bits of
* //short_id// must be 0s.
* //len// must be at least {@link object_id.MIN_PREFIX_LENGTH},
* and the prefix must be long enough to identify
* a unique object in all the backends; the
* method will fail otherwise.
*
* The returned object is reference counted and
* internally cached, so it should be closed
* by the user once it's no longer in use.
*
* @param obj pointer where to store the read object
* @param short_id a prefix of the id of the object to read.
* @param len the length of the prefix
*/
[CCode(cname = "git_odb_read_prefix", instance_pos = 1.2)]
public Error read_by_prefix(out Object obj, object_id short_id, size_t len);
/**
* Read the header of an object from the database, without
* reading its full contents.
*
* The header includes the length and the type of an object.
*
* Note that most backends do not support reading only the header
* of an object, so the whole object will be read and then the
* header will be returned.
*
* @param len the length of the object
* @param type the type of the object
* @param id identity of the object to read.
*/
[CCode(cname = "git_odb_read_header", instance_pos = 2.3)]
public Error read_header(out size_t len, out ObjectType type, object_id id);
/**
* Refresh the object database to load newly added files.
*
* If the object databases have changed on disk while the library is
* running, this function will force a reload of the underlying indexes.
*
* Use this function when you're confident that an external application
* has tampered with the ODB.
*
* Note that it is not necessary to call this function at all. The
* library will automatically attempt to refresh the ODB when a lookup
* fails, to see if the looked up object exists on disk but hasn't been
* loaded yet.
*/
[CCode(cname = "git_odb_refresh")]
public Error refresh();
/**
* Open a stream to write an object into the ODB
*
* The type and final length of the object must be specified
* when opening the stream.
*
* The returned stream will be of type {@link StreamMode.WRONLY} and
* will have the following methods:
*
* * {@link stream.write}: write //n// bytes into the stream
* * {@link stream.finalize_write}: close the stream and store the object in the ODB
*
* The streaming write won't be effective until {@link stream.finalize_write}
* is called and returns without an error
*
* @param stream where to store the stream
* @param size final size of the object that will be written
* @param type type of the object that will be written
*/
[CCode(cname = "git_odb_open_wstream", instance_pos = 1.2)]
public Error open_write_stream(out stream stream, size_t size, ObjectType type);
/**
* Open a stream to read an object from the ODB
*
* Note that most backends do ''not'' support streaming reads
* because they store their objects as compressed/delta'ed blobs.
*
* It's recommended to use {@link Handle.read} instead, which is
* assured to work on all backends.
*
* The returned stream will be of type {@link StreamMode.RDONLY} and
* will have the following methods:
*
* * {@link stream.read}: read //n// bytes from the stream
*
* @param stream where to store the stream
* @param id id of the object the stream will read from
*/
[CCode(cname = "git_odb_open_rstream")]
public Error open_read_stream(out stream stream, object_id id);
/**
* Write an object directly into the ODB
*
* This method writes a full object straight into the ODB.
* For most cases, it is preferred to write objects through a write
* stream, which is both faster and less memory intensive, specially
* for big objects.
*
* This method is provided for compatibility with custom backends
* which are not able to support streaming writes
*
* @param id pointer to store the id result of the write
* @param data buffer with the data to store
* @param type type of the data to store
*/
[CCode(cname = "git_odb_write", instance_pos = 1.2)]
public Error write(object_id id, [CCode(array_length_Type = "size_t")] uint8[] data, ObjectType type);
}
/**
* An object read from the database
*/
[CCode(cname = "git_odb_object", free_function = "git_odb_object_free", has_type_id = false)]
[Compact]
public class Object {
/**
* The data of an ODB object
*
* This is the uncompressed, raw data as read from the ODB,
* without the leading header.
*/
public uint8[] data {
[CCode(cname = "git_odb_object_data", array_length_cexpr = "git_odb_object_size")]
get;
}
/**
* The id of an ODB object
*/
public object_id? id {
[CCode(cname = "git_odb_object_id")]
get;
}
/**
* The type of an ODB object
*/
public ObjectType type {
[CCode(cname = "git_odb_object_type")]
get;
}
}
/**
* A custom backend in an ODB
*/
[CCode(cname = "git_odb_backend", has_type_id = false, default_value = "GIT_ODB_BACKEND_INIT")]
public struct backend {
[CCode(cname = "GIT_ODB_BACKEND_VERSION")]
public const uint VERSION;
public uint version;
public unowned Handle odb;
public BackendExists exists;
public BackendFree free;
[CCode(cname = "foreach")]
public BackendForEach for_each;
public BackendRead read;
public BackendReadHeader read_header;
public BackendReadPrefix read_prefix;
[CCode(cname = "readstream")]
public BackendReadStream read_stream;
public BackendWrite write;
public BackendWritePack write_pack;
[CCode(cname = "writestream")]
public BackendWriteStream write_stream;
[CCode(cname = "git_odb_backend_loose")]
public static Error create_loose(out backend backend, string objects_dir);
[CCode(cname = "git_odb_backend_one_pack")]
public static Error create_one_pack(out backend backend, string index_file);
[CCode(cname = "git_odb_backend_pack")]
public static Error create_pack(out backend backend, string objects_dir);
[CCode(cname = "git_odb_backend_malloc", simple_generics = true)]
public T malloc<T>(size_t len);
}
/**
* A stream to read/write from the ODB
*/
[CCode(cname = "git_odb_stream", has_type_id = false)]
public struct stream {
public unowned backend? backend;
public StreamMode mode;
public StreamFinalizeWrite finalize_write;
public StreamFree free;
public StreamRead read;
public StreamWrite write;
}
/**
* A stream to write a pack file to the ODB
*/
[CCode(cname = "git_odb_writepack", has_type_id = false)]
public struct write_pack {
public unowned backend? backend;
[CCode(cname = "add")]
public WritePackAdd add;
[CCode(cname = "commit")]
public WritePackCommit commit;
[CCode(cname = "free")]
public WritePackFree free;
}
/**
* Streaming mode
*/
[CCode(cname = "git_odb_streammode", cprefix = "GIT_STREAM_", has_type_id = false)]
public enum StreamMode {
RDONLY,
WRONLY,
RW
}
[CCode(has_target = false, has_type_id = false)]
public delegate bool BackendExists(backend self, object_id id);
[CCode(has_target = false, has_type_id = false)]
public delegate void BackendFree(backend self);
[CCode(has_target = false, has_type_id = false)]
public delegate Error BackendForEach(backend self, ObjectIdForEach cb);
/**
* Read each return to libgit2 a buffer which will be freed later.
*
* The buffer should be allocated using the function {@link backend.malloc} to
* ensure that it can be safely freed later.
*/
[CCode(has_target = false, has_type_id = false)]
public delegate Error BackendRead([CCode(array_length_type = "size_t")] out uint8[] data, out ObjectType type, backend self, object_id id);
/**
* Find a unique object given a prefix
*
* The id given must be so that the remaining
* ({@link object_id.HEX_SIZE} - len)*4 bits are 0s.
*/
[CCode(has_target = false, has_type_id = false)]
public delegate Error BackendReadHeader(out size_t size, out ObjectType type, backend self, object_id id);
[CCode(has_target = false, has_type_id = false)]
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);
[CCode(has_target = false, has_type_id = false)]
public delegate Error BackendReadStream(out stream stream, backend self, object_id id);
[CCode(has_target = false, has_type_id = false)]
public delegate Error BackendWrite(out object_id id, backend self, [CCode(array_length_type = "size_t")] out uint8[] data, ObjectType type);
[CCode(has_target = false, has_type_id = false)]
public delegate Error BackendWriteStream(out stream stream, backend self, size_t size, ObjectType type);
[CCode(has_target = false, has_type_id = false)]
public delegate int BackendWritePack(out write_pack write_pack, backend self, TransferProgress progress);
[CCode(has_target = false, has_type_id = false)]
public delegate Error StreamFinalizeWrite(out object_id id, stream stream);
[CCode(has_target = false, has_type_id = false)]
public delegate void StreamFree(stream stream);
[CCode(has_target = false, has_type_id = false)]
public delegate int StreamRead(stream stream, [CCode(array_length_type = "size_t")] uint8[] buffer);
[CCode(has_target = false, has_type_id = false)]
public delegate int StreamWrite(stream stream, [CCode(array_length_type = "size_t")] uint8[] buffer);
[CCode(has_target = false)]
public delegate int WritePackAdd(write_pack write_pack, [CCode(array_length_type = "size_t")] uint8[] data, transfer_progress stats);
[CCode(has_target = false)]
public delegate int WritePackCommit(write_pack write_pack, transfer_progress stats);
[CCode(has_target = false)]
public delegate void WritePackFree(write_pack write_pack);
}
namespace Threads {
/**
* Init the threading system.
*
* If libgit2 has been built with GIT_THREADS
* on, this function must be called once before
* any other library functions.
*
* If libgit2 has been built without GIT_THREADS
* support, this function is a no-op.
*/
[CCode(cname = "git_threads_init")]
public Error init();
/**
* Shutdown the threading system.
*
* If libgit2 has been built with GIT_THREADS
* on, this function must be called before shutting
* down the library.
*
* If libgit2 has been built without GIT_THREADS
* support, this function is a no-op.
*/
[CCode(cname = "git_threads_shutdown")]
public void shutdown();
}
namespace Version {
[CCode(cname = "LIBGIT2_VERSION")]
public const string VERSION;
[CCode(cname = "LIBGIT2_VER_MAJOR")]
public const int MAJOR;
[CCode(cname = "LIBGIT2_VER_MINOR")]
public const int MINOR;
[CCode(cname = "LIBGIT2_VER_REVISION")]
public const int REVISION;
/**
* Return the version of the libgit2 library
* being currently used.
*
* @param major Store the major version number
* @param minor Store the minor version number
* @param rev Store the revision (patch) number
*/
[CCode(cname = "git_libgit2_version")]
public void get_version(out int major, out int minor, out int rev);
}
/*
* Attribute management routines
*/
[CCode(cname = "git_repository", cheader_filename = "git2/attr.h", has_type_id = false)]
public class Attr {
[CCode(cname = "git_attr_t", cprefix = "GIT_ATTR_", has_type_id = false)]
public enum AttrType {
[CCode(cname = "GIT_ATTR_UNSPECIFIED_T")]
UNSPECIFIED,
[CCode(cname = "GIT_ATTR_TRUE_T")]
TRUE,
[CCode(cname = "GIT_ATTR_FALSE_T")]
FALSE,
[CCode(cname = "GIT_ATTR_VALUE_T")]
VALUE;
/**
* Return the value type for a given attribute.
*
* This can be either {@link TRUE}, {@link FALSE}, {@link UNSPECIFIED}
* (if the attribute was not set at all), or {@link VALUE}, if the
* attribute was set to an actual string.
*
* If the attribute has a {@link VALUE} string, it can be accessed
* normally as a string.
*/
[CCode(cname = "git_attr_value")]
public static AttrType from(string attr);
}
/**
* Checks if an attribute is set on.
*
* In core git parlance, this the value for "Set" attributes.
*/
[CCode(cname = "GIT_ATTR_TRUE")]
public static bool is_true(string? attr);
/**
* Checks if an attribute is set off.
*
* In core git parlance, this is the value for attributes that are "Unset"
* (not to be confused with values that a "Unspecified").
*/
[CCode(cname = "GIT_ATTR_FALSE")]
public static bool is_false(string? attr);
/**
* Checks if an attribute is set to a value (as opposied to TRUE, FALSE or
* UNSPECIFIED).
*/
[CCode(cname = "GIT_ATTR_SET_TO_VALUE")]
public static bool is_set(string? attr);
/*
* Checks if an attribute is unspecified. This may be due to the attribute
* not being mentioned at all or because the attribute was explicitly set
* unspecified via the `!` operator.
*/
[CCode(cname = "GIT_ATTR_UNSPECIFIED")]
public static bool is_unspecified(string? attr);
/**
* Add a macro definition.
*
* Macros will automatically be loaded from the top level .gitattributes
* file of the repository (plus the build-in "binary" macro). This
* function allows you to add others. For example, to add the default
* macro, you would call:
* {{{
* repo.attributes.add_macro("binary", "-diff -crlf");
* }}}
*/
[CCode(cname = "git_attr_add_macro")]
public Error add_macro(string name, string val);
/**
* Lookup attribute for path returning string caller must free
*/
[CCode(cname = "git_attr_get")]
public Error lookup(AttrCheck flags, string path, string name, out unowned string? val);
/**
* Lookup list of attributes for path, populating array of strings
*
* Use this if you have a known list of attributes that you want to
* look up in a single call. This is somewhat more efficient than
* calling {@link lookup} multiple times.
*
* For example, you might write:
* {{{
* string attrs[] = { "crlf", "diff", "foo" };
* string results[];
* repo.attributes.lookup_many(AttrCheck.FILE_THEN_INDEX, "my/fun/file.c", attrs, out values);
* }}}
* Then you could loop through the 3 values to get the settings for
* the three attributes you asked about.
*
* @param path The path inside the repo to check attributes. This does not
* have to exist, but if it does not, then it will be treated as a plain
* file (i.e. not a directory).
* @param names The attribute names.
* @param values The values of the attributes.
*/
[CCode(cname = "_vala_git_attr_get_many")]
public Error lookup_many(AttrCheck flags, string path, string[] names, out string[] values) {
unstr[] temp = new unstr[names.length];
var e = _lookup_many(flags, path, names, temp);
values = new string[names.length];
for (var it = 0; it < temp.length; it++) {
values[it] = temp[it].dup();
}
return e;
}
[CCode(cname = "git_attr_get_many")]
private Error _lookup_many(AttrCheck flags, string path, [CCode(array_length_pos = 2.1, array_length_type = "size_t")] string[] names, void* values);
/**
* Perform an operation on each attribute of a path.
* @param path The path inside the repo to check attributes. This does not
* have to exist, but if it does not, then it will be treated as a plain
* file (i.e. not a directory).
* @param attribute_for_each The function that will be invoked on each
* attribute and attribute value. The name parameter will be the name of
* the attribute and the value will be the value it is set to, including
* possibly null if the attribute is explicitly set to UNSPECIFIED using
* the ! sign. This will be invoked only once per attribute name, even if
* there are multiple rules for a given file. The highest priority rule
* will be used.
*/
[CCode(cname = "git_attr_foreach")]
public Error for_each(AttrCheck flags, string path, AttributeForEach attribute_for_each);
/**
* Flush the gitattributes cache.
*
* Call this if you have reason to believe that the attributes files
* on disk no longer match the cached contents of memory. This will cause
* the attributes files to be reloaded the next time that an attribute
* access function is called.
*/
[CCode(cname = "git_attr_cache_flush")]
public void flush();
}
/**
* In-memory representation of a blob object.
*/
[CCode(cname = "git_blob", free_function = "git_blob_free", has_type_id = false)]
[Compact]
public class Blob : Object {
[CCode(array_length = false, cname = "git_blob_rawcontent")]
private unowned uint8[]? _get_content();
/**
* Get a read-only buffer with the raw content of a blob.
*
* A pointer to the raw content of a blob is returned.
* The pointer may be invalidated at a later time.
*/
public uint8[]? content {
get {
unowned uint8[]? content = _get_content();
if (content != null) {
content.length = (int) size;
}
return content;
}
}
/**
* The id of a blob.
*/
public object_id? id {
[CCode(cname = "git_blob_id")]
get;
}
/**
* Determine if the blob content is most certainly binary or not.
*
* The heuristic used to guess if a file is binary is taken from core git:
* Searching for NUL bytes and looking for a reasonable ratio of printable
* to non-printable characters among the first 4000 bytes.
*/
public bool is_binary {
[CCode(cname = "git_blob_is_binary")]
get;
}
/**
* Get the size in bytes of the contents of a blob
*/
public size_t size {
[CCode(cname = "git_blob_rawsize")]
get;
}
/**
* Directly run a text diff on two blobs.
*
* Compared to a file, a blob lacks some contextual information. As such, the
* {@link diff_file} parameters of the callbacks will be filled accordingly to the following:
* mode will be set to 0, path will be null. When dealing with a null blob, object id
* will be set to 0.
*
* When at least one of the blobs being dealt with is binary, the {@link diff_delta} binary
* attribute will be set to true and no call to the hunk nor line will be made.
*
* We do run a binary content check on the two blobs and if either of the
* blobs looks like binary data, {@link diff_delta.flags} will {@link DiffFlag.BINARY}
* and no call to the {@link DiffHunk} nor {@link DiffData} will be made
* (unless you pass {@link DiffFlags.FORCE_TEXT} of course).
*/
[CCode(cname = "git_diff_blobs", simple_generics = true)]
public Error diff<T>(Blob new_blob, diff_options options, DiffFile<T> file, DiffHunk<T> hunk, DiffData<T> line, T context);
/**
* Directly run a diff between a blob and a buffer.
*
* As with {@link diff}, comparing a blob and buffer lacks some context, so
* the {@link diff_file} parameters to the callbacks will be faked.
*/
[CCode(cname = "git_diff_blob_to_buffer", simple_generics = true)]
public Error diff_buffer<T>([CCode(array_length_type = "size_t")] uint8[] buffer, diff_options options, DiffFile<T> file, DiffHunk<T> hunk, DiffData<T> line, T context);
}
/**
* Parsed representation of a commit object.
*/
[CCode(cname = "git_commit", free_function = "git_commit_free", has_type_id = false)]
[Compact]
public class Commit : Object {
/**
* The author of a commit.
*/
public Signature author {
[CCode(cname = "git_commit_author")]
get;
}
/**
* The committer of a commit.
*/
public Signature committer {
[CCode(cname = "git_commit_committer")]
get;
}
/**
* The id of a commit.
*/
public object_id? id {
[CCode(cname = "git_commit_id")]
get;
}
/**
* The full message of a commit.
*/
public string message {
[CCode(cname = "git_commit_message")]
get;
}
/**
* The encoding for the message of a commit, as a string representing a
* standard encoding name.
*
* The encoding may be null if the encoding header in the commit is
* missing; in that case UTF-8 is assumed.
*/
public string? message_encoding {
[CCode(cname = "git_commit_message_encoding")]
get;
}
/**
* The parent(s) of this commit
*
* Typically, commits have a single parent, but merges can have many.
*/
public Parents parents {
[CCode(cname = "")]
get;
}
/**
* Get the commit time (i.e., committer time) of a commit.
*/
public int64 time {
[CCode(cname = "git_commit_time")]
get;
}
/**
* Get the commit timezone offset (i.e., committer's preferred timezone) in minutes from UTC of a commit.
*/
public int time_offset {
[CCode(cname = "git_commit_time_offset")]
get;
}
/**
* Get the id of the tree pointed to by a commit.
*
* This differs from {@link lookup_tree} in that no attempts
* are made to fetch an object from the ODB.
*/
public object_id? tree_id {
[CCode(cname = "git_commit_tree_oid")]
get;
}
/**
* Get the commit object that is an ancestor of the named commit object,
* following only the first parents.
*
* @param ancestor the ancestor received, if any
* @param n the requested generation, or 0 for a copy of the commit.
*/
[CCode(cname = "git_commit_nth_gen_ancestor", instance_pos = 1.2)]
public Error get_ancestor(out Commit? ancestor, uint n);
/**
* The message of a commit converted to UTF-8.
*/
public string get_message_utf8() throws GLib.ConvertError {
return this.message_encoding == null ? this.message : GLib.convert(this.message, this.message.length, "utf-8", this.message_encoding);
}
/**
* Get the tree pointed to by a commit.
*/
[CCode(cname = "git_commit_tree", instance_pos = -1)]
public Error lookup_tree(out Tree tree);
}
/**
* Memory representation of a set of config files
*/
[CCode(cname = "git_config", free_function = "git_config_free", has_type_id = false)]
[Compact]
public class Config {
/**
* Allocate a new configuration object
*
* This object is empty, so you have to add a file to it before you can do
* anything with it.
*
* @param config the new configuration
*/
[CCode(cname = "git_config_new")]
public static Error create(out Config config);
/**
* Locate the path to the global configuration file
*
* The user or global configuration file is usually located in
* //$HOME/.gitconfig//.
*
* This method will try to guess the full path to that file, if the file
* exists. The returned path may be used on any call to load the global
* configuration file.
*
* @param config_path Buffer store the path
* @return {@link Error.OK} if a global configuration file has been found.
*/
[CCode(cname = "git_config_find_global")]
public static Error find_global([CCode(array_length_type = "size_t")] char[] config_path);
/**
* Locate the path to the global xdg compatible configuration file
*
* The xdg compatible configuration file is usually located in
* //$HOME/.config/git/config//.
*
* This method will try to guess the full path to that file, if the file
* exists.
* @param config_path Buffer store the path
* @return {@link Error.OK} if an XDG configuration file has been found.
*/
[CCode(cname = "git_config_find_xdg")]
public static Error find_xdg([CCode(array_length_type = "size_t")] char[] config_path);
/**
* Locate the path to the system configuration file
*
* If /etc/gitconfig doesn't exist, it will look for
* %PROGRAMFILES%\Git\etc\gitconfig.
* @param config_path Buffer of {@link PATH_MAX} length to store the path
* @return {@link Error.OK} if a system configuration file has been found. Its path will be stored in //buffer//.
*/
[CCode(cname = "git_config_find_system")]
public static Error find_system([CCode(array_length_type = "size_t")] char[] config_path);
/**
* Maps a string value to an integer constant
*/
[CCode(cname = "git_config_lookup_map_value")]
public static Error lookup_map_value(out int result, [CCode(array_length_type = "size_t")] config_var_map[] map, string name);
/**
* Create a new config instance containing a single on-disk file
*
* This method is a simple utility wrapper for the following sequence of
* calls:
* * {@link create}
* * {@link add_filename}
*
* @param cfg the configuration instance to create
* @param path path to the on-disk file to open
*/
[CCode(cname = "git_config_open_ondisk")]
public static Error open(out Config? cfg, string path);
/**
* Open the global and system configuration files
*
* Utility wrapper that calls {@link find_global}, {@link find_xdg}, and
* {@link find_system} and opens the located file, if it exists.
*
* @param config where to store the config instance
*/
[CCode(cname = "git_config_open_default")]
public static Error open_default(out Config? config);
/**
* Build a single-level focused config object from a multi-level one.
*
* The returned config object can be used to perform get/set/delete
* operations on a single specific level.
*
* Getting several times the same level from the same parent multi-level
* config will return different config instances, but containing the same
* config_file instance.
*
* @param parent Multi-level config to search for the given level
* @param level Configuration level to search for
*/
[CCode(cname = "git_config_open_level")]
public static Error open_level(out Config? config, Config parent, ConfigLevel level);
/**
* Parse a string value as a bool.
*
* Valid values for true are: 'true', 'yes', 'on', 1 or any number
* different from 0
*
* Valid values for false are: 'false', 'no', 'off', 0
*/
[CCode(cname = "git_config_parse_bool")]
public static Error bool(out bool result, string @value);
/**
* Parse a string value as an int32.
*
* An optional value suffix of 'k', 'm', or 'g' will cause the value to be
* multiplied by 1024, 1048576, or 1073741824 prior to output.
*/
[CCode(cname = "git_config_parse_int32")]
public static Error parse_int32(out int32 result, string @value);
/**
* Parse a string value as an int64.
*
* An optional value suffix of 'k', 'm', or 'g' will cause the value to be
* multiplied by 1024, 1048576, or 1073741824 prior to output.
*/
[CCode(cname = "git_config_parse_int64")]
public static Error parse_int64(out int64 result, string @value);
/**
* Add a generic config file instance to an existing config
*
* Further queries on this config object will access each of the config
* file instances in order (instances with a higher priority will be
* accessed first).
*
* @param backend the configuration file (backend) to add
* @param level the priority level of the backend
* @param force if a config file already exists for the given priority level, replace it
*/
[CCode(cname = "git_config_add_backend")]
public Error add_backend(Configuration.backend backend, ConfigLevel level, bool force);
/**
* Add an on-disk config file instance to an existing config
*
* The on-disk file pointed at by path will be opened and parsed; it's
* expected to be a native Git config file following the default Git config
* syntax (see man git-config).
*
* Further queries on this config object will access each of the config
* file instances in order (instances with a higher priority will be
* accessed first).
*
* @param path path to the configuration file (backend) to add
* @param level the priority the backend should have
*/
[CCode(cname = "git_config_add_file_ondisk")]
public Error add_filename(string path, ConfigLevel level, bool force);
/**
* Delete a config variable
*
* @param name the variable to delete
*/
[CCode(cname = "git_config_delete_entry")]
public Error delete(string name);
/**
* Perform an operation on each config variable.
*
* The callback receives the normalized name and value of each variable in
* the config backend. As soon as one of the callback functions returns
* something other than 0, this function returns that value.
*
* @param config_for_each the function to call on each variable
*/
[CCode(cname = "git_config_foreach")]
public int for_each(ConfigForEach config_for_each);
/**
* Perform an operation on each config variable matching a regular expression.
*
* This behaviors like {@link for_each} with an additional filter of a
* regular expression that filters which config keys are passed to the
* callback.
*
* @param regexp regular expression to match against config names
* @param config_for_each the function to call on each variable
* @return 0 or the return value of the callback which didn't return 0
*/
[CCode(cname = "git_config_foreach_match")]
public int for_each_match(string regexp, ConfigForEach config_for_each);
/**
* Get the value of a boolean config variable.
*
* @param name the variable's name
* @param value where the value should be stored
*/
[CCode(cname = "git_config_get_bool")]
public Error get_bool(string name, out bool value);
/**
* Get the entry of a config variable.
* @param name the variable's name
*/
[CCode(cname = "git_config_get_entry", instance_pos = 1.1)]
public Error get_entry(out unowned config_entry? entry, string name);
/**
* Get the value of an integer config variable.
*
* @param name the variable's name
* @param value where the value should be stored
*/
[CCode(cname = "git_config_get_int")]
public Error get_int32(string name, out int32 value);
/**
* Get the value of a long integer config variable.
*
* @param name the variable's name
* @param value where the value should be stored
*/
[CCode(cname = "git_config_get_int64")]
public Error get_int64(string name, out int64 value);
/**
* Get each value of a multivar.
*
* The callback will be called on each variable found
*
* @param name the variable's name
* @param regexp regular expression to filter which variables we're interested in. Use NULL to indicate all
* @param fn the function to be called on each value of the variable
*/
[CCode(cname = "git_config_get_multivar")]
public Error get_multivar(string name, string? regexp, Configuration.Setter fn);
/**
* Get the value of a string config variable.
*
* @param name the variable's name
* @param value the variable's value
*/
public Error get_string(string name, out unowned string value);
/**
* Reload changed config files
*
* A config file may be changed on disk out from under the in-memory config
* object. This function causes us to look for files that have been
* modified since we last loaded them and refresh the config with the
* latest information.
*/
[CCode(cname = "git_config_refresh")]
public Error refresh();
/**
* Set the value of a boolean config variable.
*
* @param name the variable's name
* @param value the value to store
*/
[CCode(cname = "git_config_set_bool")]
public Error set_bool(string name, bool value);
/**
* Set the value of an integer config variable.
*
* @param name the variable's name
* @param value integer value for the variable
*/
[CCode(cname = "git_config_set_int32")]
public Error set_int32(string name, int32 value);
/**
* Set the value of a long integer config variable.
*
* @param name the variable's name
* @param value Long integer value for the variable
*/
[CCode(cname = "git_config_set_long64")]
public Error set_int64(string name, int64 value);
/**
* Set a multivar
*
* @param name the variable's name
* @param regexp a regular expression to indicate which values to replace
* @param value the new value.
*/
[CCode(cname = "git_config_set_multivar")]
public Error set_multivar(string name, string regexp, string @value);
/**
* Set the value of a string config variable.
*
* A copy of the string is made and the user is free to use it
* afterwards.
*
* @param name the variable's name
* @param value the string to store.
*/
[CCode(cname = "git_config_set_string")]
public Error set_string(string name, string value);
/**
* Query the value of a config variable and return it mapped to an integer
* constant.
*
* This is a helper method to easily map different possible values to a
* variable to integer constants that easily identify them.
*
* A mapping array looks as follows:
* {{{
* var autocrlf_mapping = Git.config_var_map[] {
* {Git.ConfigVar.FALSE, null, GIT_AUTO_CRLF_FALSE},
* {Git.ConfigVar.TRUE, null, GIT_AUTO_CRLF_TRUE},
* {Git.ConfigVar.STRING, "input", GIT_AUTO_CRLF_INPUT},
* {Git.ConfigVar.STRING, "default", GIT_AUTO_CRLF_DEFAULT}};
* }}}
*
* On any "false" value for the variable (e.g. "false", "FALSE", "no"), the
* mapping will store `GIT_AUTO_CRLF_FALSE` in the `out` parameter.
*
* The same thing applies for any "true" value such as "true", "yes" or "1", storing
* the `GIT_AUTO_CRLF_TRUE` variable.
*
* Otherwise, if the value matches the string "input" (with case insensitive comparison),
* the given constant will be stored in `out`, and likewise for "default".
*
* If not a single match can be made to store in `out`, an error code will be
* returned.
*
* @param name name of the config variable to lookup
* @param map array of objects specifying the possible mappings
* @param result place to store the result of the mapping
*/
[CCode(cname = "git_config_get_mapped", instance_pos = 1.1)]
public Error get_mapped(out int result, string name, [CCode(array_length_type = "size_t")] config_var_map[] map);
}
/**
* The diff list object that contains all individual file deltas.
*/
[CCode(cname = "git_diff_list", free_function = "git_diff_list_free")]
[Compact]
public class DiffList {
/**
* How many diff records are there in a diff list.
*/
public size_t num_deltas {
[CCode(cname = "git_diff_num_deltas")]
get;
}
/**
* Query how many diff records are there in a diff list.
* @param delta_t A delta type to filter the count, or -1 for all records
* @return Count of number of deltas matching delta_t type
*/
[CCode(cname = "git_diff_num_deltas_of_type")]
public size_t get_count(DeltaType delta_t = DeltaType.ALL);
/**
* Return the diff delta and patch for an entry in the diff list.
*
* For an unchanged file or a binary file, no patch will be created, and
* the {@link diff_delta.flags} will contain {@link DiffFlag.BINARY}.
*
* @param patch contains the text diffs for the delta.
* @param delta Output parameter for the delta object
* @param idx Index into diff list
*/
[CCode(cname = "git_diff_get_patch", instance_pos = 2.1)]
public Error get_patch(out Patch? patch, out unowned diff_delta? delta, size_t idx);
/**
* Merge one diff list into another.
*
* This merges items from the "from" list into the current list. The
* resulting diff list will have all items that appear in either list.
* If an item appears in both lists, then it will be "merged" to appear
* as if the old version was from the "onto" list and the new version
* is from the "from" list (with the exception that if the item has a
* pending DELETE in the middle, then it will show as deleted).
*
* @param from Diff to merge.
*/
[CCode(cname = "git_diff_merge")]
public Error merge(DiffList from);
/**
* Iterate over a diff list issuing callbacks.
*
* If the hunk and/or line callbacks are not null, then this will calculate
* text diffs for all files it thinks are not binary. If those are both
* null, then this will not bother with the text diffs, so it can be
* efficient.
*/
[CCode(cname = "git_diff_foreach", simple_generics = true)]
public Error foreach<T>(DiffFile<T>? file, DiffHunk<T> hunk, DiffLine<T>? line, T context);
/**
* Iterate over a diff generating text output like "git diff --name-status".
*/
[CCode(cname = "git_diff_print_compact")]
public Error print_compact(DiffOutput print);
/**
* Iterate over a diff generating text output like "git diff".
*
* This is a super easy way to generate a patch from a diff.
*/
[CCode(cname = "git_diff_print_patch")]
public Error print_patch(DiffOutput print);
/**
* Transform a diff list marking file renames, copies, etc.
*
* This modifies a diff list in place, replacing old entries that look like
* renames or copies with new entries reflecting those changes. This also
* will, if requested, break modified files into add/remove pairs if the
* amount of change is above a threshold.
*
* @param options Control how detection should be run, null for defaults
*/
[CCode(cname = "git_diff_find_similar")]
public Error find_similar(find_options? options = null);
}
[CCode(cname = "git_error", has_type_id = false, free_function = "")]
public class ErrorInfo {
/**
* The explanation of the error.
*/
public string message;
/**
* The error code.
*/
[CCode(cname = "klass")]
public ErrClass @class;
/**
* Return a detailed error string with the latest error
* that occurred in the library in this thread.
*/
[CCode(cname = "giterr_last")]
public static unowned ErrorInfo? get_last();
/**
* Clear the last library error for this thread.
*/
[CCode(cname = "giterr_clear")]
public static void clear();
}
/**
* Object ID Shortener object
*/
[CCode(cname = "git_oid_shorten", free_function = "git_oid_shorten_free", has_type_id = false)]
[Compact]
public class IdShortener {
/**
* Create a new id shortener.
*
* The id shortener is used to process a list of ids in text form and
* return the shortest length that would uniquely identify all of them.
*
* (e.g., look at the result of //git log --abbrev//)
*
* @param min_length The minimal length for all identifiers, which will be used even if shorter ids would still be unique.
*/
[CCode(cname = "git_oid_shorten_new")]
public IdShortener(size_t min_length);
/**
* Add a new id to set of shortened ids and calculate the minimal length to
* uniquely identify all the ids in the set.
*
* The id is expected to be a 40-char hexadecimal string.
*
* For performance reasons, there is a hard-limit of how many ids can be
* added to a single set (around ~22000, assuming a mostly randomized
* distribution), which should be enough for any kind of program, and keeps
* the algorithm fast and memory-efficient.
*
* Attempting to add more than those ids will result in a {@link ErrClass.NOMEMORY} error
*
* @param text_id an id in text form
* @return the minimal length to uniquely identify all ids added so far to the set; or an error code (<0) if an error occurs.
*/
[CCode(cname = "git_oid_shorten_add")]
public int add(string text_id);
}
/**
* Memory representation of an index file.
*/
[CCode(cname = "git_index", free_function = "git_index_free", has_type_id = false)]
[Compact]
public class Index {
/**
* Index capabilities flags.
*/
public IndexCapability capability {
[CCode(cname = "git_index_caps")]
get;
[CCode(cname = "git_index_set_caps")]
set;
}
/**
* Does the index contains entries representing file conflicts?
*/
public bool has_conflicts {
[CCode(cname = "git_index_has_conflicts")]
get;
}
public ReucIndex reuc {
[CCode(cname = "")]
get;
}
/**
* The repository this index relates to
*/
public Repository owner {
[CCode(cname = "git_index_owner")]
get;
}
/**
* The count of entries currently in the index
*/
public uint size {
[CCode(cname = "git_index_entrycount")]
get;
}
/**
* Create an in-memory index object.
*
* This index object cannot be read/written to the filesystem,
* but may be used to perform in-memory index operations.
*
* The index must be freed once it's no longer in use.
*/
[CCode(cname = "git_index_new")]
public static Error create(out Index? index);
/**
* Create a new bare Git index object as a memory representation of the Git
* index file in the index path, without a repository to back it.
*
* Since there is no ODB or working directory behind this index, any index
* methods which rely on these (e.g., {@link add}) will fail.
*
* If you need to access the index of an actual repository, use {@link Repository.get_index}.
*
* @param index where to put the new index
* @param index_path the path to the index file in disk
*/
public static Error open(out Index index, string index_path);
/**
* Add or update an index entry from an in-memory struct
*
* A full copy (including the path string) of the given source will be
* inserted on the index.
*
* @param entry new entry object
*/
[CCode(cname = "git_index_add")]
public Error add(IndexEntry entry);
/**
* Add (append) an index entry from a file on disk
*
* A new entry will always be inserted into the index; if the index already
* contains an entry for such path, the old entry will ''not'' be replaced.
*
* The file path must be relative to the repository's working folder and
* must be readable.
*
* This method will fail in bare index instances.
*
* This forces the file to be added to the index, not looking at gitignore
* rules.
*
* If this file currently is the result of a merge conflict, this file will
* no longer be marked as conflicting. The data about the conflict will be
* moved to the "resolve undo" (REUC) section.
*
* @param path filename to add
*/
[CCode(cname = "git_index_add_bypath")]
public Error add_path(string path);
/**
* Clear the contents (all the entries) of an index object.
*
* This clears the index object in memory; changes must be manually written
* to disk for them to take effect.
*/
[CCode(cname = "git_index_clear")]
public void clear();
/**
* Add or update index entries to represent a conflict
*
* The entries are the entries from the tree included in the merge. Any
* entry may be null to indicate that that file was not present in the
* trees during the merge. For example, the ancestor entry may be null to
* indicate that a file was added in both branches and must be resolved.
*
* @param ancestor_entry the entry data for the ancestor of the conflict
* @param our_entry the entry data for our side of the merge conflict
* @param their_entry the entry data for their side of the merge conflict
*/
[CCode(cname = "git_index_conflict_add")]
public Error conflict_add(IndexEntry? ancestor_entry, IndexEntry? our_entry, IndexEntry? their_entry);
/**
* Get the index entries that represent a conflict of a single file.
*
* The values of this entry can be modified (except the paths)
* and the changes will be written back to disk on the next
* write() call.
*
* @param ancestor Pointer to store the ancestor entry
* @param our Pointer to store the our entry
* @param their Pointer to store the their entry
* @param path path to search
*/
[CCode(cname = "git_index_conflict_get", instance_pos = 3.1)]
public Error conflict_get(out unowned IndexEntry? ancestor, out unowned IndexEntry? our, out unowned IndexEntry? their, string path);
/**
* Remove all conflicts in the index (entries with a stage greater than 0.)
*/
[CCode(cname = "git_index_conflict_cleanup")]
public void conflict_cleanup();
/**
* Removes the index entries that represent a conflict of a single file.
*
* @param path to search
*/
[CCode(cname = "git_index_conflict_remove")]
public Error conflict_remove(string path);
/**
* Find the first index of any entries which point to given path in the Git
* index.
*
* @param at_pos the address to which the position of the reuc entry is written (optional)
* @param path path to search
*/
[CCode(cname = "git_index_find", instance_pos = 1.1)]
public Error find(out size_t at_pos, string path);
/**
* Get a pointer to one of the entries in the index
*
* This entry can be modified, and the changes will be written back to disk
* on the next {@link write} call.
*
* @param n the position of the entry
* @return the entry; null if out of bounds
*/
[CCode(cname = "git_index_get_byindex")]
public unowned IndexEntry? get(size_t n);
/**
* Get a pointer to one of the entries in the index
*
* The values of this entry can be modified (except the path) and the
* changes will be written back to disk on the next {@link write} call.
*
* @param path path to search
* @param stage stage to search
*/
[CCode(cname = "git_index_get_bypath")]
public unowned IndexEntry? get_by_path(string path, int stage);
/**
* Remove all entries with equal path except last added
*/
[CCode(cname = "git_index_uniq")]
public void make_unique();
/**
* Update the contents of an existing index object in memory by reading
* from the hard disk.
*/
[CCode(cname = "git_index_read")]
public Error read();
/**
* Read a tree into the index file with stats
*
* The current index contents will be replaced by the specified tree.
*
* @param tree tree to read
*/
[CCode(cname = "git_index_read_tree")]
public Error read_tree(Tree tree);
/**
* Remove an entry from the index
*/
[CCode(cname = "git_index_remove")]
public Error remove(string path, int stage);
/**
* Remove all entries from the index under a given directory
*
* @param dir container directory path
* @param stage stage to search
*/
[CCode(cname = "git_index_remove_directory")]
public Error remove_directory(string dir, int stage);
/**
* Remove an index entry corresponding to a file on disk
*
* The file path must be relative to the repository's working folder. It
* may exist.
*
* If this file currently is the result of a merge conflict, this file will
* no longer be marked as conflicting. The data about the conflict will be
* moved to the "resolve undo" (REUC) section.
*
* @param path filename to remove
*/
[CCode(cname = "git_index_remove_bypath")]
public Error remove_path(string path);
/**
* Write an existing index object from memory back to disk using an atomic
* file lock.
*/
[CCode(cname = "git_index_write")]
public Error write();
/**
* Write the index as a tree
*
* This method will scan the index and write a representation of its
* current state back to disk; it recursively creates
* tree objects for each of the subtrees stored in the index, but only
* returns the OID of the root tree. This is the OID that can be used e.g.
* to create a commit.
*
* The index instance cannot be bare, and needs to be associated to an
* existing repository.
*
* The index must not contain any file in conflict.
*/
[CCode(cname = "git_index_write_tree", instance_pos = -1)]
public Error write_tree(out object_id id);
/**
* Write the index as a tree to the given repository
*
* This method will do the same as {@link write_tree}, but letting the user
* choose the repository where the tree will be written.
*
* The index must not contain any file in conflict.
*
* @param id Pointer where to store OID of the the written tree
* @param repo Repository where to write the tree
*/
[CCode(cname = "git_index_write_tree_to", instance_pos = 1.1)]
public Error write_tree_to(out object_id id, Repository repo);
}
[CCode(cname = "git_indexer_stream", free_function = "git_indexer_stream_free", has_type_id = false)]
public class IndexerStream {
/**
* The packfile's hash
*
* A packfile's name is derived from the sorted hashing of all object
* names. This is only correct after the index has been finalized.
*/
public object_id? hash {
[CCode(cname = "git_indexer_stream_hash")]
get;
}
/**
* Create a new streaming indexer instance
*
* @param indexer_stream where to store the indexer instance
* @param path to the directory where the packfile should be stored
*/
[CCode(cname = "git_indexer_stream_new")]
public static Error open(out IndexerStream indexer_stream, string path, TransferProgress transfer);
/**
* Add data to the indexer
*
* @param data the data to add
* @param stats stat storage
*/
[CCode(cname = "git_indexer_stream_add")]
public Error add([CCode(array_length_type = "size_t")] uint8[] data, transfer_progress stats);
/**
* Finalize the pack and index
*
* Resolve any pending deltas and write out the index file
*/
[CCode(cname = "git_indexer_stream_finalize")]
public Error finalize(transfer_progress stats);
}
/**
* Memory representation of a file entry in the index.
*/
[CCode(cname = "git_index_entry", has_type_id = false)]
[Compact]
public class IndexEntry {
public Attributes flags;
public index_time ctime;
public index_time mtime;
public int64 file_size;
[CCode(cname = "oid")]
public object_id id;
public string path;
public uint16 flags_extended;
public uint dev;
public uint gid;
public uint ino;
public uint mode;
public uint uid;
/**
* The stage number from a git index entry
*/
public int stage {
[CCode(cname = "git_index_entry_stage")]
get;
}
}
/**
* A note attached to an object
*/
[CCode(cname = "git_note", free_function = "git_note_free", has_type_id = false)]
[Compact]
public class Note {
/**
* The message for this note
*/
public string message {
[CCode(cname = "git_note_message")]
get;
}
/**
* The note object OID
*/
public object_id? id {
[CCode(cname = "git_note_oid")]
get;
}
}
[CCode(cname = "git_note_iterator ", free_function = "git_note_iterator_free", has_type_id = false)]
[Compact]
public class NoteIterator {
/**
* Returns the current item and advance the iterator internally to the next
* value.
*/
[CCode(cname = "git_note_next", instance_pos = -1)]
public Error next(out object_id note_id, out object_id annotated_id);
}
/**
* Representation of a generic object in a repository
*/
[CCode(cname = "git_object", free_function = "git_object_free", has_type_id = false)]
[Compact]
public class Object {
/**
* The id (SHA1) of a repository object
*/
public object_id? id {
[CCode(cname = "git_object_id")]
get;
}
/**
* The object type of an object
*/
public ObjectType type {
[CCode(cname = "git_object_type")]
get;
}
/**
* The repository that owns this object
*/
public Repository repository {
[CCode(cname = "git_object_owner")]
get;
}
/**
* Recursively peel an object until an object of the specified type is met
*
* @param target_type The type of the requested object
*/
[CCode(cname = "git_object_peel", instance_pos = 1.1)]
public Error peel(out Object? peeled, ObjectType target_type);
}
[Compact]
[CCode(cname = "git_packbuilder", free_function = "git_packbuilder_free", has_type_id = false)]
public class PackBuilder {
/**
* The total number of objects the packbuilder will write out
*/
public uint32 count {
[CCode(cname = "packbuilder_object_count")]
get;
}
/**
* The number of objects the packbuilder has already written out
*/
public uint32 written {
[CCode(cname = "git_packbuilder_written")]
get;
}
/**
* Set number of threads to spawn
*
* By default, libgit2 won't spawn any threads at all; when set to 0,
* libgit2 will autodetect the number of CPUs.
*
* @param n Number of threads to spawn
* @return number of actual threads to be used
*/
[CCode(cname = "git_packbuilder_set_threads")]
public uint set_threads(uint n);
/**
* Insert a single object
*
* For an optimal pack it's mandatory to insert objects in recency order,
* commits followed by trees and blobs.
*
* @param id The oid of the commit
* @param name The name
*/
[CCode(cname = "git_packbuilder_insert")]
public Error insert(object_id id, string? name);
/**
* Insert a root tree object
*
* This will add the tree as well as all referenced trees and blobs.
*
* @param id The oid of the root tree
*/
[CCode(cname = "git_packbuilder_insert_tree")]
public Error insert_tree(object_id id);
/**
* Write the new pack and the corresponding index to path
*
* @param path Directory to store the new pack and index
*/
[CCode(cname = "git_packbuilder_write")]
public Error write(string path);
/**
* Create the new pack and pass each object to the callback
*/
[CCode(cname = "git_packbuilder_foreach")]
public Error for_each(PackBuilderForEach pack_builder_for_each);
}
/**
* The list of parents of a commit
*/
[Compact]
[CCode(cname = "git_commit", has_type_id = false)]
public class Parents {
/**
* Get the number of parents of this commit
*/
public uint size {
[CCode(cname = "git_commit_parentcount")]
get;
}
/**
* Get the id of a specified parent for a commit.
*
* This is different from {@link Parents.lookup}, which will attempt
* to load the parent commit from the ODB.
*
* @param n the position of the parent
* @return the id of the parent, null on error.
*/
[CCode(cname = "git_commit_parent_id")]
public unowned object_id? get(uint n);
/**
* Get the specified parent of the commit.
*
* @param parent where to store the parent commit
* @param n the position of the parent
*/
[CCode(cname = "git_commit_parent", instance_pos = 1.2)]
public Error lookup(out Commit parent, uint n);
}
[CCode(cname = "git_diff_patch ", free_function = "git_diff_patch_free", has_type_id = false)]
[Compact]
public class Patch {
/**
* The delta associated with a patch
*/
public diff_delta? delta {
[CCode(cname = "git_diff_patch_delta")]
get;
}
/**
* The number of hunks in a patch
*/
public size_t num_hunks {
[CCode(cname = "git_diff_patch_num_hunks")]
get;
}
/**
* Get the information about a hunk in a patch
*
* Given a patch and a hunk index into the patch, this returns detailed
* information about that hunk. Any of the output pointers can be passed
* as NULL if you don't care about that particular piece of information.
*
* @param range Range of the hunk
* @param header Header string for hunk. Unlike the content for each line,
* this will be NUL-terminated
* @param lines_in_hunk Count of total lines in this hunk
* @param hunk_idx Input index of hunk to get information about
*/
[CCode(cname = "git_diff_patch_get_hunk", instance_pos = 3.1)]
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);
/**
* Get data about a line in a hunk of a patch.
*
* Given a patch, a hunk index, and a line index in the hunk, this will
* return a lot of details about that line. If you pass a hunk index
* larger than the number of hunks or a line index larger than the number
* of lines in the hunk, this will return -1.
*
* @param old_lineno Line number in old file or -1 if line is added
* @param new_lineno Line number in new file or -1 if line is deleted
* @param hunk_idx The index of the hunk
* @param line_of_hunk The index of the line in the hunk
*/
[CCode(cname = "git_diff_patch_get_line_in_hunk", instance_pos = 4.1)]
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);
/**
* Get line counts of each type in a patch.
*
* This helps imitate a '''diff --numstat''' type of output. For that
* purpose, you only need the total additions and total_deletions values,
* but we include the total context line count in case you want the total
* number of lines of diff output that will be generated.
*
* @param total_context Count of context lines in output.
* @param total_additions Count of addition lines in output.
* @param total_deletions Count of deletion lines in output.
* @return Number of lines in hunk or -1 if invalid hunk index
*/
[CCode(cname = "git_diff_patch_line_stats", instance_pos = -1)]
public int get_line_stats(out size_t total_context, out size_t total_additions, out size_t total_deletions);
/**
* Get the number of lines in a hunk.
*
* @param hunk_idx Index of the hunk
* @return Number of lines in hunk or -1 if invalid hunk index
*/
[CCode(cname = "git_diff_patch_num_lines_in_hunk")]
public int num_lines_in_hunk(size_t hunk_idx);
/**
* Serialize the patch to text via callback.
*/
[CCode(cname = "git_diff_patch_print")]
public Error patch_print(DiffOutput print);
/**
* Get the content of a patch as a single diff text.
*/
[CCode(cname = "git_diff_patch_to_str", instance_pos = -1)]
public Error to_str(out string str);
public string? to_string() {
string str;
return to_str(out str) == Error.OK ? str : null;
}
}
[Compact]
[CCode(cname = "git_push", free_function = "git_push_free", has_type_id = false)]
public class Push {
/**
* Check if remote side successfully unpacked
*/
public bool unpack_ok {
[CCode(cname = "git_push_unpack_ok")]
get;
}
/**
* Add a refspec to be pushed
*/
[CCode(cname = "git_push_add_refspec")]
public Error add_refspec(string refspec);
/**
* Actually push all given refspecs
*
* To check if the push was successful (i.e. all remote references have
* been updated as requested), you need to call both {@link unpack_ok} and
* {@link for_each}. The remote repository might have refused to update
* some or all of the references.
*/
[CCode(cname = "git_push_finish")]
public Error finish();
/**
* Iterate over each status.
*
* For each of the updated references, we receive a status report in the
* form of '''ok refs/heads/master''' or '''ng refs/heads/master ///msg///'''.
* If the message is not null, this means the reference has not been
* updated for the given reason.
*
*/
[CCode(cname = "git_push_status_foreach")]
public Error for_each(PushForEach push_for_each);
/**
* Set options on a push object
*
* @param opts The options to set on the push object
*/
[CCode(cname = "git_push_set_options")]
public Error set_options(push_options opts);
/**
* Update remote tips after a push
*/
[CCode(cname = "git_push_update_tips")]
public Error update_tips();
}
[CCode(cname = "git_refdb", has_type_id = false, free_function = "git_refdb_free")]
public class RefDb {
/**
* Create a new reference. Either an oid or a symbolic target must be
* specified.
*
* @param name the reference name
* @param id the object id for a direct reference
* @param symbolic the target for a symbolic reference
*/
[CCode(cname = "git_reference__alloc")]
public Reference? alloc(string name, object_id id, string symbolic);
/**
* Suggests that the given refdb compress or optimize its references.
*
* This mechanism is implementation specific. For on-disk reference
* databases, for example, this may pack all loose references.
*/
[CCode(cname = "git_refdb_compress")]
public Error compress();
/**
* Sets the custom backend to an existing reference DB
*/
[CCode(cname = "git_refdb_set_backend")]
public Error set_backend(owned refdb_backend backend);
}
/**
* In-memory representation of a reference.
*/
[CCode(cname = "git_reference", free_function = "git_reference_free", has_type_id = false)]
[Compact]
public class Reference {
/**
* Check if a reflog exists for the specified reference.
*/
public bool has_log {
[CCode(cname = "git_reference_has_log")]
get;
}
/**
* Check if a reference is a local branch.
*/
public bool is_branch {
[CCode(cname = "git_reference_is_branch")]
get;
}
/**
* Determine if the current local branch is pointed at by HEAD.
*/
public bool is_head {
[CCode(cname = "0 != git_branch_is_head")]
get;
}
/**
* If a reference is a remote tracking branch
*/
public bool is_remote {
[CCode(cname = "git_reference_is_remote")]
get;
}
/**
* The full name of a reference
*/
public string name {
[CCode(cname = "git_reference_name")]
get;
}
/**
* The repository where a reference resides
*/
public Repository repository {
[CCode(cname = "git_reference_owner")]
get;
}
/**
* The full name to the reference pointed by this reference
*
* Only available if the reference is symbolic
*/
public string? symbolic_target {
[CCode(cname = "git_reference_symbolic_target")]
get;
}
/**
* The id pointed to by a reference.
*
* Only available if the reference is direct (i.e., not symbolic)
*/
public object_id? target {
[CCode(cname = "git_reference_target")]
get;
}
/**
* The type of a reference
*
* Either direct, {@link ReferenceType.ID}, or symbolic, {@link ReferenceType.SYMBOLIC}
*/
public ReferenceType type {
[CCode(cname = "git_reference_type")]
get;
}
/**
* Ensure the reference name is well-formed.
*
* Valid reference names must follow one of two patterns:
*
* 1. Top-level names must contain only capital letters and underscores,
* and must begin and end with a letter. (e.g. "HEAD", "ORIG_HEAD").
* 2. Names prefixed with "refs/" can be almost anything. You must avoid
* the characters '~', '^', ':', '\\', '?', '[', and '*', and the
* sequences ".." and "@{" which have special meaning to revparse.
*/
[CCode(cname = "git_reference_is_valid_name")]
public static bool is_valid_name(string refname);
/**
* Delete an existing branch reference.
*/
[CCode(cname = "git_branch_delete")]
public static Error delete_branch(owned Reference reference);
/**
* Normalize the reference name by removing any leading slash (/)
* characters and collapsing runs of adjacent slashes between name
* components into a single slash.
*
* Once normalized, if the reference name is valid, it will be returned in
* the user allocated buffer.
* @param buffer The buffer where the normalized name will be stored.
* @param name name to be checked.
* @param flags Flags to determine the options to be applied while checking
* the validatity of the name.
*/
[CCode(cname = "git_reference_normalize_name")]
public static Error normalize_name([CCode(array_length_type = "size_t")] uint8[] buffer, string name, ReferenceFormat flags);
/**
* Compare two references.
*
* @return 0 if the same, else a stable but meaningless ordering.
*/
[CCode(cname = "git_reference_cmp")]
public int compare(Reference other);
/**
* Delete an existing reference
*
* This method works for both direct and symbolic references.
*
* The reference will be immediately removed on disk.
*/
[CCode(cname = "git_reference_delete")]
public void @delete();
/**
* Delete the reflog for the given reference
*/
[CCode(cname = "git_reflog_delete")]
public Error delete_reflog();
/**
* Return the name of the given local or remote branch.
*
* The name of the branch matches the definition of the name for
* {@link Repository.lookup_branch}. That is, if the returned name is
* looked up then the reference is returned that was given to this
* function.
*
* @param name where the pointer of branch name is stored;
* this is valid as long as the ref is not freed.
*/
[CCode(cname = "git_branch_name", instance_pos = -1)]
public Error get_branch_name(out unowned string name);
/**
* Read the reflog for the given reference
*
* @param reflog where to put the reflog
*/
[CCode(cname = "git_reflog_read", instance_pos = -1)]
public Error get_reflog(out ReferenceLog? reflog);
/**
* Return the reference supporting the remote tracking branch, given a
* reference branch.
*
* The input reference has to be located in the '''refs/heads''' namespace.
*
*/
[CCode(cname = "git_reference_remote_tracking_from_branch", instance_pos = -1)]
public Error get_remote_tracking_from_branch(out Reference tracking_ref);
/**
* Return the reference supporting the remote tracking branch, given a
* local branch reference.
*/
[CCode(cname = "git_branch_tracking", instance_pos = -1)]
public Error get_tracking(out Reference? tracking);
/**
* Move/rename an existing branch reference.
*
* @param new_branch_name Target name of the branch once the move
* is performed; this name is validated for consistency.
*
* @param force Overwrite existing branch.
*/
[CCode(cname = "git_branch_move", instance_pos = 1.1)]
public Error move_branch(out Reference? moved, string new_branch_name, bool force);
/**
* Recursively peel an reference until an object of the specified type is
* met.
*
* If you pass {@link ObjectType.ANY} as the target type, then the object
* will be peeled until a non-tag object is met.
*
* @param target_type The type of the requested object
*/
[CCode(cname = "git_reference_peel", instance_pos = 1.1)]
public Error peel(out Object? peeled, ObjectType target_type);
/**
* Rename an existing reference
*
* This method works for both direct and symbolic references.
* The new name will be checked for validity and may be
* modified into a normalized form.
*
* The refernece will be immediately renamed in-memory
* and on disk.
*
* ''IMPORTANT:'' The user needs to write a proper reflog entry if the
* reflog is enabled for the repository. We only rename the reflog if it
* exists.
*
*/
[CCode(cname = "git_reference_rename", instance_pos = 1.1)]
public Error rename(out Reference? renamed_reference, string new_name, bool force);
/**
* Resolve a symbolic reference
*
* Thie method iteratively peels a symbolic reference
* until it resolves to a direct reference to an id.
*
* If a direct reference is passed as an argument,
* that reference is returned immediately
*
* @param resolved the peeled reference
*/
[CCode(cname = "git_reference_resolve", instance_pos = -1)]
public Error resolve(out Reference resolved);
/**
* Create a new reference with the same name as the given reference but a
* different symbolic target.
*
* The reference must be a symbolic reference, otherwise this will fail.
*
* The new reference will be written to disk, overwriting the given
* reference.
*
* @param id the new target id for the reference
*/
[CCode(cname = "git_reference_set_oid", instance_pos = 1.1)]
public Error set_target(out Reference? retargeted, object_id id);
/**
* Set the symbolic target of a reference.
*
* The reference must be a symbolic reference, otherwise this method will
* fail.
*
* The reference will be automatically updated in memory and on disk.
*
* @param target The new target for the reference
*/
[CCode(cname = "git_reference_symbolic_set_target")]
public Error set_symbolic_target(string target);
}
/**
* Representation of a reference log
*/
[CCode(cname = "git_reflog", free_function = "git_reflog_free", has_type_id = false)]
[Compact]
public class ReferenceLog {
/**
* The number of log entries in a reflog
*/
public size_t size {
[CCode(cname = "git_reflog_entrycount")]
get;
}
/**
* Add a new entry to the reflog.
*
* If there is no reflog file for the given reference yet, it will be
* created.
*
* @param id the id the reference is now pointing to
* @param committer the signature of the committer
* @param msg the reflog message
*/
[CCode(cname = "git_reflog_append")]
public Error append(out object_id id, Signature committer, string? msg = null);
/**
* Remove an entry from the reflog by its index
*
* To ensure there's no gap in the log history, when deleting an entry,
* member old_oid of the previous entry (if any) will be updated with the
* value of memeber new_oid of next entry.
*
* @param idx the position of the entry to remove.
*
* @param rewrite_previous_entry true to rewrite the history; 0 otherwise.
*
*/
[CCode(cname = "git_reflog_drop")]
public Error drop(size_t idx, bool rewrite_previous_entry);
/**
* Lookup an entry by its index
*
* @param idx the position to lookup
* @return the entry; null if not found
*/
[CCode(cname = "git_reflog_entry_byindex")]
public unowned ReferenceLogEntry? get(size_t idx);
/**
* Rename the reflog for the given reference
*
* @param new_name the new name of the reference
*/
[CCode(cname = "git_reflog_rename")]
public Error rename(string new_name);
/**
* Write an existing in-memory reflog object back to disk using an atomic
* file lock.
*
* If there is no reflog file for the given reference yet, it will be
* created.
*/
[CCode(cname = "git_reflog_write")]
public Error write();
}
/**
* Representation of a reference log entry
*/
[CCode(cname = "git_reflog_entry", has_type_id = false)]
[Compact]
public class ReferenceLogEntry {
/**
* The committer of this entry
*/
public Signature commiter {
[CCode(cname = "git_reflog_entry_committer")]
get;
}
/**
* The log message
*/
public string message {
[CCode(cname = "git_reflog_entry_msg")]
get;
}
/**
* The new id at this time
*/
public object_id? new_id {
[CCode(cname = "git_reflog_entry_id_new")]
get;
}
/**
* The old id
*/
public object_id? old_id {
[CCode(cname = "git_reflog_entry_id_old")]
get;
}
}
/**
* Reference to a remote repository
*/
[CCode(cname = "git_remote", free_function = "git_remote_free", has_type_id = false)]
[Compact]
public class Remote {
[CCode(cname = "git_remote_rename_problem_cb")]
public delegate bool RenameProblem(string problematic_refspec);
/**
* The tag auto-follow setting
*/
public AutoTag autotag {
[CCode(cname = "git_remote_autotag")]
get;
[CCode(cname = "git_remote_set_autotag")]
set;
}
/**
* Choose whether to check the server's certificate (applies to HTTPS only)
*/
public bool check_cert {
[CCode(cname = "git_remote_check_cert")]
set;
}
/**
* Whether the remote is connected
*
* Whether the remote's underlying transport is connected to the remote
* host.
*/
public bool is_connected {
[CCode(cname = "git_remote_connected")]
get;
}
/**
* The fetch refspec, if it exists
*/
public ref_spec? fetch_spec {
[CCode(cname = "git_remote_fetchspec")]
get;
[CCode(cname = "git_remote_set_fetchspec")]
set;
}
/**
* The remote's name
*/
public string? name {
[CCode(cname = "git_remote_name")]
get;
}
/**
* The push refspec, if it existsc
*/
public ref_spec? push_spec {
[CCode(cname = "git_remote_pushspec")]
get;
[CCode(cname = "git_remote_set_pushspec")]
set;
}
/**
* The statistics structure that is filled in by the fetch operation.
*/
public transfer_progress stats {
[CCode(cname = "git_remote_stats")]
get;
}
/**
* Update FETCH_HEAD on ever fetch.
*/
public bool update_fetchhead {
[CCode(cname = "git_remote_update_fetchhead")]
get;
[CCode(cname = "git_remote_set_update_fetchhead")]
set;
}
/**
* The remote's URL
*/
public string url {
[CCode(cname = "git_remote_url")]
get;
}
/**
* Ensure the remote name is well-formed.
*
* @param remote_name name to be checked.
*/
[CCode(cname = "git_remote_is_valid_name")]
public static bool is_valid_name(string remote_name);
/**
* Return whether a string is a valid remote URL
*
* @param url the url to check
*/
[CCode(cname = "git_remote_valid_url")]
public static bool is_valid_url(string url);
/**
* Return whether the passed URL is supported by this version of the library.
*
* @param url the url to check
*/
[CCode(cname = "git_remote_supported_url")]
public static bool is_supported_url(string url);
/**
* Create a new push object
*/
[CCode(cname = "git_push_new", instance_pos = -1)]
public Error create_push(out Push? push);
/**
* Open a connection to a remote
*
* The transport is selected based on the URL. The direction argument is
* due to a limitation of the git protocol (over TCP or SSH) which starts
* up a specific binary which can only do the one or the other.
*
* @param direction whether you want to receive or send data
*/
[CCode(cname = "git_remote_connect")]
public Error connect(Direction direction);
/**
* Download the packfile
*
* Negotiate what objects should be downloaded and download the packfile
* with those objects.
*/
[CCode(cname = "git_remote_download")]
public Error download(Progress progress);
/**
* Disconnect from the remote
*
* Close the connection to the remote and free the underlying transport.
*/
[CCode(cname = "git_remote_disconnect")]
public void disconnect();
/**
* Get a list of refs at the remote
*
* The remote (or more exactly its transport) must be connected.
*/
[CCode(cname = "git_remote_ls", instance_pos = -1)]
public Error list(Head headcb);
/**
* Give the remote a new name
*
* All remote-tracking branches and configuration settings for the remote
* are updated.
*
* The new name will be checked for validity.
*
* A temporary in-memory remote cannot be given a name with this method.
*
* @param new_name the new name the remote should bear
* @param rename_problem Optional callback to notify the consumer of fetch refspecs
* that haven't been automatically updated and need potential manual tweaking.
* @see Repository.create_tag
*/
[CCode(cname = "git_remote_rename")]
public Error rename(string new_name, RenameProblem? rename_problem = null);
/**
* Save a remote to its repository's configuration
*
* One can't save a in-memory remote. Doing so will result in a
* {@link Error.INVALIDSPEC} being returned.
*/
[CCode(cname = "git_remote_save")]
public Error save();
/**
* Set the callbacks for a remote
*/
[CCode(cname = "git_remote_set_callbacks", simple_generics = true)]
public Error set_callbacks<T>(remote_callbacks<T> callbacks);
/**
* Sets the owning repository for the remote. This is only allowed on
* dangling remotes.
*/
[CCode(cname = "git_remote_set_repository")]
public Error set_repository(Repository repo);
/**
* Sets a credentials acquisition callback for this remote.
*
* If the remote is not available for anonymous access, then you must set
* this callback in order to provide credentials to the transport at the
* time of authentication failure so that retry can be performed.
*/
[CCode(cname = "git_remote_set_cred_acquire_cb")]
public void set_cred_acquire(CredAcquire? cred_acquire);
/**
* Sets a custom transport for the remote. The caller can use this function
* to bypass the automatic discovery of a transport by URL scheme (i.e.,
* http, https, git) and supply their own transport to be used
* instead. After providing the transport to a remote using this function,
* the transport object belongs exclusively to that remote, and the remote will
* free it when it is freed with git_remote_free.
*
* @param transport the transport object for the remote to use
*/
[CCode(cname = "git_remote_set_transport")]
public Error set_transport(transport transport);
/**
* Cancel the operation
*
* At certain points in its operation, the network code checks whether the
* operation has been cancelled and if so stops the operation.
*/
[CCode(cname = "git_remote_stop")]
public void stop();
/**
* Update the tips to the new state
*
* Make sure that you only call this once you've successfully indexed or
* expanded the packfile.
*/
[CCode(cname = "git_remote_update_tips")]
public Error update_tips(Update update);
}
/**
* Representation of an existing git repository,
* including all its object contents
*/
[CCode(cname = "git_repository", free_function = "git_repository_free", has_type_id = false)]
[Compact]
public class Repository {
public Attr attributes {
[CCode(cname = "")]
get;
}
/**
* Check if a repository is bare
*/
public bool is_bare {
[CCode(cname = "git_repository_is_bare")]
get;
}
/**
* Check if a repository's HEAD is detached
*
* A repository's HEAD is detached when it points directly to a commit
* instead of a branch.
*/
public bool is_head_detached {
[CCode(cname = "git_repository_head_detached")]
get;
}
/**
* Check if the current branch is an orphan
*
* An orphan branch is one named from HEAD but which doesn't exist in
* the refs namespace, because it doesn't have any commit to point to.
*/
public bool is_head_orphan {
[CCode(cname = "git_repository_head_orphan")]
get;
}
/**
* Check if a repository is empty
*
* An empty repository has just been initialized and contains no commits.
*/
public bool is_empty {
[CCode(cname = "git_repository_is_empty")]
get;
}
/**
* The path to the repository.
*/
public string? path {
[CCode(cname = "git_repository_path")]
get;
}
/**
* Determines the status of a git repository (i.e., whether an operation
* such as a merge or cherry-pick is in progress).
*/
public State state {
[CCode(cname = "git_repository_state")]
get;
}
/**
* The working directory for this repository
*
* If the repository is bare, this is null.
*
* If this repository is bare, setting its working directory will turn it
* into a normal repository, capable of performing all the common workdir
* operations (checkout, status, index manipulation, etc).
*/
public string? workdir {
[CCode(cname = "git_repository_workdir")]
get;
set {
set_workdir(value, true);
}
}
/**
* Clone a remote repository, and checkout the branch pointed to by the remote
* HEAD.
*
* @param origin_url repository to clone from
* @param dest_path local directory to clone to
* @param clone_opts configuration options for the clone.
*/
[CCode(cname = "git_clone")]
public static Error clone(out Repository? repo, string origin_url, string dest_path, clone_opts? clone_opts = null);
/**
* Look for a git repository and copy its path in the given buffer. The lookup start
* from base_path and walk across parent directories if nothing has been found. The
* lookup ends when the first repository is found, or when reaching a directory
* referenced in ceiling_dirs or when the filesystem changes (in case across_fs
* is true).
*
* The method will automatically detect if the repository is bare (if there is
* a repository).
*
* @param repository_path The buffer which will contain the found path.
*
* @param start_path The base path where the lookup starts.
*
* @param across_fs If true, then the lookup will not stop when a filesystem device change
* is detected while exploring parent directories.
*
* @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.
*/
public static Error discover([CCode(array_length_type = "size_t")] char[] repository_path, string start_path, bool across_fs = true, string? ceiling_dirs = null);
/**
* Creates a new Git repository in the given folder.
*
* @param repo the repo which will be created or reinitialized
* @param path the path to the repository
* @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.
*/
[CCode(cname = "git_repository_init")]
public static Error init(out Repository repo, string path, bool is_bare);
/**
* Create a new Git repository in the given folder with extended controls.
*
* This will initialize a new git repository (creating the path if
* requested by flags) and working directory as needed. It will
* auto-detect the case sensitivity of the file system and if the file
* system supports file mode bits correctly.
*
* @param repo_path The path to the repository.
* @param opts Pointer to git_repository_init_options struct.
*/
[CCode(cname = "git_repository_init_ext")]
public static Error init_ext(out Repository? repo, string repo_path, init_options opts);
/**
* Open a git repository.
*
* The path argument must point to an existing git repository
* folder. The repository can be normal (having a //.git// directory)
* or bare (having objects, index, and HEAD directly).
* The method will automatically detect if path is a normal
* or bare repository or fail is path is neither.
*
* @param repository the repo which will be opened
* @param path the path to the repository
*/
[CCode(cname = "git_repository_open")]
public static Error open(out Repository? repository, string path);
/**
* Find and open a repository with extended controls.
*/
[CCode(cname = "git_repository_open_ext")]
public static Error open_ext(out Repository? repository, string start_path, OpenFlags flags, string ceiling_dirs);
/**
* Add ignore rules for a repository.
*
* Excludesfile rules (i.e. .gitignore rules) are generally read from
* .gitignore files in the repository tree or from a shared system file
* only if a "core.excludesfile" config value is set. The library also
* keeps a set of per-repository internal ignores that can be configured
* in-memory and will not persist. This function allows you to add to
* that internal rules list.
*
* @param rules Text of rules, a la the contents of a .gitignore file. It
* is okay to have multiple rules in the text; if so, each rule should be
* terminated with a newline.
*/
[CCode(cname = "git_ignore_add_rule")]
public Error add_ignore(string rules);
/**
* Set up a new git submodule for checkout.
*
* This does '''git submodule add''' up to the fetch and checkout of the
* submodule contents. It preps a new submodule, creates an entry in
* .gitmodules and creates an empty initialized repository either at the
* given path in the working directory or in .git/modules with a gitlink
* from the working directory to the new repo.
*
* To fully emulate '''git submodule add''' call this function, then open
* the submodule repo and perform the clone step as needed. Lastly, call
* {@link Submodule.add_finalize} to wrap up adding the new submodule and
* .gitmodules to the index to be ready to commit.
*
* @param submodule The newly created submodule ready to open for clone
* @param url URL for the submodules remote
* @param path Path at which the submodule should be created
* @param use_gitlink Should workdir contain a gitlink to the repo in
* .git/modules vs. repo directly in workdir.
*/
[CCode(cname = "git_submodule_add_setup", instance_pos = 1.1)]
public Error add_submodule_setup(out Submodule? submodule, string url, string path, bool use_gitlink);
/**
* Remove all the metadata associated with an ongoing git merge, including
* MERGE_HEAD, MERGE_MSG, etc.
*/
[CCode(cname = "git_repository_merge_cleanup")]
public Error cleanup_merge();
/**
* Clear ignore rules that were explicitly added.
*
* Resets to the default internal ignore rules. This will not turn off
* rules in .gitignore files that actually exist in the filesystem.
*
* The default internal ignores ignore '''.''', '''..''' and '''.git''' entries.
*/
public Error clear_internal_ignores();
/**
* Updates files in the index and the working tree to match the commit pointed to by HEAD.
*
* @param opts specifies checkout options
*/
[CCode(cname = "git_checkout_head")]
public Error checkout_head(checkout_opts? opts = null);
/**
* Updates files in the working tree to match the content of the index.
*
* @param opts specifies checkout options
* @param index index to be checked out (or null to use repository index)
*/
[CCode(cname = "git_checkout_index")]
public Error checkout_index(Index? index = null, checkout_opts? opts = null);
/**
* Updates files in the index and working tree to match the content of a
* tree.
*
* @param treeish a commit, tag or tree which content will be used to
* update the working directory
* @param opts specifies checkout options
*/
[CCode(cname = "git_checkout_tree")]
public Error checkout_tree(Object treeish, checkout_opts? opts = null);
/**
* Count the number of unique commits between two commit objects
*
* There is no need for branches containing the commits to have any
* upstream relationship, but it helps to think of one as a branch and the
* other as its upstream, the ahead and behind values will be what git
* would report for the branches.
*
* @param ahead number of unique commits in upstream
* @param behind number of unique commits in local
* @param local one of the commits
* @param upstream the other commit
*/
[CCode(cname = "git_graph_ahead_behind", instance_pos = 2.1)]
public Error count_ahead_behind(out size_t ahead, out size_t behind, object_id local, object_id upstream);
/**
* Write an in-memory buffer to the ODB as a blob
*
* @param id return the id of the written blob
* @param buffer data to be written into the blob
*/
[CCode(cname = "git_blob_create_frombuffer", instance_pos = 1.2)]
public Error create_blob_from_buffer(object_id id, [CCode(array_length_type = "size_t")] uint8[] buffer);
/**
* Write a loose blob to the Object Database from a provider of chunks of
* data.
*
* @param id Return the id of the written blob
* @param hint_path will help to determine what git filters should be
* applied to the object before it can be placed to the object database.
*/
[CCode(cname = "git_blob_create_fromchunks", instance_pos = 1.2)]
public Error create_blob_from_chunks(object_id id, string? hint_path, ChunkSource source);
/**
* Read a file from the filesystem and write its content to the Object
* Database as a loose blob
*
* @param id return the id of the written blob
* @param path file from which the blob will be created
*/
[CCode(cname = "git_blob_create_fromdisk", instance_pos = 1.2)]
public Error create_blob_from_disk(out object_id id, string path);
/**
* Read a file from the working folder of a repository
* and write it to the object database as a loose blob
*
* This repository cannot be bare.
*
* @param id return the id of the written blob
* @param path file from which the blob will be created, relative to the repository's working dir
*/
[CCode(cname = "git_blob_create_fromworkdir", instance_pos = 1.2)]
public Error create_blob_from_file(object_id id, string path);
/**
* Create a new branch pointing at a target commit
*
* A new direct reference will be created pointing to this target commit.
* If forced and a reference already exists with the given name, it'll be
* replaced.
*
* @param branch_name Name for the branch; this name is
* validated for consistency. It should also not conflict with
* an already existing branch name.
*
* @param target Object to which this branch should point. This object must
* belong to the given repository and can either be a commit or a tag. When
* a tag is being passed, it should be dereferencable to a commit which oid
* will be used as the target of the branch.
*
* @param force Overwrite existing branch.
*/
[CCode(cname = "git_branch_create", instance_pos = 1.2)]
public Error create_branch(out Reference? branch, string branch_name, Commit target, bool force = false);
/**
* Create a new commit in the repository using {@link Object}
* instances as parameters.
*
* The message will not be cleaned up.
*
* @param id the id of the newly created commit
*
* @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.
* @param author Signature representing the author and the author time of this commit
* @param committer Signature representing the committer and the commit time of this commit
* @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.
* @param message Full message for this commit
* @param tree The tree that will be used as the tree for the commit. This tree object must also be owned by this repository.
* @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.
* @see prettify_message
*/
[CCode(cname = "git_commit_create", instance_pos = 1.2)]
public Error create_commit(object_id id, string? update_ref, Signature author, Signature committer, string? message_encoding, string message, Tree tree, [CCode(array_length_pos = 7.8)] Commit[] parents);
/**
* Create a new commit in the repository using a variable argument list.
*
* The parents for the commit are specified as a variable arguments. Note
* that this is a convenience method which may not be safe to export for
* certain languages or compilers
*
* The message will be cleaned up from excess whitespace it will be made
* sure that the last line ends with a new line.
*
* All other parameters remain the same.
*
* @see create_commit
*/
[CCode(cname = "git_commit_create_v", instance_pos = 1.2)]
public Error create_commit_v(object_id id, string update_ref, Signature author, Signature committer, string message_encoding, string message, Tree tree, int parent_count, ...);
/**
* Create a new lightweight tag pointing at a target object
*
* A new direct reference will be created pointing to this target object.
* If //force// is true and a reference already exists with the given name,
* it'll be replaced.
*
* The message will be cleaned up from excess whitespace
* it will be made sure that the last line ends with a new line.
*
* @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.
*
* @param tag_name Name for the tag; this name is validated for consistency. It should also not conflict with an already existing tag name.
*
* @param target Object to which this tag points. This object must belong to this repository.
*
* @param force Overwrite existing references
*
* @return on success, a proper reference is written in the ///refs/tags// folder, pointing to the provided target object
* @see create_tag
*/
[CCode(cname = "git_tag_create_lightweight", instance_pos = 1.2)]
public Error create_lightweight_tag(object_id id, string tag_name, Object target, bool force);
/**
* Add a note for an object
*
* @param note_id the object id of the note crated
* @param author signature of the notes commit author
* @param committer signature of the notes commit committer
* @param notes_ref ID reference to update (optional); defaults to "refs/notes/commits"
* @param id The ID of the object
* @param note The note to add for the object
* @param force Overwrite existing note
*/
[CCode(cname = "git_note_create", instance_pos = 1.2)]
public Error create_note(out object_id note_id, Signature author, Signature committer, string? notes_ref, object_id id, string note, bool force = false);
/**
* Creates a new iterator for notes.
*
* @param notes_ref canonical name of the reference to use (optional);
* defaults to "refs/notes/commits"
*/
[CCode(cname = "git_note_iterator_new", instance_pos = 1.1)]
public Error create_note_iterator(out NoteIterator? iterator, string? notes_ref = null);
/**
* Initialize a new packbuilder
*
* @param pack_builder The new packbuilder object
*/
[CCode(cname = "git_packbuilder_new", instance_pos = -1)]
public Error create_pack_builder(out PackBuilder? pack_builder);
/**
* Create a new reference database with no backends.
*
* Before the Ref DB can be used for read/writing, a custom database
* backend must be manually set using {@link RefDb.set_backend}.
*/
[CCode(cname = "git_refdb_new", instance_pos = -1)]
public Error create_refdb(out RefDb? refdb);
/**
* Create a new object id reference.
*
* The reference will be created in the repository and written to the disk.
*
* @param reference the newly created reference
* @param name The name of the reference
* @param id The object id pointed to by the reference.
* @param force Overwrite existing references
*/
[CCode(cname = "git_reference_create", instance_pos = 1.2)]
public Error create_reference(out unowned Reference reference, string name, object_id id, bool force);
/**
* Add a remote with the default fetch refspec to the repository's configuration.
*
* This calls {@link Remote.save} before returning.
*
* @param remote the resulting remote
* @param name the remote's name
* @param url the remote's url
*/
[CCode(cname = "git_remote_create", instance_pos = 1.2)]
public Error create_remote(out Remote? remote, string name, string url);
/**
* Create a remote with the given refspec in memory.
*
* You can use this when you have a URL instead of a remote's name. Note
* that in-memory remotes cannot be converted to persisted remotes.
*
* @param remote the newly created remote reference
* @param fetch the fetch refspec to use for this remote; null for defaults
* @param url the remote repository's URL
*/
[CCode(cname = "git_remote_create_inmemory", instance_pos = 1.2)]
public Error create_remote_in_memory(out Remote? remote, string? fetch, string url);
/**
* Create a new symbolic reference.
*
* The reference will be created in the repository and written to the disk.
*
* @param reference the newly created reference
* @param name The name of the reference
* @param target The target of the reference
* @param force Overwrite existing references
*/
[CCode(cname = "git_reference_symbolic_create", instance_pos = 1.2)]
public Error create_symbolic_reference(out unowned Reference reference, string name, string target, bool force);
/**
* Create a new tag in the repository from an object
*
* A new reference will also be created pointing to this tag object. If
* //force// is true and a reference already exists with the given name,
* it'll be replaced.
*
* The tag name will be checked for validity. You must avoid the characters
* ~, ^, :, \, ?, [, and *, and the sequences '''..''' and '''@{''' which
* have special meaning to revparse.
*
* @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.
* @param tag_name Name for the tag; this name is validated for consistency. It should also not conflict with an already existing tag name.
* @param target Object to which this tag points. This object must belong to this repository.
* @param tagger Signature of the tagger for this tag, and of the tagging time
* @param message Full message for this tag
* @param force Overwrite existing references
* @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
*/
[CCode(cname = "git_tag_create", instance_pos = 1.2)]
public Error create_tag(object_id id, string tag_name, Object target, Signature tagger, string message, bool force);
/**
* Create a new tag in the repository from a buffer
*
* @param id Pointer where to store the id of the newly created tag
* @param buffer Raw tag data
* @param force Overwrite existing tags
* @see create_tag
*/
[CCode(cname = "git_tag_create_frombuffer", instance_pos = 1.2)]
public Error create_tag_from_buffer(object_id id, string buffer, bool force);
/**
* Delete an existing tag reference.
*
* @param tag_name Name of the tag to be deleted; this name is validated for consistency.
*/
[CCode(cname = "git_tag_delete")]
public Error delete_tag(string tag_name);
/**
* Detach the HEAD.
*
* If the HEAD is already detached and points to a commit, the call is successful.
*
* If the HEAD is already detached and points to a tag, the HEAD is updated
* into making it point to the peeled commit, and the call is successful.
*
* If the HEAD is already detached and points to a non commitish, the HEAD
* is unaletered, and an error is returned.
*
* Otherwise, the HEAD will be detached and point to the peeled commit.
*/
[CCode(cname = "git_repository_detach_head")]
public Error detach_head();
/**
* Compute a difference between two tree objects.
*
* @param diff The diff that will be allocated.
* @param old_tree A tree to diff from.
* @param new_tree A tree to diff to.
* @param opts Structure with options to influence diff or null for defaults.
*/
[CCode(cname = "git_diff_tree_to_tree", instance_pos = 1.1)]
public Error diff_tree_to_tree(out DiffList? diff, Tree old_tree, Tree new_tree, diff_options? opts = null);
/**
* Compute a difference between a tree and the index.
*
* @param diff The diff that will be allocated.
* @param old_tree A tree object to diff from.
* @param opts Structure with options to influence diff or null for defaults.
*/
[CCode(cname = "git_diff_tree_to_index", instance_pos = 1.1)]
public Error diff_tree_to_index(out DiffList? diff, Tree old_tree, diff_options? opts = null);
/**
* Compute a difference between the working directory and the index.
*
* @param diff A pointer to a git_diff_list pointer that will be allocated.
* @param opts Structure with options to influence diff or null for defaults.
*/
[CCode(cname = "git_diff_index_to_workdir", instance_pos = 1.1)]
public Error diff_index_to_workdir(out DiffList? diff, diff_options? opts = null);
/**
* Compute a difference between the working directory and a tree.
*
* Please note: this is //not// the same as '''git diff //treeish//'''.
* Running '''git diff HEAD''' or the like actually uses information from
* the index, along with the tree and working directory info.
*
* This function returns strictly the differences between the tree and the
* The tree you provide will be used for the {@link diff_delta.old_file}
* side of the delta, and the working directory will be used for the
* {@link diff_delta.new_file} side.
*
* Files contained in the working directory, regardless of the state of
* files in the index. It may come as a surprise, but there is no direct
* equivalent in core git.
*
* This is //not// the same as '''git diff HEAD''' or '''git diff <SHA>'''.
* Those commands diff the tree, the index, and the workdir. To emulate
* those functions, call {@link diff_tree_to_index} and
* {@link diff_index_to_workdir}, then call {@link DiffList.merge} on the
* results.
*
* If this seems confusing, take the case of a file with a staged deletion
* where the file has then been put back into the working dir and modified.
* The tree-to-workdir diff for that file is 'modified', but core git would
* show status 'deleted' since there is a pending deletion in the index.
*
* @param old_tree A tree to diff from.
* @param opts Structure with options to influence diff or NULL for defaults.
*/
[CCode(cname = "git_diff_workdir_to_tree", instance_pos = 1.1)]
public Error diff_tree_to_workdir(out DiffList? diff, Tree old_tree, diff_options? opts = null);
/**
* Remove a single stashed state from the stash list.
* @param index The position within the stash list. 0 points to the
* most recent stashed state.
*/
[CCode(cname = "git_stash_drop")]
public Error drop_stash(size_t index);
/**
* Iterate over each entry in the FETCH_HEAD file.
*/
[CCode(cname = "git_repository_fetchhead_foreach")]
public Error for_each_fetchhead(FetchHeadForEach fetch_head_for_each);
/**
* If a merge is in progress, iterate over each commit ID in the MERGE_HEAD
* file.
*/
[CCode(cname = "git_repository_mergehead_foreach")]
public Error for_each_merge_head(MergeHeadForEach merge_head_for_each);
/**
* Perform an operation on each reference in the repository
*
* The processed references may be filtered by type, or using a bitwise OR
* of several types. Use the magic value {@link ReferenceType.LISTALL} to
* obtain all references, including packed ones.
*
* @param list_flags Filtering flags for the reference listing.
* @param reference_for_each Function which will be called for every listed ref
*/
[CCode(cname = "git_reference_foreach")]
public Error for_each_reference(ReferenceType list_flags, ReferenceForEach reference_for_each);
/**
* Loop over all the references and issue a callback for each one which
* name matches the given glob pattern.
*
* @param list_flags Filtering flags for the reference listing.
* @param reference_for_each to invoke per found reference.
*/
[CCode(cname = "git_reference_foreach_glob")]
public Error for_each_reference_glob(string glob, ReferenceType list_flags, ReferenceForEach reference_for_each);
/**
* Iterate over all submodules of a repository.
*/
[CCode(cname = "git_submodule_foreach")]
public Error for_each_submodule(SubmoduleForEach submodule_for_each);
/**
* Iterate over each tag in the repository.
*/
[CCode(cname = "git_tag_foreach")]
public Error for_each_tag(TagForEach tag_for_each);
/**
* Find a merge base between two commits
*
* @param merge_base the OID of a merge base between 'one' and 'two'
* @param one one of the commits
* @param two the other commit
*/
[CCode(cname = "git_merge_base", instance_pos = 1.2)]
public Error find_merge_base(out object_id merge_base, object_id one, object_id two);
/**
* Find a merge base given a list of commits
*
* @param id the ID of a merge base considering all the commits
* @param input ids of the commits
*/
[CCode(cname = "git_merge_base_many", instance_pos = 1.1)]
public Error find_merge_base_many(out object_id id, [CCode(array_length_type = "size_t")]object_id[] input);
/**
* Loop over all the notes within a specified namespace.
* @param notes_ref OID reference to read from (optional); defaults to "refs/notes/commits".
*/
[CCode(cname = "git_note_foreach")]
public Error for_each_note(string? notes_ref, NoteForEach note_for_each);
/**
* Loop over all the stashed states.
*
* The most recent stash state will be enumerated first.
*/
[CCode(cname = "git_stash_foreach")]
public Error for_each_stash(StashForEach stash_for_each);
/**
* Gather file statuses and run a callback for each one.
*
* The callback is passed the path of the file, the status and the data
* pointer passed to this function. If the callback returns something other
* than {@link Error.OK}, this function will return that value.
*
* @param status_for_each the function to call on each file
* @return {@link Error.OK} or the return value of the callback
*/
[CCode(cname = "git_status_foreach")]
public Error for_each_status(StatusForEach status_for_each);
/**
* Gather file status information and run callbacks as requested.
*/
[CCode(cname = "git_status_foreach_ext")]
public Error for_each_status_ext(status_options opts, StatusForEach status_for_each);
/**
* Get the configuration file for this repository.
*
* If a configuration file has not been set, the default
* config set for the repository will be returned, including
* global and system configurations (if they are available).
*
* @param config the repository's configuration
*/
[CCode(cname = "git_repository_config", instance_pos = -1)]
public Error get_config(out Config config);
/**
* Get the Object Database for this repository.
*
* If a custom ODB has not been set, the default database for the
* repository will be returned (the one located in //.git/objects//).
*/
[CCode(cname = "git_repository_odb", instance_pos = -1)]
public Error get_db(out Database.Handle db);
/**
* Get file status for a single file
*
* @param status the status value
* @param path the file to retrieve status for, rooted at the repo's workdir
* @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
*/
[CCode(cname = "git_status_file", instance_pos = 1.2)]
public Error get_file_status(out Status status, string path);
/**
* Retrieve and resolve the reference pointed at by HEAD.
*
* @param head the reference which will be retrieved
*/
[CCode(cname = "git_repository_head", instance_pos = -1)]
public Error get_head(out Reference head);
/**
* Get the index file for this repository.
*
* If a custom index has not been set, the default
* index for the repository will be returned (the one
* located in //.git/index//).
*
* If a custom index has not been set, the default
* index for the repository will be returned (the one
* located in //.git/index//).
*
*/
[CCode(cname = "git_repository_index", instance_pos = -1)]
public void get_index(out Index index);
/**
* Get the information for a particular remote
*
* The name will be checked for validity.
* @param remote the new remote object
* @param name the remote's name
* @see create_tag
*/
[CCode(cname = "git_remote_load", instance_pos = 1.2)]
public Error get_remote(out Remote remote, string name);
/**
* Return the name of remote that the remote tracking branch belongs to.
*
* @param remote_name The buffer which will be filled with the name of the
* remote. Pass null if you just want to get the needed size of the name of
* the remote as the output value.
*
* @param canonical_branch_name name of the remote tracking branch.
*
* @return Number of characters in the reference name including the
* trailing NUL byte; {@link Error.NOTFOUND} when no remote matching remote
* was found, {@link Error.AMBIGUOUS} when the branch maps to several
* remotes, otherwise an error code.
*/
[CCode(cname = "git_branch_remote_name", insance_pos = 1.2)]
public int get_branch_remote_name([CCode(array_length_type = "size_t")] uint8[]? remote_name, string canonical_branch_name);
/**
* Get the Reference Database Backend for this repository.
*
* If a custom refsdb has not been set, the default database for the
* repository will be returned (the one that manipulates loose and packed
* references in the '''.git''' directory).
*/
[CCode(cname = "git_repository_refdb", instance_pos = -1)]
public Error get_refdb(out RefDb? refdb);
/**
* Get a list of the configured remotes for a repo
*
* @param remotes_list a string array with the names of the remotes
*/
[CCode(cname = "git_remote_list", instance_pos = -1)]
public Error get_remote_list(out string_array remotes_list);
/**
* Fill a list with all the tags in the Repository
*
* @param tag_names where the tag names will be stored
*/
[CCode(cname = "git_tag_list", instance_pos = -1)]
public Error get_tag_list(string_array tag_names);
/**
* Fill a list with all the tags in the Repository which name match a
* defined pattern
*
* If an empty pattern is provided, all the tags will be returned.
*
* @param tag_names the tag names will be stored
* @param pattern standard shell-like (fnmatch) pattern
*/
[CCode(cname = "git_tag_list_match", instance_pos = -1)]
public Error get_tag_list_match(out string_array tag_names, string pattern);
/**
* Return the name of the reference supporting the remote tracking branch,
* given the name of a local branch reference.
*
* @param tracking_branch_name The buffer which will be filled with the
* name of the reference, or null if you just want to get the needed size
* of the name of the reference as the output value.
*
* @param canonical_branch_name name of the local branch.
*
* @return number of characters in the reference name including the
* trailing NUL byte; otherwise an error code.
*/
[CCode(cname = "git_branch_tracking_name", instance_pos = 1.3)]
public int get_tracking_branch_name([CCode(array_length_type = "size_t")] char[]? tracking_branch_name, string canonical_branch_name);
/**
* Allocate a new revision walker to iterate through a repo.
*
* This revision walker uses a custom memory pool and an internal commit
* cache, so it is relatively expensive to allocate.
*
* For maximum performance, this revision walker should be reused for
* different walks.
*
* This revision walker is ''not'' thread safe: it may only be used to walk
* a repository on a single thread; however, it is possible to have several
* revision walkers in several different threads walking the same
* repository.
*
* @param walker the new revision walker
*/
[CCode(cname = "git_revwalk_new", instance_pos = -1)]
public Error get_walker(out RevisionWalker walker);
/**
* Calculate hash of file using repository filtering rules.
*
* If you simply want to calculate the hash of a file on disk with no filters,
* you can just use the {@link object_id.hashfile} API. However, if you
* want to hash a file in the repository and you want to apply filtering
* rules (e.g. crlf filters) before generating the SHA, then use this
* function.
*
* @param path Path to file on disk whose contents should be hashed. This can be a relative path.
* @param type The object type to hash
* @param as_path The path to use to look up filtering rules. If this is
* null, then the path parameter will be used instead. If this is passed as
* the empty string, then no filters will be applied when calculating the
* hash.
*/
[CCode(cname = "git_repository_hashfile", instance_pos = 1.1)]
public Error hashfile(out object_id id, string path, ObjectType type, string? as_path = null);
/**
* Iterate over the branches in the repository.
*
* @param list_flags Filtering flags for the branch listing.
*/
[CCode(cname = "git_branch_foreach")]
public Error for_each_branch(BranchType list_flags, Branch branch);
/**
* Test if the ignore rules apply to a given path.
*
* This function checks the ignore rules to see if they would apply to the
* given file. This indicates if the file would be ignored regardless of
* whether the file is already in the index or commited to the repository.
*
* One way to think of this is if you were to do '''git add .''' on the
* directory containing the file, would it be added or not?
*
* @param path the file to check ignores for, relative to the repo's
* workdir.
*/
[CCode(cname = "git_ignore_path_is_ignored", instance_pos = 1.1)]
public Error is_path_ignored(out bool ignored, string path);
[CCode(cname = "git_branch_foreach", instance_pos = 1.2)]
public Error list_branches(out string_array branch_names, BranchType list_flags);
/**
* Fill a list with all the references that can be found
* in a repository.
*
* The listed references may be filtered by type, or using
* a bitwise OR of several types. Use the magic value
* {@link ReferenceType.LISTALL} to obtain all references, including
* packed ones.
*
* @param array where the reference names will be stored
* @param list_flags Filtering flags for the reference listing.
*/
[CCode(cname = "git_reference_listall", instance_pos = 1.2)]
public Error list_all(out string_array array, ReferenceType list_flags);
/**
* Convert a tree entry to the object it points too.
*
* @param object pointer to the converted object
* @param entry a tree entry
*/
[CCode(cname = "git_tree_entry_to_object", instance_pos = 1.2)]
public Error load(out Object object, TreeEntry entry);
/**
* Lookup a blob object from a repository.
*
* @param blob the looked up blob
* @param id identity of the blob to locate.
*/
[CCode(cname = "git_blob_lookup", instance_pos = 1.2)]
public Error lookup_blob(out Blob blob, object_id id);
/**
* Lookup a blob object from a repository, given a prefix of its identifier
* (short id).
*
* @see lookup_object_by_prefix
*
* @param blob the looked up blob
* @param id identity of the blob to locate.
* @param len the length of the short identifier
*/
[CCode(cname = "git_blob_lookup_prefix", instance_pos = 1.2)]
public Error lookup_blob_by_prefix(out Blob blob, object_id id, size_t len);
/**
* Lookup a branch by its name.
*
* @param branch_name Name of the branch to be looked-up; this name is
* validated for consistency.
*/
[CCode(cname = "git_branch_lookup", instance_pos = 1.1)]
public Error lookup_branch(out Reference? branch, string branch_name, BranchType branch_type);
/**
* Lookup a commit object from a repository.
*
* @param commit the looked up commit
* @param id identity of the commit to locate. If the object is an annotated tag it will be peeled back to the commit.
*/
[CCode(cname = "git_commit_lookup", instance_pos = 1.2)]
public Error lookup_commit(out Commit commit, object_id id);
/**
* Lookup a commit object from a repository, given a prefix of its
* identifier (short id).
*
* @see lookup_object_by_prefix
*
* @param commit the looked up commit
* @param id identity of the commit to locate. If the object is an annotated tag it will be peeled back to the commit.
* @param len the length of the short identifier
*/
[CCode(cname = "git_commit_lookup_prefix", instance_pos = 1.2)]
public Error lookup_commit_by_prefix(out Commit commit, object_id id, size_t len);
/**
* Lookup a reference to one of the objects in a repostory.
*
* The //type// parameter must match the type of the object in the ODB; the
* method will fail otherwise. The special value {@link ObjectType.ANY}
* may be passed to let the method guess the object's type.
*
* @param object the looked-up object
* @param id the unique identifier for the object
* @param type the type of the object
* @return a reference to the object
*/
[CCode(cname = "git_object_lookup", instance_pos = 1.2)]
public Error lookup_object(out Object object, object_id id, ObjectType type);
/**
* Lookup a reference to one of the objects in a repostory, given a prefix
* of its identifier (short id).
*
* The object obtained will be so that its identifier matches the first
* //len// hexadecimal characters (packets of 4 bits) of the given //id//.
* //len// must be at least {@link object_id.MIN_PREFIX_LENGTH}, and long
* enough to identify a unique object matching the prefix; otherwise the
* method will fail.
*
* The //type// parameter must match the type of the object in the ODB; the
* method will fail otherwise. The special value {@link ObjectType.ANY}
* may be passed to let the method guess the object's type.
*
* @param object where to store the looked-up object
* @param id a short identifier for the object
* @param len the length of the short identifier
* @param type the type of the object
*/
[CCode(cname = "git_object_lookup_prefix", instance_pos = 1.2)]
public Error lookup_object_by_prefix(out Object object, object_id id, size_t len, ObjectType type);
/**
* Lookup a reference by its name in a repository.
*
* @param reference the looked-up reference
* @param name the long name for the reference (e.g., HEAD, ref/heads/master, refs/tags/v0.1.0, ...)
*/
[CCode(cname = "git_reference_lookup", instance_pos = 1.2)]
public Error lookup_reference(out Reference reference, string name);
/**
* Lookup a reference by name and resolve immediately to an ID.
*
* @param name The long name for the reference
*/
[CCode(cname = "git_reference_name_to_id", instance_pos = 1.2)]
public Error lookup_reference_to_id(out object_id id, string name);
/**
* Lookup submodule information by name or path.
*
* Given either the submodule name or path (they are ususally the same),
* this returns a structure describing the submodule.
*
* @param name The name of the submodule. Trailing slashes will be ignored.
*/
[CCode(cname = "git_submodule_lookup", instance_pos = 1.2)]
public Error lookup_submodule(out unowned Submodule? submodule, string name);
/**
* Lookup a tag object from the repository.
*
* @param tag pointer to the looked up tag
* @param id identity of the tag to locate.
*/
[CCode(cname = "git_tag_lookup", instance_pos = 1.2)]
public Error lookup_tag(out Tag tag, object_id id);
/**
* Lookup a tag object from the repository, given a prefix of its
* identifier (short id).
*
* @see lookup_object_by_prefix
*
* @param tag pointer to the looked up tag
* @param id identity of the tag to locate.
* @param len the length of the short identifier
*/
[CCode(cname = "git_tag_lookup_prefix", instance_pos = 1.2)]
public Error prefix_lookup_tag(out Tag tag, object_id id, uint len);
/**
* Lookup a tree object from the repository.
*
* @param tree the looked up tree
* @param id identity of the tree to locate.
*/
[CCode(cname = "git_tree_lookup", instance_pos = 1.2)]
public Error lookup_tree(out Tree tree, object_id id);
/**
* Lookup a tree object from the repository, given a prefix of its
* identifier (short id).
*
* @see lookup_object_by_prefix
*
* @param tree the looked up tree
* @param id identity of the tree to locate.
* @param len the length of the short identifier
*/
[CCode(cname = "git_tree_lookup_prefix", instance_pos = 1.2)]
public Error lookup_tree_by_prefix(out Tree tree, object_id id, uint len);
/**
* Create a new reference database and automatically add
* the default backends:
*
* - git_refdb_dir: read and write loose and packed refs from disk,
* assuming the repository dir as the folder
*/
[CCode(cname = "git_refdb_open", instance_pos = -1)]
public Error open_refdb(out RefDb? refdb);
/**
* Find an object, as specified by a revision string. See the gitrevisions
* manual page, or the documentation for '''git rev-parse''' for
* information on the syntax accepted.
*
* @param spec the textual specification for an object
*/
[CCode(cname = "git_revparse_single", instance_pos = 1.1)]
public Error parse(out Object? obj, string spec);
/**
* Read the note for an object
* @param notes_ref ID reference to use (optional); defaults to "refs/notes/commits"
* @param id ID of the object
*/
[CCode(cname = "git_note_read", instance_pos = 1.2)]
public Error read_note(out Note? note, string? notes_ref, object_id id);
/**
* Get the default notes reference for a repository
*/
[CCode(cname = "git_note_default_ref", instance_pos = -1)]
public Error read_note_default_ref(out unowned string note);
/**
* Reread all submodule info.
*
* Call this to reload all cached submodule information for the repo.
*/
[CCode(cname = "git_submodule_reload_all")]
public Error reload_submodules();
/**
* Remove the note for an object
*
* @param notes_ref ID reference to use (optional); defaults to "refs/notes/commits"
* @param author signature of the notes commit author
* @param committer signature of the notes commit committer
* @param id the id which note's to be removed
*/
[CCode(cname = "git_note_remove")]
public Error remove_note(string? notes_ref, Signature author, Signature committer, object_id id);
/**
* Sets the current head to the specified commit oid and optionally resets
* the index and working tree to match.
*
* When specifying a Soft kind of reset, the head will be moved to the commit.
*
* Specifying a Mixed kind of reset will trigger a Soft reset and the index
* will be replaced with the content of the commit tree.
*
* @param target Object to which the Head should be moved to. This object
* must belong to this repository and can either be a {@link Commit} or a
* {@link Tag}. When a {@link Tag} is being passed, it should be
* dereferencable to a {@link Commit} which oid will be used as the target
* of the branch.
* @param reset_type Kind of reset operation to perform.
*/
[CCode(cname = "git_reset")]
public Error reset(Object target, ResetType reset_type);
/**
* Updates some entries in the index from the target commit tree.
*
* The scope of the updated entries is determined by the paths
* specified.
*
* @param target The committish which content will be used to reset the
* content of the index. Passing null will result in removing entries in
* the index matching the provided pathspecs.
*
* @param pathspecs List of pathspecs to operate on.
*/
[CCode(cname = "git_reset_default")]
public Error reset_default(Object? target, string_array pathspecs);
/**
* Save the local modifications to a new stash.
*
* @param id id of the commit containing the stashed state. This commit is
* also the target of the direct reference refs/stash.
* @param stasher The identity of the person performing the stashing.
* @param message description along with the stashed state.
*/
[CCode(cname = "git_stash_save", instance_pos = 1.1)]
public Error save_stash(out object_id id, Signature stasher, string? message = null, StashFlag flags = StashFlag.DEFAULT);
/**
* Set the configuration file for this repository
*
* This configuration file will be used for all configuration
* queries involving this repository.
*/
[CCode(cname = "git_repository_set_config")]
public void set_config(Config config);
/**
* Set the Object Database for this repository
*
* The ODB will be used for all object-related operations involving this
* repository.
*/
[CCode(cname = "git_repository_set_odb")]
public void set_db(Database.Handle db);
/**
* Make the repository HEAD point to the specified reference.