...
 
Commits (4)
......@@ -7,8 +7,7 @@
module libgit2_d.annotated_commit;
private static import libgit2_d.common;
private static import libgit2_d.repository;
private static import libgit2_d.oid;
private static import libgit2_d.types;
/**
......@@ -20,6 +19,7 @@ private static import libgit2_d.types;
*/
extern (C):
nothrow @nogc:
public:
/**
* Creates a `git_annotated_commit` from the given reference.
......@@ -94,6 +94,15 @@ int git_annotated_commit_from_revspec(libgit2_d.types.git_annotated_commit** out
//GIT_EXTERN
const (libgit2_d.oid.git_oid)* git_annotated_commit_id(const (libgit2_d.types.git_annotated_commit)* commit);
/**
* Get the refname that the given `git_annotated_commit` refers to.
*
* @param commit the given annotated commit
* @return ref name.
*/
//GIT_EXTERN
const (char)* git_annotated_commit_ref(const (libgit2_d.types.git_annotated_commit)* commit);
/**
* Frees a `git_annotated_commit`.
*
......
/*
* Copyright (C) the libgit2 contributors. All rights reserved.
*
* This file is part of libgit2, distributed under the GNU GPL v2 with
* a Linking Exception. For full terms see the included COPYING file.
*/
module libgit2_d.apply;
private static import libgit2_d.diff;
private static import libgit2_d.types;
/**
* @file git2/apply.h
* @brief Git patch application routines
* @defgroup git_apply Git patch application routines
* @ingroup Git
* @{
*/
extern (C):
nothrow @nogc:
public:
/**
* When applying a patch, callback that will be made per delta (file).
*
* When the callback:
* - returns < 0, the apply process will be aborted.
* - returns > 0, the delta will not be applied, but the apply process
* continues
* - returns 0, the delta is applied, and the apply process continues.
*
* @param delta The delta to be applied
* @param payload User-specified payload
*/
alias git_apply_delta_cb = int function(const (libgit2_d.diff.git_diff_delta)* delta, void* payload);
/**
* When applying a patch, callback that will be made per hunk.
*
* When the callback:
* - returns < 0, the apply process will be aborted.
* - returns > 0, the hunk will not be applied, but the apply process
* continues
* - returns 0, the hunk is applied, and the apply process continues.
*
* @param hunk The hunk to be applied
* @param payload User-specified payload
*/
alias git_apply_hunk_cb = int function(const (libgit2_d.diff.git_diff_hunk)* hunk, void* payload);
/**
* Flags controlling the behavior of git_apply
*/
enum git_apply_flags_t
{
/**
* Don't actually make changes, just test that the patch applies.
* This is the equivalent of `git apply --check`.
*/
GIT_APPLY_CHECK = 1 << 0,
}
/**
* Apply options structure
*
* Initialize with `GIT_APPLY_OPTIONS_INIT`. Alternatively, you can
* use `git_apply_options_init`.
*
* @see git_apply_to_tree, git_apply
*/
struct git_apply_options
{
/**
* The version
*/
uint version_;
/**
* When applying a patch, callback that will be made per delta (file).
*/
.git_apply_delta_cb delta_cb;
/**
* When applying a patch, callback that will be made per hunk.
*/
.git_apply_hunk_cb hunk_cb;
/**
* Payload passed to both delta_cb & hunk_cb.
*/
void* payload;
/**
* Bitmask of git_apply_flags_t
*/
uint flags;
}
enum GIT_APPLY_OPTIONS_VERSION = 1;
pragma(inline, true)
pure nothrow @safe @nogc
.git_apply_options GIT_APPLY_OPTIONS_INIT()
do
{
.git_apply_options OUTPUT =
{
version_: .GIT_APPLY_OPTIONS_VERSION,
};
return OUTPUT;
}
//GIT_EXTERN
int git_apply_options_init(.git_apply_options* opts, uint version_);
/**
* Apply a `git_diff` to a `git_tree`, and return the resulting image
* as an index.
*
* @param out_ the postimage of the application
* @param repo the repository to apply
* @param preimage the tree to apply the diff to
* @param diff the diff to apply
* @param options the options for the apply (or null for defaults)
*/
//GIT_EXTERN
int git_apply_to_tree(libgit2_d.types.git_index** out_, libgit2_d.types.git_repository* repo, libgit2_d.types.git_tree* preimage, libgit2_d.diff.git_diff* diff, const (.git_apply_options)* options);
/**
* Possible application locations for git_apply
*/
enum git_apply_location_t
{
/**
* Apply the patch to the workdir, leaving the index untouched.
* This is the equivalent of `git apply` with no location argument.
*/
GIT_APPLY_LOCATION_WORKDIR = 0,
/**
* Apply the patch to the index, leaving the working directory
* untouched. This is the equivalent of `git apply --cached`.
*/
GIT_APPLY_LOCATION_INDEX = 1,
/**
* Apply the patch to both the working directory and the index.
* This is the equivalent of `git apply --index`.
*/
GIT_APPLY_LOCATION_BOTH = 2,
}
/**
* Apply a `git_diff` to the given repository, making changes directly
* in the working directory, the index, or both.
*
* @param repo the repository to apply to
* @param diff the diff to apply
* @param location the location to apply (workdir, index or both)
* @param options the options for the apply (or null for defaults)
*/
//GIT_EXTERN
int git_apply(libgit2_d.types.git_repository* repo, libgit2_d.diff.git_diff* diff, .git_apply_location_t location, const (.git_apply_options)* options);
/** @} */
......@@ -7,7 +7,6 @@
module libgit2_d.attr;
private static import libgit2_d.common;
private static import libgit2_d.types;
/**
......@@ -19,6 +18,7 @@ private static import libgit2_d.types;
*/
extern (C):
nothrow @nogc:
public:
//Linker error
version (none) {
......@@ -35,11 +35,11 @@ version (none) {
*/
pragma(inline, true)
nothrow @nogc
bool GIT_ATTR_TRUE(const (char)* attr)
bool GIT_ATTR_IS_TRUE(const (char)* attr)
do
{
return .git_attr_value(attr) == .git_attr_t.GIT_ATTR_TRUE_T;
return .git_attr_value(attr) == .git_attr_t.GIT_ATTR_VALUE_TRUE;
}
/**
......@@ -56,11 +56,11 @@ version (none) {
*/
pragma(inline, true)
nothrow @nogc
bool GIT_ATTR_FALSE(const (char)* attr)
bool GIT_ATTR_IS_FALSE(const (char)* attr)
do
{
return .git_attr_value(attr) == .git_attr_t.GIT_ATTR_FALSE_T;
return .git_attr_value(attr) == .git_attr_t.GIT_ATTR_VALUE_FALSE;
}
/**
......@@ -81,11 +81,11 @@ version (none) {
*/
pragma(inline, true)
nothrow @nogc
bool GIT_ATTR_UNSPECIFIED(const (char)* attr)
bool GIT_ATTR_IS_UNSPECIFIED(const (char)* attr)
do
{
return .git_attr_value(attr) == .git_attr_t.GIT_ATTR_UNSPECIFIED_T;
return .git_attr_value(attr) == .git_attr_t.GIT_ATTR_VALUE_UNSPECIFIED;
}
/**
......@@ -104,26 +104,26 @@ version (none) {
do
{
return .git_attr_value(attr) == .git_attr_t.GIT_ATTR_VALUE_T;
return .git_attr_value(attr) == .git_attr_t.GIT_ATTR_VALUE_STRING;
}
}
/**
* Possible states for an attribute
*/
enum git_attr_t
enum git_attr_value_t
{
/**< The attribute has been left unspecified */
GIT_ATTR_UNSPECIFIED_T = 0,
GIT_ATTR_VALUE_UNSPECIFIED = 0,
/**< The attribute has been set */
GIT_ATTR_TRUE_T,
GIT_ATTR_VALUE_TRUE,
/**< The attribute has been unset */
GIT_ATTR_FALSE_T,
GIT_ATTR_VALUE_FALSE,
/**< This attribute has a value */
GIT_ATTR_VALUE_T,
GIT_ATTR_VALUE_STRING,
}
/**
......@@ -140,7 +140,7 @@ enum git_attr_t
* @return the value type for the attribute
*/
//GIT_EXTERN
.git_attr_t git_attr_value(const (char)* attr);
.git_attr_value_t git_attr_value(const (char)* attr);
/**
* Check attribute flags: Reading values from index and working directory.
......@@ -160,13 +160,20 @@ enum GIT_ATTR_CHECK_INDEX_THEN_FILE = 1;
enum GIT_ATTR_CHECK_INDEX_ONLY = 2;
/**
* Check attribute flags: Using the system attributes file.
* Check attribute flags: controlling extended attribute behavior.
*
* Normally, attribute checks include looking in the /etc (or system
* equivalent) directory for a `gitattributes` file. Passing this
* flag will cause attribute checks to ignore that file.
* equivalent) directory for a `gitattributes` file. Passing the
* `GIT_ATTR_CHECK_NO_SYSTEM` flag will cause attribute checks to
* ignore that file.
*
* Passing the `GIT_ATTR_CHECK_INCLUDE_HEAD` flag will use attributes
* from a `.gitattributes` file in the repository at the HEAD revision.
*/
enum GIT_ATTR_CHECK_NO_SYSTEM = 1 << 2;
enum GIT_ATTR_CHECK_INCLUDE_HEAD = 1 << 3;
/**
* Look up the value of one git attribute for path.
......@@ -218,6 +225,22 @@ int git_attr_get(const (char)** value_out, libgit2_d.types.git_repository* repo,
//GIT_EXTERN
int git_attr_get_many(const (char)** values_out, libgit2_d.types.git_repository* repo, uint flags, const (char)* path, size_t num_attr, const (char)** names);
/**
* The callback used with git_attr_foreach.
*
* This callback 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.
*
* @see git_attr_foreach.
*
* @param name The attribute name.
* @param value The attribute value. May be NULL if the attribute is explicitly
* set to UNSPECIFIED using the '!' sign.
* @param payload A user-specified pointer.
* @return 0 to continue looping, non-zero to stop. This value will be returned
* from git_attr_foreach.
*/
alias git_attr_foreach_cb = int function(const (char)* name, const (char)* value, void* payload);
/**
......@@ -228,13 +251,8 @@ alias git_attr_foreach_cb = int function(const (char)* name, const (char)* value
* @param path 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 callback Function to invoke on each attribute name and value. The
* value may be null is the attribute is explicitly set to
* UNSPECIFIED using the '!' sign. Callback 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. Return a non-zero value from this to stop looping.
* The value will be returned from `git_attr_foreach`.
* @param callback Function to invoke on each attribute name and value.
* See git_attr_foreach_cb.
* @param payload Passed on as extra parameter to callback function.
* @return 0 on success, non-zero callback return value, or error code
*/
......
......@@ -7,8 +7,8 @@
module libgit2_d.blame;
private static import libgit2_d.common;
private static import libgit2_d.oid;
private static import libgit2_d.types;
/**
* @file git2/blame.h
......@@ -54,39 +54,60 @@ enum git_blame_flag_t
* first parents.
*/
GIT_BLAME_FIRST_PARENT = (1 << 4),
/**
* Use mailmap file to map author and committer names and email addresses
* to canonical real names and email addresses. The mailmap will be read
* from the working directory, or HEAD in a bare repository.
*/
GIT_BLAME_USE_MAILMAP = (1 << 5),
}
/**
* Blame options structure
*
* Use zeros to indicate default settings. It's easiest to use the
* `GIT_BLAME_OPTIONS_INIT` macro:
* git_blame_options opts = GIT_BLAME_OPTIONS_INIT;
*
* - `flags` is a combination of the `git_blame_flag_t` values above.
* - `min_match_characters` is the lower bound on the number of alphanumeric
* characters that must be detected as moving/copying within a file for it to
* associate those lines with the parent commit. The default value is 20.
* This value only takes effect if any of the `GIT_BLAME_TRACK_COPIES_*`
* flags are specified.
* - `newest_commit` is the id of the newest commit to consider. The default
* is HEAD.
* - `oldest_commit` is the id of the oldest commit to consider. The default
* is the first commit encountered with a null parent.
* - `min_line` is the first line in the file to blame. The default is 1
*(line numbers start with 1).
* - `max_line` is the last line in the file to blame. The default is the
*last line of the file.
* Initialize with `GIT_BLAME_OPTIONS_INIT`. Alternatively, you can
* use `git_blame_options_init`.
*/
struct git_blame_options
{
uint version_;
/**
* A combination of `git_blame_flag_t`
*/
uint flags;
/**
* The lower bound on the number of alphanumeric
* characters that must be detected as moving/copying within a file for it to
* associate those lines with the parent commit. The default value is 20.
* This value only takes effect if any of the `GIT_BLAME_TRACK_COPIES_*`
* flags are specified.
*/
ushort min_match_characters;
/**
* The id of the newest commit to consider. The default is HEAD.
*/
libgit2_d.oid.git_oid newest_commit;
/**
* The id of the oldest commit to consider.
* The default is the first commit encountered with a NULL parent.
*/
libgit2_d.oid.git_oid oldest_commit;
/**
* The first line in the file to blame.
* The default is 1 (line numbers start with 1).
*/
size_t min_line;
/**
* The last line in the file to blame.
* The default is the last line of the file.
*/
size_t max_line;
}
......@@ -107,15 +128,17 @@ pure nothrow @safe @nogc
}
/**
* Initializes a `git_blame_options` with default values. Equivalent to
* creating an instance with GIT_BLAME_OPTIONS_INIT.
* Initialize git_blame_options structure
*
* @param opts The `git_blame_options` struct to initialize
* @param version Version of struct; pass `GIT_BLAME_OPTIONS_VERSION`
* Initializes a `git_blame_options` with default values. Equivalent to creating
* an instance with GIT_BLAME_OPTIONS_INIT.
*
* @param opts The `git_blame_options` struct to initialize.
* @param version The struct version; pass `GIT_BLAME_OPTIONS_VERSION`.
* @return Zero on success; -1 on failure.
*/
//GIT_EXTERN
int git_blame_init_options(.git_blame_options* opts, uint version_);
int git_blame_options_init(.git_blame_options* opts, uint version_);
/**
* Structure that represents a blame hunk.
......@@ -125,14 +148,20 @@ int git_blame_init_options(.git_blame_options* opts, uint version_);
* changed.
* - `final_start_line_number` is the 1-based line number where this hunk
* begins, in the final version of the file
* - `final_signature` is the author of `final_commit_id`. If
* `git_blame_flag_t.GIT_BLAME_USE_MAILMAP` has been specified, it will contain the canonical
* real name and email address.
* - `orig_commit_id` is the OID of the commit where this hunk was found. This
* will usually be the same as `final_commit_id`, except when
* `GIT_BLAME_TRACK_COPIES_ANY_COMMIT_COPIES` has been specified.
* `git_blame_flag_t.GIT_BLAME_TRACK_COPIES_ANY_COMMIT_COPIES` has been specified.
* - `orig_path` is the path to the file where this hunk originated, as of the
* commit specified by `orig_commit_id`.
* - `orig_start_line_number` is the 1-based line number where this hunk begins
* in the file named by `orig_path` in the commit specified by
* `orig_commit_id`.
* - `orig_signature` is the author of `orig_commit_id`. If
* `git_blame_flag_t.GIT_BLAME_USE_MAILMAP` has been specified, it will contain the canonical
* real name and email address.
* - `boundary` is 1 iff the hunk has been tracked to a boundary commit (the
* root, or the commit specified in git_blame_options.oldest_commit)
*/
......@@ -149,10 +178,12 @@ struct git_blame_hunk
size_t orig_start_line_number;
libgit2_d.types.git_signature* orig_signature;
char boundary;
char boundary = '\0';
}
/* Opaque structure to hold blame results */
/**
* Opaque structure to hold blame results
*/
struct git_blame;
/**
......@@ -189,7 +220,7 @@ const (.git_blame_hunk)* git_blame_get_hunk_byline(.git_blame* blame, size_t lin
* @param path path to file to consider
* @param options options for the blame operation. If null, this is treated as
* though GIT_BLAME_OPTIONS_INIT were passed.
* @return 0 on success, or an error code. (use giterr_last for information
* @return 0 on success, or an error code. (use git_error_last for information
* about the error.)
*/
//GIT_EXTERN
......@@ -209,7 +240,7 @@ int git_blame_file(.git_blame** out_, libgit2_d.types.git_repository* repo, cons
* output from git_blame_file)
* @param buffer the (possibly) modified contents of the file
* @param buffer_len number of valid bytes in the buffer
* @return 0 on success, or an error code. (use giterr_last for information
* @return 0 on success, or an error code. (use git_error_last for information
* about the error)
*/
//GIT_EXTERN
......
......@@ -8,8 +8,6 @@ module libgit2_d.blob;
private static import libgit2_d.buffer;
private static import libgit2_d.common;
private static import libgit2_d.object;
private static import libgit2_d.oid;
private static import libgit2_d.types;
......@@ -22,6 +20,7 @@ private static import libgit2_d.types;
*/
extern (C):
nothrow @nogc:
public:
/**
* Lookup a blob object from a repository.
......@@ -104,6 +103,59 @@ const (void)* git_blob_rawcontent(const (libgit2_d.types.git_blob)* blob);
//GIT_EXTERN
libgit2_d.types.git_off_t git_blob_rawsize(const (libgit2_d.types.git_blob)* blob);
/**
* Flags to control the functionality of `git_blob_filter`.
*/
enum git_blob_filter_flag_t
{
/**
* When set, filters will not be applied to binary files.
*/
GIT_BLOB_FILTER_CHECK_FOR_BINARY = 1 << 0,
/**
* When set, filters will not load configuration from the
* system-wide `gitattributes` in `/etc` (or system equivalent).
*/
GIT_BLOB_FILTER_NO_SYSTEM_ATTRIBUTES = 1 << 1,
/**
* When set, filters will be loaded from a `.gitattributes` file
* in the HEAD commit.
*/
GIT_BLOB_FILTER_ATTTRIBUTES_FROM_HEAD = 1 << 2,
}
/**
* The options used when applying filter options to a file.
*/
struct git_blob_filter_options
{
int version_;
/**
* Flags to control the filtering process, see `git_blob_filter_flag_t` above
*/
uint flags;
}
enum GIT_BLOB_FILTER_OPTIONS_VERSION = 1;
pragma(inline, true)
pure nothrow @safe @nogc
.git_blob_filter_options GIT_BLOB_FILTER_OPTIONS_INIT()
do
{
.git_blob_filter_options OUTPUT =
{
version_: .GIT_BLOB_FILTER_OPTIONS_VERSION,
flags: .git_blob_filter_flag_t.GIT_BLOB_FILTER_CHECK_FOR_BINARY,
};
return OUTPUT;
}
/**
* Get a buffer with the filtered content of a blob.
*
......@@ -113,22 +165,21 @@ libgit2_d.types.git_off_t git_blob_rawsize(const (libgit2_d.types.git_blob)* blo
* attributes set for the blob and the content detected in it.
*
* The output is written into a `git_buf` which the caller must free
* when done (via `git_buf_free`).
* when done (via `git_buf_dispose`).
*
* If no filters need to be applied, then the `out` buffer will just
* be populated with a pointer to the raw content of the blob. In
* that case, be careful to *not* free the blob until done with the
* buffer or copy it into memory you own.
*
* @param out_ The git_buf to be filled in
* @param out The git_buf to be filled in
* @param blob Pointer to the blob
* @param as_path Path used for file attribute lookups, etc.
* @param check_for_binary_data Should this test if blob content contains
* NUL bytes / looks like binary data before applying filters?
* @param opts Options to use for filtering the blob
* @return 0 on success or an error code
*/
//GIT_EXTERN
int git_blob_filtered_content(libgit2_d.buffer.git_buf* out_, libgit2_d.types.git_blob* blob, const (char)* as_path, int check_for_binary_data);
int git_blob_filter(libgit2_d.buffer.git_buf* out_, libgit2_d.types.git_blob* blob, const (char)* as_path, .git_blob_filter_options* opts);
/**
* Read a file from the working folder of a repository
......@@ -142,7 +193,7 @@ int git_blob_filtered_content(libgit2_d.buffer.git_buf* out_, libgit2_d.types.gi
* @return 0 or an error code
*/
//GIT_EXTERN
int git_blob_create_fromworkdir(libgit2_d.oid.git_oid* id, libgit2_d.types.git_repository* repo, const (char)* relative_path);
int git_blob_create_from_workdir(libgit2_d.oid.git_oid* id, libgit2_d.types.git_repository* repo, const (char)* relative_path);
/**
* Read a file from the filesystem and write its content
......@@ -155,7 +206,7 @@ int git_blob_create_fromworkdir(libgit2_d.oid.git_oid* id, libgit2_d.types.git_r
* @return 0 or an error code
*/
//GIT_EXTERN
int git_blob_create_fromdisk(libgit2_d.oid.git_oid* id, libgit2_d.types.git_repository* repo, const (char)* path);
int git_blob_create_from_disk(libgit2_d.oid.git_oid* id, libgit2_d.types.git_repository* repo, const (char)* path);
/**
* Create a stream to write a new blob into the object db
......@@ -163,27 +214,27 @@ int git_blob_create_fromdisk(libgit2_d.oid.git_oid* id, libgit2_d.types.git_repo
* This function may need to buffer the data on disk and will in
* general not be the right choice if you know the size of the data
* to write. If you have data in memory, use
* `git_blob_create_frombuffer()`. If you do not, but know the size of
* `git_blob_create_from_buffer()`. If you do not, but know the size of
* the contents (and don't want/need to perform filtering), use
* `git_odb_open_wstream()`.
*
* Don't close this stream yourself but pass it to
* `git_blob_create_fromstream_commit()` to commit the write to the
* `git_blob_create_from_stream_commit()` to commit the write to the
* object db and get the object id.
*
* If the `hintpath` parameter is filled, it will be used to determine
* what git filters should be applied to the object before it is written
* to the object database.
*
* @param out_ the stream into which to write
* @param out the stream into which to write
* @param repo Repository where the blob will be written.
* This repository can be bare or not.
* @param hintpath If not null, will be used to select data filters
* @param hintpath If not NULL, will be used to select data filters
* to apply onto the content of the blob to be created.
* @return 0 or error code
*/
//GIT_EXTERN
int git_blob_create_fromstream(libgit2_d.types.git_writestream** out_, libgit2_d.types.git_repository* repo, const (char)* hintpath);
int git_blob_create_from_stream(libgit2_d.types.git_writestream** out_, libgit2_d.types.git_repository* repo, const (char)* hintpath);
/**
* Close the stream and write the blob to the object db
......@@ -195,7 +246,7 @@ int git_blob_create_fromstream(libgit2_d.types.git_writestream** out_, libgit2_d
* @return 0 or an error code
*/
//GIT_EXTERN
int git_blob_create_fromstream_commit(libgit2_d.oid.git_oid* out_, libgit2_d.types.git_writestream* stream);
int git_blob_create_from_stream_commit(libgit2_d.oid.git_oid* out_, libgit2_d.types.git_writestream* stream);
/**
* Write an in-memory buffer to the ODB as a blob
......@@ -207,7 +258,7 @@ int git_blob_create_fromstream_commit(libgit2_d.oid.git_oid* out_, libgit2_d.typ
* @return 0 or an error code
*/
//GIT_EXTERN
int git_blob_create_frombuffer(libgit2_d.oid.git_oid* id, libgit2_d.types.git_repository* repo, const (void)* buffer, size_t len);
int git_blob_create_from_buffer(libgit2_d.oid.git_oid* id, libgit2_d.types.git_repository* repo, const (void)* buffer, size_t len);
/**
* Determine if the blob content is most certainly binary or not.
......
......@@ -7,8 +7,7 @@
module libgit2_d.branch;
private static import libgit2_d.common;
private static import libgit2_d.oid;
private static import libgit2_d.buffer;
private static import libgit2_d.types;
/**
......@@ -20,6 +19,7 @@ private static import libgit2_d.types;
*/
extern (C):
nothrow @nogc:
public:
/**
* Create a new branch pointing at a target commit
......@@ -44,7 +44,7 @@ nothrow @nogc:
*
* @param force Overwrite existing branch.
*
* @return 0, GIT_EINVALIDSPEC or an error code.
* @return 0, git_error_code.GIT_EINVALIDSPEC or an error code.
* A proper reference is written in the refs/heads namespace
* pointing to the provided target commit.
*/
......@@ -87,8 +87,8 @@ struct git_branch_iterator;
* @param out_ the iterator
* @param repo Repository where to find the branches.
* @param list_flags Filtering flags for the branch
* listing. Valid values are GIT_BRANCH_LOCAL, GIT_BRANCH_REMOTE
* or GIT_BRANCH_ALL.
* listing. Valid values are git_branch_t.GIT_BRANCH_LOCAL, git_branch_t.GIT_BRANCH_REMOTE
* or git_branch_t.GIT_BRANCH_ALL.
*
* @return 0 on success or an error code
*/
......@@ -101,7 +101,7 @@ int git_branch_iterator_new(.git_branch_iterator** out_, libgit2_d.types.git_rep
* @param out_ the reference
* @param out_type the type of branch (local or remote-tracking)
* @param iter the branch iterator
* @return 0 on success, GIT_ITEROVER if there are no more branches or an error
* @return 0 on success, git_error_code.GIT_ITEROVER if there are no more branches or an error
* code.
*/
//GIT_EXTERN
......@@ -128,7 +128,7 @@ void git_branch_iterator_free(.git_branch_iterator* iter);
*
* @param force Overwrite existing branch.
*
* @return 0 on success, GIT_EINVALIDSPEC or an error code.
* @return 0 on success, git_error_code.GIT_EINVALIDSPEC or an error code.
*/
//GIT_EXTERN
int git_branch_move(libgit2_d.types.git_reference** out_, libgit2_d.types.git_reference* branch, const (char)* new_branch_name, int force);
......@@ -149,10 +149,10 @@ int git_branch_move(libgit2_d.types.git_reference** out_, libgit2_d.types.git_re
* this name is validated for consistency.
*
* @param branch_type Type of the considered branch. This should
* be valued with either GIT_BRANCH_LOCAL or GIT_BRANCH_REMOTE.
* be valued with either git_branch_t.GIT_BRANCH_LOCAL or git_branch_t.GIT_BRANCH_REMOTE.
*
* @return 0 on success; GIT_ENOTFOUND when no matching branch
* exists, GIT_EINVALIDSPEC, otherwise an error code.
* @return 0 on success; git_error_code.GIT_ENOTFOUND when no matching branch
* exists, git_error_code.GIT_EINVALIDSPEC, otherwise an error code.
*/
//GIT_EXTERN
int git_branch_lookup(libgit2_d.types.git_reference** out_, libgit2_d.types.git_repository* repo, const (char)* branch_name, libgit2_d.types.git_branch_t branch_type);
......@@ -184,7 +184,7 @@ int git_branch_name(const (char)** out_, const (libgit2_d.types.git_reference)*
*
* @param branch Current underlying reference of the branch.
*
* @return 0 on success; GIT_ENOTFOUND when no remote tracking
* @return 0 on success; git_error_code.GIT_ENOTFOUND when no remote tracking
* reference exists, otherwise an error code.
*/
//GIT_EXTERN
......@@ -214,7 +214,7 @@ int git_branch_set_upstream(libgit2_d.types.git_reference* branch, const (char)*
*
* @param refname reference name of the local branch.
*
* @return 0, GIT_ENOTFOUND when no remote tracking reference exists,
* @return 0, git_error_code.GIT_ENOTFOUND when no remote tracking reference exists,
* otherwise an error code.
*/
//GIT_EXTERN
......@@ -253,16 +253,16 @@ int git_branch_is_checked_out(const (libgit2_d.types.git_reference)* branch);
*
* @param canonical_branch_name name of the remote tracking branch.
*
* @return 0, GIT_ENOTFOUND
* @return 0, git_error_code.GIT_ENOTFOUND
* when no remote matching remote was found,
* GIT_EAMBIGUOUS when the branch maps to several remotes,
* git_error_code.GIT_EAMBIGUOUS when the branch maps to several remotes,
* otherwise an error code.
*/
//GIT_EXTERN
int git_branch_remote_name(libgit2_d.buffer.git_buf* out_, libgit2_d.types.git_repository* repo, const (char)* canonical_branch_name);
/**
* Retrieve the name fo the upstream remote of a local branch
* Retrieve the name of the upstream remote of a local branch
*
* @param buf the buffer into which to write the name
* @param repo the repository in which to look
......
......@@ -7,8 +7,6 @@
module libgit2_d.buffer;
private static import libgit2_d.common;
/**
* @file git2/buffer.h
* @brief Buffer export structure
......@@ -18,6 +16,7 @@ private static import libgit2_d.common;
*/
extern (C):
nothrow @nogc:
public:
/**
* A data buffer for exporting data from libgit2
......@@ -26,34 +25,39 @@ nothrow @nogc:
* caller and have the caller take responsibility for freeing that memory.
* This can be awkward if the caller does not have easy access to the same
* allocation functions that libgit2 is using. In those cases, libgit2
* will fill in a `git_buf` and the caller can use `git_buf_free()` to
* will fill in a `git_buf` and the caller can use `git_buf_dispose()` to
* release it when they are done.
*
* A `git_buf` may also be used for the caller to pass in a reference to
* a block of memory they hold. In this case, libgit2 will not resize or
* free the memory, but will read from it as needed.
*
* A `git_buf` is a public structure with three fields:
*
* - `ptr` points to the start of the allocated memory. If it is null,
* then the `git_buf` is considered empty and libgit2 will feel free
* to overwrite it with new data.
*
* - `size` holds the size (in bytes) of the data that is actually used.
*
* - `asize` holds the known total amount of allocated memory if the `ptr`
* was allocated by libgit2. It may be larger than `size`. If `ptr`
* was not allocated by libgit2 and should not be resized and/or freed,
* then `asize` will be set to zero.
*
* Some APIs may occasionally do something slightly unusual with a buffer,
* such as setting `ptr` to a value that was passed in by the user. In
* such as setting `ptr_` to a value that was passed in by the user. In
* those cases, the behavior will be clearly documented by the API.
*/
struct git_buf
{
char* ptr;
/**
* The buffer contents.
*
* `ptr_` points to the start of the allocated memory. If it is NULL,
* then the `git_buf` is considered empty and libgit2 will feel free
* to overwrite it with new data.
*/
char* ptr_;
/**
* `asize` holds the known total amount of allocated memory if the `ptr_`
* was allocated by libgit2. It may be larger than `size`. If `ptr_`
* was not allocated by libgit2 and should not be resized and/or freed,
* then `asize` will be set to zero.
*/
size_t asize;
/**
* `size` holds the size (in bytes) of the data that is actually used.
*/
size_t size;
}
......@@ -68,7 +72,7 @@ pure nothrow @safe @nogc
{
.git_buf OUTPUT =
{
ptr: STR,
ptr_: STR,
asize: 0,
size: LEN,
};
......@@ -80,14 +84,14 @@ pure nothrow @safe @nogc
* Free the memory referred to by the git_buf.
*
* Note that this does not free the `git_buf` itself, just the memory
* pointed to by `buffer->ptr`. This will not free the memory if it looks
* pointed to by `buffer->ptr_`. This will not free the memory if it looks
* like it was not allocated internally, but it will clear the buffer back
* to the empty state.
*
* @param buffer The buffer to deallocate
*/
//GIT_EXTERN
void git_buf_free(.git_buf* buffer);
void git_buf_dispose(.git_buf* buffer);
/**
* Resize the buffer allocation to make more space.
......@@ -95,7 +99,7 @@ void git_buf_free(.git_buf* buffer);
* This will attempt to grow the buffer to accommodate the target size.
*
* If the buffer refers to memory that was not allocated by libgit2 (i.e.
* the `asize` field is zero), then `ptr` will be replaced with a newly
* the `asize` field is zero), then `ptr_` will be replaced with a newly
* allocated block of data. Be careful so that memory allocated by the
* caller is not lost. As a special variant, if you pass `target_size` as
* 0 and the memory is not allocated by libgit2, this will allocate a new
......
/*
* Copyright (C) the libgit2 contributors. All rights reserved.
*
* This file is part of libgit2, distributed under the GNU GPL v2 with
* a Linking Exception. For full terms see the included COPYING file.
*/
module libgit2_d.cert;
/**
* @file git2/cert.h
* @brief Git certificate objects
* @defgroup git_cert Certificate objects
* @ingroup Git
* @{
*/
extern (C):
nothrow @nogc:
public:
/**
* Type of host certificate structure that is passed to the check callback
*/
enum git_cert_t
{
/**
* No information about the certificate is available. This may
* happen when using curl.
*/
GIT_CERT_NONE,
/**
* The `data` argument to the callback will be a pointer to
* the DER-encoded data.
*/
GIT_CERT_X509,
/**
* The `data` argument to the callback will be a pointer to a
* `git_cert_hostkey` structure.
*/
GIT_CERT_HOSTKEY_LIBSSH2,
/**
* The `data` argument to the callback will be a pointer to a
* `git_strarray` with `name:content` strings containing
* information about the certificate. This is used when using
* curl.
*/
GIT_CERT_STRARRAY,
}
/**
* Parent type for `git_cert_hostkey` and `git_cert_x509`.
*/
struct git_cert
{
/**
* Type of certificate. A `GIT_CERT_` value.
*/
.git_cert_t cert_type;
}
/**
* Callback for the user's custom certificate checks.
*
* @param cert The host certificate
* @param valid Whether the libgit2 checks (OpenSSL or WinHTTP) think
* this certificate is valid
* @param host Hostname of the host libgit2 connected to
* @param payload Payload provided by the caller
* @return 0 to proceed with the connection, < 0 to fail the connection
* or > 0 to indicate that the callback refused to act and that
* the existing validity determination should be honored
*/
alias git_transport_certificate_check_cb = int function(.git_cert* cert, int valid, const (char)* host, void* payload);
/**
* Type of SSH host fingerprint
*/
enum git_cert_ssh_t
{
/**
* MD5 is available
*/
GIT_CERT_SSH_MD5 = 1 << 0,
/**
* SHA-1 is available
*/
GIT_CERT_SSH_SHA1 = 1 << 1,
}
/**
* Hostkey information taken from libssh2
*/
struct git_cert_hostkey
{
/**
* The parent cert
*/
.git_cert parent;
/**
* A hostkey type from libssh2, either
* `git_cert_ssh_t.GIT_CERT_SSH_MD5` or `git_cert_ssh_t.GIT_CERT_SSH_SHA1`
*/
.git_cert_ssh_t type;
/**
* Hostkey hash. If type has `git_cert_ssh_t.GIT_CERT_SSH_MD5` set, this will
* have the MD5 hash of the hostkey.
*/
ubyte[16] hash_md5;
/**
* Hostkey hash. If type has `git_cert_ssh_t.GIT_CERT_SSH_SHA1` set, this will
* have the SHA-1 hash of the hostkey.
*/
ubyte[20] hash_sha1;
}
/**
* X.509 certificate information
*/
struct git_cert_x509
{
/**
* The parent cert
*/
.git_cert parent;
/**
* Pointer to the X.509 certificate data
*/
void* data;
/**
* Length of the memory block pointed to by `data`.
*/
size_t len;
}
/** @} */
......@@ -7,8 +7,8 @@
module libgit2_d.checkout;
private static import libgit2_d.common;
private static import libgit2_d.diff;
private static import libgit2_d.strarray;
private static import libgit2_d.types;
/**
......@@ -20,6 +20,7 @@ private static import libgit2_d.types;
*/
extern (C):
nothrow @nogc:
public:
/**
* Checkout behavior flags
......@@ -68,7 +69,7 @@ nothrow @nogc:
* To emulate `git checkout -f`, use `GIT_CHECKOUT_FORCE`.
*
*
* There are some additional flags to modified the behavior of checkout:
* There are some additional flags to modify the behavior of checkout:
*
* - GIT_CHECKOUT_ALLOW_CONFLICTS makes SAFE mode apply safe file updates
* even if there are conflicts (instead of cancelling the checkout).
......@@ -109,10 +110,22 @@ enum git_checkout_strategy_t
/**< default is a dry run, no actual updates */
GIT_CHECKOUT_NONE = 0,
/** Allow safe updates that cannot overwrite uncommitted data */
/**
* Allow safe updates that cannot overwrite uncommitted data.
* If the uncommitted changes don't conflict with the checked out files,
* the checkout will still proceed, leaving the changes intact.
*
* Mutually exclusive with GIT_CHECKOUT_FORCE.
* GIT_CHECKOUT_FORCE takes precedence over GIT_CHECKOUT_SAFE.
*/
GIT_CHECKOUT_SAFE = (1u << 0),
/** Allow all updates to force working directory to look like index */
/**
* Allow all updates to force working directory to look like index.
*
* Mutually exclusive with GIT_CHECKOUT_SAFE.
* GIT_CHECKOUT_FORCE takes precedence over GIT_CHECKOUT_SAFE.
*/
GIT_CHECKOUT_FORCE = (1u << 1),
/** Allow checkout to recreate missing files */
......@@ -218,6 +231,9 @@ enum git_checkout_notify_t
GIT_CHECKOUT_NOTIFY_ALL = 0x0FFFFu,
}
/**
* Checkout performance-reporting structure
*/
struct git_checkout_perfdata
{
size_t mkdir_calls;
......@@ -237,16 +253,15 @@ alias git_checkout_perfdata_cb = void function(const (.git_checkout_perfdata)* p
/**
* Checkout options structure
*
* Zero out for defaults. Initialize with `GIT_CHECKOUT_OPTIONS_INIT` macro to
* correctly set the `version` field. E.g.
*
* git_checkout_options opts = GIT_CHECKOUT_OPTIONS_INIT;
* Initialize with `GIT_CHECKOUT_OPTIONS_INIT`. Alternatively, you can
* use `git_checkout_options_init`.
*/
struct git_checkout_options
{
/**< The version */
uint version_;
/**< default will be a dry run */
/**< default will be a safe checkout */
uint checkout_strategy;
/**< don't apply filters like CRLF conversion */
......@@ -263,37 +278,50 @@ struct git_checkout_options
/**< see `git_checkout_notify_t` above */
uint notify_flags;
/**
* Optional callback to get notifications on specific file states.
* @see git_checkout_notify_t
*/
.git_checkout_notify_cb notify_cb;
/**
* Payload passed to notify_cb
*/
void* notify_payload;
/** Optional callback to notify the consumer of checkout progress. */
.git_checkout_progress_cb progress_cb;
/**
* Payload passed to progress_cb
*/
void* progress_payload;
/**
* When not zeroed out, array of fnmatch patterns specifying which
* paths should be taken into account, otherwise all files. Use
* GIT_CHECKOUT_DISABLE_PATHSPEC_MATCH to treat as simple list.
* A list of wildmatch patterns or paths.
*
* By default, all paths are processed. If you pass an array of wildmatch
* patterns, those will be used to filter which paths should be taken into
* account.
*
* Use git_checkout_strategy_t.GIT_CHECKOUT_DISABLE_PATHSPEC_MATCH to treat as a simple list.
*/
libgit2_d.strarray.git_strarray paths;
/**
* The expected content of the working directory; defaults to HEAD.
* If the working directory does not match this baseline information,
* that will produce a checkout conflict.
*
* If the working directory does not match this baseline information,
* that will produce a checkout conflict.
*/
libgit2_d.types.git_tree* baseline;
/**
* Like `baseline` above, though expressed as an index. This
* option overrides `baseline`.
*/
/**
* < expected content of workdir, expressed as an
* index.
* option overrides `baseline`.
*/
libgit2_d.types.git_index* baseline_index;
/**< alternative checkout path to workdir */
const (char)* target_directory;
......@@ -309,6 +337,10 @@ struct git_checkout_options
/** Optional callback to notify the consumer of performance data. */
.git_checkout_perfdata_cb perfdata_cb;
/**
* Payload passed to perfdata_cb
*/
void* perfdata_payload;
}
......@@ -323,21 +355,24 @@ pure nothrow @safe @nogc
.git_checkout_options OUTPUT =
{
version_: .GIT_CHECKOUT_OPTIONS_VERSION,
checkout_strategy: .git_checkout_strategy_t.GIT_CHECKOUT_SAFE,
};
return OUTPUT;
}
/**
* Initializes a `git_checkout_options` with default values. Equivalent to
* creating an instance with GIT_CHECKOUT_OPTIONS_INIT.
* Initialize git_checkout_options structure
*
* Initializes a `git_checkout_options` with default values. Equivalent to creating
* an instance with GIT_CHECKOUT_OPTIONS_INIT.
*
* @param opts the `git_checkout_options` struct to initialize.
* @param version_ Version of struct; pass `GIT_CHECKOUT_OPTIONS_VERSION`
* @param opts The `git_checkout_options` struct to initialize.
* @param version The struct version; pass `GIT_CHECKOUT_OPTIONS_VERSION`.
* @return Zero on success; -1 on failure.
*/
//GIT_EXTERN
int git_checkout_init_options(.git_checkout_options* opts, uint version_);
int git_checkout_options_init(.git_checkout_options* opts, uint version_);
/**
* Updates files in the index and the working tree to match the content of
......@@ -352,9 +387,9 @@ int git_checkout_init_options(.git_checkout_options* opts, uint version_);
*
* @param repo repository to check out (must be non-bare)
* @param opts specifies checkout options (may be null)
* @return 0 on success, GIT_EUNBORNBRANCH if HEAD points to a non
* @return 0 on success, git_error_code.GIT_EUNBORNBRANCH if HEAD points to a non
* existing branch, non-zero value returned by `notify_cb`, or
* other error code < 0 (use giterr_last for error details)
* other error code < 0 (use git_error_last for error details)
*/
//GIT_EXTERN
int git_checkout_head(libgit2_d.types.git_repository* repo, const (.git_checkout_options)* opts);
......@@ -366,7 +401,7 @@ int git_checkout_head(libgit2_d.types.git_repository* repo, const (.git_checkout
* @param index index to be checked out (or null to use repository index)
* @param opts specifies checkout options (may be null)
* @return 0 on success, non-zero return value from `notify_cb`, or error
* code < 0 (use giterr_last for error details)
* code < 0 (use git_error_last for error details)
*/
//GIT_EXTERN
int git_checkout_index(libgit2_d.types.git_repository* repo, libgit2_d.types.git_index* index, const (.git_checkout_options)* opts);
......@@ -380,7 +415,7 @@ int git_checkout_index(libgit2_d.types.git_repository* repo, libgit2_d.types.git
* the working directory (or null to use HEAD)
* @param opts specifies checkout options (may be null)
* @return 0 on success, non-zero return value from `notify_cb`, or error
* code < 0 (use giterr_last for error details)
* code < 0 (use git_error_last for error details)
*/
//GIT_EXTERN
int git_checkout_tree(libgit2_d.types.git_repository* repo, const (libgit2_d.types.git_object)* treeish, const (.git_checkout_options)* opts);
......
......@@ -7,10 +7,9 @@
module libgit2_d.cherrypick;
private static import libgit2_d.common;
private static import libgit2_d.checkout;
private static import libgit2_d.merge;
private static import libgit2_d.types;
private static import libgit2_d.checkout;
/**
* @file git2/cherrypick.h
......@@ -21,6 +20,7 @@ private static import libgit2_d.checkout;
*/
extern (C):
nothrow @nogc:
public:
/**
* Cherry-pick options
......@@ -59,15 +59,17 @@ pure nothrow @safe @nogc
}
/**
* Initializes a `git_cherrypick_options` with default values. Equivalent to
* creating an instance with GIT_CHERRYPICK_OPTIONS_INIT.
* Initialize git_cherrypick_options structure
*
* Initializes a `git_cherrypick_options` with default values. Equivalent to creating
* an instance with GIT_CHERRYPICK_OPTIONS_INIT.
*
* @param opts the `git_cherrypick_options` struct to initialize
* @param version_ Version of struct; pass `GIT_CHERRYPICK_OPTIONS_VERSION`
* @param opts The `git_cherrypick_options` struct to initialize.
* @param version The struct version; pass `GIT_CHERRYPICK_OPTIONS_VERSION`.
* @return Zero on success; -1 on failure.
*/
//GIT_EXTERN
int git_cherrypick_init_options(.git_cherrypick_options* opts, uint version_);
int git_cherrypick_options_init(.git_cherrypick_options* opts, uint version_);
/**
* Cherry-picks the given commit against the given "our" commit, producing an
......
......@@ -8,10 +8,7 @@ module libgit2_d.clone;
private static import libgit2_d.checkout;
private static import libgit2_d.common;
private static import libgit2_d.indexer;
private static import libgit2_d.remote;
private static import libgit2_d.transport;
private static import libgit2_d.types;
/**
......@@ -23,6 +20,7 @@ private static import libgit2_d.types;
*/
extern (C):
nothrow @nogc:
public:
/**
* Options for bypassing the git-aware transport on clone. Bypassing
......@@ -66,7 +64,7 @@ enum git_clone_local_t
* @param name the remote's name
* @param url the remote's url
* @param payload an opaque payload
* @return 0, GIT_EINVALIDSPEC, GIT_EEXISTS or an error code
* @return 0, git_error_code.GIT_EINVALIDSPEC, git_error_code.GIT_EEXISTS or an error code
*/
alias git_remote_create_cb = int function(libgit2_d.types.git_remote** out_, libgit2_d.types.git_repository* repo, const (char)* name, const (char)* url, void* payload);
......@@ -90,9 +88,8 @@ alias git_repository_create_cb = int function(libgit2_d.types.git_repository** o
/**
* Clone options structure
*
* Use the GIT_CLONE_OPTIONS_INIT to get the default settings, like this:
*
* git_clone_options opts = GIT_CLONE_OPTIONS_INIT;
* Initialize with `GIT_CLONE_OPTIONS_INIT`. Alternatively, you can
* use `git_clone_options_init`.
*/
struct git_clone_options
{
......@@ -101,7 +98,7 @@ struct git_clone_options
/**
* These options are passed to the checkout step. To disable
* checkout, set the `checkout_strategy` to
* `GIT_CHECKOUT_NONE`.
* `git_checkout_strategy_t.GIT_CHECKOUT_NONE`.
*/
libgit2_d.checkout.git_checkout_options checkout_opts;
......@@ -183,15 +180,17 @@ pure nothrow @safe @nogc
}
/**
* Initializes a `git_clone_options` with default values. Equivalent to
* creating an instance with GIT_CLONE_OPTIONS_INIT.
* Initialize git_clone_options structure
*
* Initializes a `git_clone_options` with default values. Equivalent to creating
* an instance with GIT_CLONE_OPTIONS_INIT.
*
* @param opts The `git_clone_options` struct to initialize
* @param version_ Version of struct; pass `GIT_CLONE_OPTIONS_VERSION`
* @param opts The `git_clone_options` struct to initialize.
* @param version The struct version; pass `GIT_CLONE_OPTIONS_VERSION`.
* @return Zero on success; -1 on failure.
*/
//GIT_EXTERN
int git_clone_init_options(.git_clone_options* opts, uint version_);
int git_clone_options_init(.git_clone_options* opts, uint version_);
/**
* Clone a remote repository.
......@@ -207,7 +206,7 @@ int git_clone_init_options(.git_clone_options* opts, uint version_);
* function works as though GIT_OPTIONS_INIT were passed.
* @return 0 on success, any non-zero return value from a callback
* function, or a negative value to indicate an error (use
* `giterr_last` for a detailed error message)
* `git_error_last` for a detailed error message)
*/
//GIT_EXTERN
int git_clone(libgit2_d.types.git_repository** out_, const (char)* url, const (char)* local_path, const (.git_clone_options)* options);
......
......@@ -7,8 +7,7 @@
module libgit2_d.commit;
private static import libgit2_d.common;
private static import libgit2_d.object;
private static import libgit2_d.buffer;
private static import libgit2_d.oid;
private static import libgit2_d.types;
......@@ -21,6 +20,7 @@ private static import libgit2_d.types;
*/
extern (C):
nothrow @nogc:
public:
/**
* Lookup a commit object from a repository.
......@@ -186,6 +186,34 @@ const (libgit2_d.types.git_signature)* git_commit_committer(const (libgit2_d.typ
//GIT_EXTERN
const (libgit2_d.types.git_signature)* git_commit_author(const (libgit2_d.types.git_commit)* commit);
/**
* Get the committer of a commit, using the mailmap to map names and email
* addresses to canonical real names and email addresses.
*
* Call `git_signature_free` to free the signature.
*
* @param out a pointer to store the resolved signature.
* @param commit a previously loaded commit.
* @param mailmap the mailmap to resolve with. (may be NULL)
* @return 0 or an error code
*/
//GIT_EXTERN
int git_commit_committer_with_mailmap(libgit2_d.types.git_signature** out_, const (libgit2_d.types.git_commit)* commit, const (libgit2_d.types.git_mailmap)* mailmap);
/**
* Get the author of a commit, using the mailmap to map names and email
* addresses to canonical real names and email addresses.
*
* Call `git_signature_free` to free the signature.
*
* @param out a pointer to store the resolved signature.
* @param commit a previously loaded commit.
* @param mailmap the mailmap to resolve with. (may be NULL)
* @return 0 or an error code
*/
//GIT_EXTERN
int git_commit_author_with_mailmap(libgit2_d.types.git_signature** out_, const (libgit2_d.types.git_commit)* commit, const (libgit2_d.types.git_mailmap)* mailmap);
/**
* Get the full raw text of the commit header.
*
......@@ -259,7 +287,7 @@ const (libgit2_d.oid.git_oid)* git_commit_parent_id(const (libgit2_d.types.git_c
* @param ancestor Pointer where to store the ancestor commit
* @param commit a previously loaded commit.
* @param n the requested generation
* @return 0 on success; GIT_ENOTFOUND if no matching ancestor exists
* @return 0 on success; git_error_code.GIT_ENOTFOUND if no matching ancestor exists
* or an error code
*/
//GIT_EXTERN
......@@ -272,7 +300,7 @@ int git_commit_nth_gen_ancestor(libgit2_d.types.git_commit** ancestor, const (li
* overwritten
* @param commit the commit to look in
* @param field the header field to return
* @return 0 on succeess, GIT_ENOTFOUND if the field does not exist,
* @return 0 on succeess, git_error_code.GIT_ENOTFOUND if the field does not exist,
* or an error code
*/
//GIT_EXTERN
......@@ -282,8 +310,8 @@ int git_commit_header_field(libgit2_d.buffer.git_buf* out_, const (libgit2_d.typ
* Extract the signature from a commit
*
* If the id is not for a commit, the error class will be
* `GITERR_INVALID`. If the commit does not have a signature, the
* error class will be `GITERR_OBJECT`.
* `git_error_t.GIT_ERROR_INVALID`. If the commit does not have a signature, the
* error class will be `git_error_t.GIT_ERROR_OBJECT`.
*
* @param signature the signature block; existing content will be
* overwritten
......@@ -293,7 +321,7 @@ int git_commit_header_field(libgit2_d.buffer.git_buf* out_, const (libgit2_d.typ
* @param commit_id the commit from which to extract the data
* @param field the name of the header field containing the signature
* block; pass `null` to extract the default 'gpgsig'
* @return 0 on success, GIT_ENOTFOUND if the id is not for a commit
* @return 0 on success, git_error_code.GIT_ENOTFOUND if the id is not for a commit
* or the commit does not have a signature.
*/
//GIT_EXTERN
......@@ -432,11 +460,12 @@ int git_commit_create_buffer(libgit2_d.buffer.git_buf* out_, libgit2_d.types.git
* header field in which to store the signature, attach the signature
* to the commit and write it into the given repository.
*
* @param out_ the resulting commit id
* @param out the resulting commit id
* @param commit_content the content of the unsigned commit object
* @param signature the signature to add to the commit
* @param signature the signature to add to the commit. Leave `NULL`
* to create a commit without adding a signature field.
* @param signature_field which header field should contain this
* signature. Leave `null` for the default of "gpgsig"
* signature. Leave `NULL` for the default of "gpgsig"
* @return 0 or an error code
*/
//GIT_EXTERN
......@@ -452,4 +481,24 @@ int git_commit_create_with_signature(libgit2_d.oid.git_oid* out_, libgit2_d.type
//GIT_EXTERN
int git_commit_dup(libgit2_d.types.git_commit** out_, libgit2_d.types.git_commit* source);
/**
* Commit signing callback.
*
* The callback will be called with the commit content, giving a user an
* opportunity to sign the commit content. The signature_field
* buf may be left empty to specify the default field "gpgsig".
*
* Signatures can take the form of any string, and can be created on an arbitrary
* header field. Signatures are most commonly used for verifying authorship of a
* commit using GPG or a similar cryptographically secure signing algorithm.
* See https://git-scm.com/book/en/v2/Git-Tools-Signing-Your-Work for more
* details.
*
* When the callback:
* - returns git_error_code.GIT_PASSTHROUGH, no signature will be added to the commit.
* - returns < 0, commit creation will be aborted.
* - returns git_error_code.GIT_OK, the signature parameter is expected to be filled.
*/
alias git_commit_signing_cb = int function(libgit2_d.buffer.git_buf* signature, libgit2_d.buffer.git_buf* signature_field, const (char)* commit_content, void* payload);
/** @} */
This diff is collapsed.
......@@ -8,9 +8,8 @@ module libgit2_d.config;
private static import libgit2_d.buffer;
private static import libgit2_d.common;
private static import libgit2_d.types;
private static import libgit2_d.sys.config;
private static import libgit2_d.types;
/**
* @file git2/config.h
......@@ -21,6 +20,7 @@ private static import libgit2_d.sys.config;
*/
extern (C):
nothrow @nogc:
public:
/**
* Priority level of a config file.
......@@ -76,6 +76,11 @@ struct git_config_entry
/**< String value of the entry */
const (char)* value;
/**
* Depth of includes where this variable was found
*/
uint include_depth;
/**< Which config file this was found in */
.git_config_level_t level;
......@@ -92,25 +97,36 @@ struct git_config_entry
//GIT_EXTERN
void git_config_entry_free(.git_config_entry*);
alias git_config_foreach_cb = int function(const (.git_config_entry)*, void*);
/**
* A config enumeration callback
*
* @param entry the entry currently being enumerated
* @param payload a user-specified pointer
*/
alias git_config_foreach_cb = int function(const (.git_config_entry)*, void* payload);
/**
* An opaque structure for a configuration iterator
*/
alias git_config_iterator = libgit2_d.sys.config.git_config_iterator;
/**
* Config var type
*/
enum git_cvar_t
enum git_configmap_t
{
GIT_CVAR_FALSE = 0,
GIT_CVAR_TRUE = 1,
GIT_CVAR_INT32,
GIT_CVAR_STRING,
GIT_CONFIGMAP_FALSE = 0,
GIT_CONFIGMAP_TRUE = 1,
GIT_CONFIGMAP_INT32,
GIT_CONFIGMAP_STRING,
}
/**
* Mapping from config variables to values.
*/
struct git_cvar_map
struct git_configmap
{
.git_cvar_t cvar_type;
.git_configmap_t cvar_type;
const (char)* str_match;
int map_value;
}
......@@ -227,9 +243,9 @@ int git_config_new(libgit2_d.types.git_config** out_);
* @param force replace config file at the given priority level
* @param repo optional repository to allow parsing of
* conditional includes
* @return 0 on success, GIT_EEXISTS when adding more than one file
* @return 0 on success, git_error_code.GIT_EEXISTS when adding more than one file
* for a given priority level (and force_replace set to 0),
* GIT_ENOTFOUND when the file doesn't exist or error code
* git_error_code.GIT_ENOTFOUND when the file doesn't exist or error code
*/
//GIT_EXTERN
int git_config_add_file_ondisk(libgit2_d.types.git_config* cfg, const (char)* path, .git_config_level_t level, const (libgit2_d.types.git_repository)* repo, int force);
......@@ -262,7 +278,7 @@ int git_config_open_ondisk(libgit2_d.types.git_config** out_, const (char)* path
* @param out_ The configuration instance to create
* @param parent Multi-level config to search for the given level
* @param level Configuration level to search for
* @return 0, GIT_ENOTFOUND if the passed level cannot be found in the
* @return 0, git_error_code.GIT_ENOTFOUND if the passed level cannot be found in the
* multi-level parent config, or an error code
*/
//GIT_EXTERN
......@@ -272,7 +288,7 @@ int git_config_open_level(libgit2_d.types.git_config** out_, const (libgit2_d.ty
* Open the global/XDG configuration file according to git's rules
*
* Git allows you to store your global configuration at
* `$HOME/.config` or `$XDG_CONFIG_HOME/git/config`. For backwards
* `$HOME/.gitconfig` or `$XDG_CONFIG_HOME/git/config`. For backwards
* compatability, the XDG file shouldn't be used unless the use has
* created it explicitly. With this function you'll open the correct
* one to write to.
......@@ -457,7 +473,7 @@ int git_config_get_multivar_foreach(const (libgit2_d.types.git_config)* cfg, con
* interested in. Use null to indicate all
*/
//GIT_EXTERN
int git_config_multivar_iterator_new(libgit2_d.sys.config.git_config_iterator** out_,