summaryrefslogtreecommitdiffstats
path: root/include/git2
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-21 05:03:04 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-21 05:03:04 +0000
commitb88736462df2c86a83f01dcc260b5463205819d2 (patch)
treeb1a9a5a5392a52ec4e5f60fb4b45083cf7fd65b0 /include/git2
parentAdding upstream version 1.7.2+ds. (diff)
downloadlibgit2-b88736462df2c86a83f01dcc260b5463205819d2.tar.xz
libgit2-b88736462df2c86a83f01dcc260b5463205819d2.zip
Adding upstream version 1.8.1+ds.upstream/1.8.1+dsupstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'include/git2')
-rw-r--r--include/git2/attr.h4
-rw-r--r--include/git2/commit.h67
-rw-r--r--include/git2/common.h52
-rw-r--r--include/git2/config.h56
-rw-r--r--include/git2/email.h1
-rw-r--r--include/git2/errors.h82
-rw-r--r--include/git2/refspec.h2
-rw-r--r--include/git2/remote.h34
-rw-r--r--include/git2/repository.h13
-rw-r--r--include/git2/sys/config.h51
-rw-r--r--include/git2/sys/email.h5
-rw-r--r--include/git2/sys/errors.h66
-rw-r--r--include/git2/sys/remote.h6
-rw-r--r--include/git2/sys/repository.h5
-rw-r--r--include/git2/sys/stream.h4
-rw-r--r--include/git2/version.h14
-rw-r--r--include/git2/worktree.h9
17 files changed, 362 insertions, 109 deletions
diff --git a/include/git2/attr.h b/include/git2/attr.h
index 0c83872..69929b3 100644
--- a/include/git2/attr.h
+++ b/include/git2/attr.h
@@ -116,14 +116,12 @@ GIT_EXTERN(git_attr_value_t) git_attr_value(const char *attr);
*/
#define GIT_ATTR_CHECK_FILE_THEN_INDEX 0
#define GIT_ATTR_CHECK_INDEX_THEN_FILE 1
-#define GIT_ATTR_CHECK_INDEX_ONLY 2
+#define GIT_ATTR_CHECK_INDEX_ONLY 2
/**
* 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.
diff --git a/include/git2/commit.h b/include/git2/commit.h
index 67170cb..ef38c66 100644
--- a/include/git2/commit.h
+++ b/include/git2/commit.h
@@ -366,7 +366,7 @@ GIT_EXTERN(int) git_commit_create(
const char *message,
const git_tree *tree,
size_t parent_count,
- const git_commit *parents[]);
+ git_commit * const parents[]);
/**
* Create new commit in the repository using a variable argument list.
@@ -394,6 +394,49 @@ GIT_EXTERN(int) git_commit_create_v(
size_t parent_count,
...);
+typedef struct {
+ unsigned int version;
+
+ /**
+ * Flags for creating the commit.
+ *
+ * If `allow_empty_commit` is specified, a commit with no changes
+ * from the prior commit (and "empty" commit) is allowed. Otherwise,
+ * commit creation will be stopped.
+ */
+ unsigned int allow_empty_commit : 1;
+
+ /** The commit author, or NULL for the default. */
+ const git_signature *author;
+
+ /** The committer, or NULL for the default. */
+ const git_signature *committer;
+
+ /** Encoding for the commit message; leave NULL for default. */
+ const char *message_encoding;
+} git_commit_create_options;
+
+#define GIT_COMMIT_CREATE_OPTIONS_VERSION 1
+#define GIT_COMMIT_CREATE_OPTIONS_INIT { GIT_COMMIT_CREATE_OPTIONS_VERSION }
+
+/**
+ * Commits the staged changes in the repository; this is a near analog to
+ * `git commit -m message`.
+ *
+ * By default, empty commits are not allowed.
+ *
+ * @param id pointer to store the new commit's object id
+ * @param repo repository to commit changes in
+ * @param message the commit message
+ * @param opts options for creating the commit
+ * @return 0 on success, GIT_EUNCHANGED if there were no changes to commit, or an error code
+ */
+GIT_EXTERN(int) git_commit_create_from_stage(
+ git_oid *id,
+ git_repository *repo,
+ const char *message,
+ const git_commit_create_options *opts);
+
/**
* Amend an existing commit by replacing only non-NULL values.
*
@@ -469,7 +512,7 @@ GIT_EXTERN(int) git_commit_create_buffer(
const char *message,
const git_tree *tree,
size_t parent_count,
- const git_commit *parents[]);
+ git_commit * const parents[]);
/**
* Create a commit object from the given buffer and signature
@@ -538,9 +581,27 @@ typedef int (*git_commit_create_cb)(
const char *message,
const git_tree *tree,
size_t parent_count,
- const git_commit *parents[],
+ git_commit * const parents[],
void *payload);
+/** An array of commits returned from the library */
+typedef struct git_commitarray {
+ git_commit *const *commits;
+ size_t count;
+} git_commitarray;
+
+/**
+ * Free the commits contained in a commit array. This method should
+ * be called on `git_commitarray` objects that were provided by the
+ * library. Not doing so will result in a memory leak.
+ *
+ * This does not free the `git_commitarray` itself, since the library
+ * will never allocate that object directly itself.
+ *
+ * @param array The git_commitarray that contains commits to free
+ */
+GIT_EXTERN(void) git_commitarray_dispose(git_commitarray *array);
+
/** @} */
GIT_END_DECL
#endif
diff --git a/include/git2/common.h b/include/git2/common.h
index ab6bc13..b7cf20b 100644
--- a/include/git2/common.h
+++ b/include/git2/common.h
@@ -228,7 +228,9 @@ typedef enum {
GIT_OPT_SET_SERVER_CONNECT_TIMEOUT,
GIT_OPT_GET_SERVER_CONNECT_TIMEOUT,
GIT_OPT_SET_SERVER_TIMEOUT,
- GIT_OPT_GET_SERVER_TIMEOUT
+ GIT_OPT_GET_SERVER_TIMEOUT,
+ GIT_OPT_SET_USER_AGENT_PRODUCT,
+ GIT_OPT_GET_USER_AGENT_PRODUCT
} git_libgit2_opt_t;
/**
@@ -337,11 +339,35 @@ typedef enum {
*
* * opts(GIT_OPT_SET_USER_AGENT, const char *user_agent)
*
- * > Set the value of the User-Agent header. This value will be
- * > appended to "git/1.0", for compatibility with other git clients.
+ * > Set the value of the comment section of the User-Agent header.
+ * > This can be information about your product and its version.
+ * > By default this is "libgit2" followed by the libgit2 version.
* >
- * > - `user_agent` is the value that will be delivered as the
- * > User-Agent header on HTTP requests.
+ * > This value will be appended to User-Agent _product_, which
+ * > is typically set to "git/2.0".
+ * >
+ * > Set to the empty string ("") to not send any information in the
+ * > comment section, or set to NULL to restore the default.
+ *
+ * * opts(GIT_OPT_GET_USER_AGENT, git_buf *out)
+ *
+ * > Get the value of the User-Agent header.
+ * > The User-Agent is written to the `out` buffer.
+ *
+ * * opts(GIT_OPT_SET_USER_AGENT_PRODUCT, const char *user_agent_product)
+ *
+ * > Set the value of the product portion of the User-Agent header.
+ * > This defaults to "git/2.0", for compatibility with other git
+ * > clients. It is recommended to keep this as git/<version> for
+ * > compatibility with servers that do user-agent detection.
+ * >
+ * > Set to the empty string ("") to not send any user-agent string,
+ * > or set to NULL to restore the default.
+ *
+ * * opts(GIT_OPT_GET_USER_AGENT_PRODUCT, git_buf *out)
+ *
+ * > Get the value of the User-Agent product header.
+ * > The User-Agent product is written to the `out` buffer.
*
* * opts(GIT_OPT_SET_WINDOWS_SHAREMODE, unsigned long value)
*
@@ -377,11 +403,6 @@ typedef enum {
* >
* > - `ciphers` is the list of ciphers that are eanbled.
*
- * * opts(GIT_OPT_GET_USER_AGENT, git_buf *out)
- *
- * > Get the value of the User-Agent header.
- * > The User-Agent is written to the `out` buffer.
- *
* * opts(GIT_OPT_ENABLE_OFS_DELTA, int enabled)
*
* > Enable or disable the use of "offset deltas" when creating packfiles,
@@ -490,10 +511,9 @@ typedef enum {
*
* opts(GIT_OPT_SET_SERVER_CONNECT_TIMEOUT, int timeout)
* > Sets the timeout (in milliseconds) to attempt connections to
- * > a remote server. This is supported only for HTTP(S) connections
- * > and is not supported by SSH. Set to 0 to use the system default.
- * > Note that this may not be able to be configured longer than the
- * > system default, typically 75 seconds.
+ * > a remote server. Set to 0 to use the system default. Note that
+ * > this may not be able to be configured longer than the system
+ * > default, typically 75 seconds.
*
* opts(GIT_OPT_GET_SERVER_TIMEOUT, int *timeout)
* > Gets the timeout (in milliseconds) for reading from and writing
@@ -501,9 +521,7 @@ typedef enum {
*
* opts(GIT_OPT_SET_SERVER_TIMEOUT, int timeout)
* > Sets the timeout (in milliseconds) for reading from and writing
- * > to a remote server. This is supported only for HTTP(S)
- * > connections and is not supported by SSH. Set to 0 to use the
- * > system default.
+ * > to a remote server. Set to 0 to use the system default.
*
* @param option Option key
* @param ... value to set the option
diff --git a/include/git2/config.h b/include/git2/config.h
index cfab0c7..3236143 100644
--- a/include/git2/config.h
+++ b/include/git2/config.h
@@ -22,8 +22,19 @@ GIT_BEGIN_DECL
/**
* Priority level of a config file.
+ *
* These priority levels correspond to the natural escalation logic
- * (from higher to lower) when searching for config entries in git.git.
+ * (from higher to lower) when reading or searching for config entries
+ * in git.git. Meaning that for the same key, the configuration in
+ * the local configuration is preferred over the configuration in
+ * the system configuration file.
+ *
+ * Callers can add their own custom configuration, beginning at the
+ * `GIT_CONFIG_LEVEL_APP` level.
+ *
+ * Writes, by default, occur in the highest priority level backend
+ * that is writable. This ordering can be overridden with
+ * `git_config_set_writeorder`.
*
* git_config_open_default() and git_repository_config() honor those
* priority levels as well.
@@ -48,9 +59,13 @@ typedef enum {
*/
GIT_CONFIG_LEVEL_LOCAL = 5,
+ /** Worktree specific configuration file; $GIT_DIR/config.worktree
+ */
+ GIT_CONFIG_LEVEL_WORKTREE = 6,
+
/** Application specific configuration file; freely defined by applications
*/
- GIT_CONFIG_LEVEL_APP = 6,
+ GIT_CONFIG_LEVEL_APP = 7,
/** Represents the highest level available config file (i.e. the most
* specific config file available that actually is loaded)
@@ -62,12 +77,32 @@ typedef enum {
* An entry in a configuration file
*/
typedef struct git_config_entry {
- const char *name; /**< Name of the entry (normalised) */
- const char *value; /**< String value of the entry */
- unsigned int include_depth; /**< Depth of includes where this variable was found */
- git_config_level_t level; /**< Which config file this was found in */
- void GIT_CALLBACK(free)(struct git_config_entry *entry); /**< Free function for this entry */
- void *payload; /**< Opaque value for the free function. Do not read or write */
+ /** Name of the configuration entry (normalized) */
+ const char *name;
+
+ /** Literal (string) value of the entry */
+ const char *value;
+
+ /** The type of backend that this entry exists in (eg, "file") */
+ const char *backend_type;
+
+ /**
+ * The path to the origin of this entry. For config files, this is
+ * the path to the file.
+ */
+ const char *origin_path;
+
+ /** Depth of includes where this variable was found */
+ unsigned int include_depth;
+
+ /** Configuration level for the file this was found in */
+ git_config_level_t level;
+
+ /**
+ * Free function for this entry; for internal purposes. Callers
+ * should call `git_config_entry_free` to free data.
+ */
+ void GIT_CALLBACK(free)(struct git_config_entry *entry);
} git_config_entry;
/**
@@ -276,6 +311,11 @@ GIT_EXTERN(int) git_config_open_level(
*/
GIT_EXTERN(int) git_config_open_global(git_config **out, git_config *config);
+GIT_EXTERN(int) git_config_set_writeorder(
+ git_config *cfg,
+ git_config_level_t *levels,
+ size_t len);
+
/**
* Create a snapshot of the configuration
*
diff --git a/include/git2/email.h b/include/git2/email.h
index 2039365..3389353 100644
--- a/include/git2/email.h
+++ b/include/git2/email.h
@@ -8,6 +8,7 @@
#define INCLUDE_git_email_h__
#include "common.h"
+#include "diff.h"
/**
* @file git2/email.h
diff --git a/include/git2/errors.h b/include/git2/errors.h
index 7180852..52fa5f0 100644
--- a/include/git2/errors.h
+++ b/include/git2/errors.h
@@ -19,20 +19,20 @@ GIT_BEGIN_DECL
/** Generic return codes */
typedef enum {
- GIT_OK = 0, /**< No error */
+ GIT_OK = 0, /**< No error */
- GIT_ERROR = -1, /**< Generic error */
- GIT_ENOTFOUND = -3, /**< Requested object could not be found */
- GIT_EEXISTS = -4, /**< Object exists preventing operation */
- GIT_EAMBIGUOUS = -5, /**< More than one object matches */
- GIT_EBUFS = -6, /**< Output buffer too short to hold data */
+ GIT_ERROR = -1, /**< Generic error */
+ GIT_ENOTFOUND = -3, /**< Requested object could not be found */
+ GIT_EEXISTS = -4, /**< Object exists preventing operation */
+ GIT_EAMBIGUOUS = -5, /**< More than one object matches */
+ GIT_EBUFS = -6, /**< Output buffer too short to hold data */
/**
* GIT_EUSER is a special error that is never generated by libgit2
* code. You can return it from a callback (e.g to stop an iteration)
* to know that it was generated by the callback and not by libgit2.
*/
- GIT_EUSER = -7,
+ GIT_EUSER = -7,
GIT_EBAREREPO = -8, /**< Operation not allowed on bare repository */
GIT_EUNBORNBRANCH = -9, /**< HEAD refers to branch with no commits */
@@ -59,7 +59,10 @@ typedef enum {
GIT_EINDEXDIRTY = -34, /**< Unsaved changes in the index would be overwritten */
GIT_EAPPLYFAIL = -35, /**< Patch application failed */
GIT_EOWNER = -36, /**< The object is not owned by the current user */
- GIT_TIMEOUT = -37 /**< The operation timed out */
+ GIT_TIMEOUT = -37, /**< The operation timed out */
+ GIT_EUNCHANGED = -38, /**< There were no changes */
+ GIT_ENOTSUPPORTED = -39, /**< An option is not supported */
+ GIT_EREADONLY = -40 /**< The subject is read-only */
} git_error_code;
/**
@@ -118,63 +121,22 @@ typedef enum {
* Return the last `git_error` object that was generated for the
* current thread.
*
- * The default behaviour of this function is to return NULL if no previous error has occurred.
- * However, libgit2's error strings are not cleared aggressively, so a prior
- * (unrelated) error may be returned. This can be avoided by only calling
- * this function if the prior call to a libgit2 API returned an error.
+ * This function will never return NULL.
*
- * @return A git_error object.
- */
-GIT_EXTERN(const git_error *) git_error_last(void);
-
-/**
- * Clear the last library error that occurred for this thread.
- */
-GIT_EXTERN(void) git_error_clear(void);
-
-/**
- * Set the error message string for this thread, using `printf`-style
- * formatting.
- *
- * This function is public so that custom ODB backends and the like can
- * relay an error message through libgit2. Most regular users of libgit2
- * will never need to call this function -- actually, calling it in most
- * circumstances (for example, calling from within a callback function)
- * will just end up having the value overwritten by libgit2 internals.
+ * Callers should not rely on this to determine whether an error has
+ * occurred. For error checking, callers should examine the return
+ * codes of libgit2 functions.
*
- * This error message is stored in thread-local storage and only applies
- * to the particular thread that this libgit2 call is made from.
+ * This call can only reliably report error messages when an error
+ * has occurred. (It may contain stale information if it is called
+ * after a different function that succeeds.)
*
- * @param error_class One of the `git_error_t` enum above describing the
- * general subsystem that is responsible for the error.
- * @param fmt The `printf`-style format string; subsequent arguments must
- * be the arguments for the format string.
- */
-GIT_EXTERN(void) git_error_set(int error_class, const char *fmt, ...)
- GIT_FORMAT_PRINTF(2, 3);
-
-/**
- * Set the error message string for this thread. This function is like
- * `git_error_set` but takes a static string instead of a `printf`-style
- * format.
+ * The memory for this object is managed by libgit2. It should not
+ * be freed.
*
- * @param error_class One of the `git_error_t` enum above describing the
- * general subsystem that is responsible for the error.
- * @param string The error message to keep
- * @return 0 on success or -1 on failure
- */
-GIT_EXTERN(int) git_error_set_str(int error_class, const char *string);
-
-/**
- * Set the error message to a special value for memory allocation failure.
- *
- * The normal `git_error_set_str()` function attempts to `strdup()` the
- * string that is passed in. This is not a good idea when the error in
- * question is a memory allocation failure. That circumstance has a
- * special setter function that sets the error string to a known and
- * statically allocated internal value.
+ * @return A git_error object.
*/
-GIT_EXTERN(void) git_error_set_oom(void);
+GIT_EXTERN(const git_error *) git_error_last(void);
/** @} */
GIT_END_DECL
diff --git a/include/git2/refspec.h b/include/git2/refspec.h
index eaf7747..e708713 100644
--- a/include/git2/refspec.h
+++ b/include/git2/refspec.h
@@ -58,7 +58,7 @@ GIT_EXTERN(const char *) git_refspec_dst(const git_refspec *refspec);
* Get the refspec's string
*
* @param refspec the refspec
- * @returns the refspec's original string
+ * @return the refspec's original string
*/
GIT_EXTERN(const char *) git_refspec_string(const git_refspec *refspec);
diff --git a/include/git2/remote.h b/include/git2/remote.h
index e9065b2..5505f6c 100644
--- a/include/git2/remote.h
+++ b/include/git2/remote.h
@@ -77,6 +77,17 @@ typedef enum {
} git_remote_create_flags;
/**
+ * How to handle reference updates.
+ */
+typedef enum {
+ /* Write the fetch results to FETCH_HEAD. */
+ GIT_REMOTE_UPDATE_FETCHHEAD = (1 << 0),
+
+ /* Report unchanged tips in the update_tips callback. */
+ GIT_REMOTE_UPDATE_REPORT_UNCHANGED = (1 << 1)
+} git_remote_update_flags;
+
+/**
* Remote creation options structure
*
* Initialize with `GIT_REMOTE_CREATE_OPTIONS_INIT`. Alternatively, you can
@@ -733,10 +744,9 @@ typedef struct {
git_fetch_prune_t prune;
/**
- * Whether to write the results to FETCH_HEAD. Defaults to
- * on. Leave this default in order to behave like git.
+ * How to handle reference updates; see `git_remote_update_flags`.
*/
- int update_fetchhead;
+ unsigned int update_fetchhead;
/**
* Determines how to behave regarding tags on the remote, such
@@ -775,8 +785,13 @@ typedef struct {
} git_fetch_options;
#define GIT_FETCH_OPTIONS_VERSION 1
-#define GIT_FETCH_OPTIONS_INIT { GIT_FETCH_OPTIONS_VERSION, GIT_REMOTE_CALLBACKS_INIT, GIT_FETCH_PRUNE_UNSPECIFIED, 1, \
- GIT_REMOTE_DOWNLOAD_TAGS_UNSPECIFIED, GIT_PROXY_OPTIONS_INIT }
+#define GIT_FETCH_OPTIONS_INIT { \
+ GIT_FETCH_OPTIONS_VERSION, \
+ GIT_REMOTE_CALLBACKS_INIT, \
+ GIT_FETCH_PRUNE_UNSPECIFIED, \
+ GIT_REMOTE_UPDATE_FETCHHEAD, \
+ GIT_REMOTE_DOWNLOAD_TAGS_UNSPECIFIED, \
+ GIT_PROXY_OPTIONS_INIT }
/**
* Initialize git_fetch_options structure
@@ -830,6 +845,11 @@ typedef struct {
* Extra headers for this push operation
*/
git_strarray custom_headers;
+
+ /**
+ * "Push options" to deliver to the remote.
+ */
+ git_strarray remote_push_options;
} git_push_options;
#define GIT_PUSH_OPTIONS_VERSION 1
@@ -1001,7 +1021,7 @@ GIT_EXTERN(int) git_remote_upload(
* the name of the remote (or its url, for in-memory remotes). This
* parameter is ignored when pushing.
* @param callbacks pointer to the callback structure to use or NULL
- * @param update_fetchhead whether to write to FETCH_HEAD. Pass 1 to behave like git.
+ * @param update_flags the git_remote_update_flags for these tips.
* @param download_tags what the behaviour for downloading tags is for this fetch. This is
* ignored for push. This must be the same value passed to `git_remote_download()`.
* @return 0 or an error code
@@ -1009,7 +1029,7 @@ GIT_EXTERN(int) git_remote_upload(
GIT_EXTERN(int) git_remote_update_tips(
git_remote *remote,
const git_remote_callbacks *callbacks,
- int update_fetchhead,
+ unsigned int update_flags,
git_remote_autotag_option_t download_tags,
const char *reflog_message);
diff --git a/include/git2/repository.h b/include/git2/repository.h
index 6ec2ac8..0afda72 100644
--- a/include/git2/repository.h
+++ b/include/git2/repository.h
@@ -11,6 +11,7 @@
#include "types.h"
#include "oid.h"
#include "buffer.h"
+#include "commit.h"
/**
* @file git2/repository.h
@@ -503,6 +504,7 @@ typedef enum {
GIT_REPOSITORY_ITEM_LOGS,
GIT_REPOSITORY_ITEM_MODULES,
GIT_REPOSITORY_ITEM_WORKTREES,
+ GIT_REPOSITORY_ITEM_WORKTREE_CONFIG,
GIT_REPOSITORY_ITEM__LAST
} git_repository_item_t;
@@ -978,6 +980,17 @@ GIT_EXTERN(int) git_repository_set_ident(git_repository *repo, const char *name,
*/
GIT_EXTERN(git_oid_t) git_repository_oid_type(git_repository *repo);
+/**
+ * Gets the parents of the next commit, given the current repository state.
+ * Generally, this is the HEAD commit, except when performing a merge, in
+ * which case it is two or more commits.
+ *
+ * @param commits a `git_commitarray` that will contain the commit parents
+ * @param repo the repository
+ * @return 0 or an error code
+ */
+GIT_EXTERN(int) git_repository_commit_parents(git_commitarray *commits, git_repository *repo);
+
/** @} */
GIT_END_DECL
#endif
diff --git a/include/git2/sys/config.h b/include/git2/sys/config.h
index 0a9005e..75d2075 100644
--- a/include/git2/sys/config.h
+++ b/include/git2/sys/config.h
@@ -125,6 +125,57 @@ GIT_EXTERN(int) git_config_add_backend(
const git_repository *repo,
int force);
+/** Options for in-memory configuration backends. */
+typedef struct {
+ unsigned int version;
+
+ /**
+ * The type of this backend (eg, "command line"). If this is
+ * NULL, then this will be "in-memory".
+ */
+ const char *backend_type;
+
+ /**
+ * The path to the origin; if this is NULL then it will be
+ * left unset in the resulting configuration entries.
+ */
+ const char *origin_path;
+} git_config_backend_memory_options;
+
+#define GIT_CONFIG_BACKEND_MEMORY_OPTIONS_VERSION 1
+#define GIT_CONFIG_BACKEND_MEMORY_OPTIONS_INIT { GIT_CONFIG_BACKEND_MEMORY_OPTIONS_VERSION }
+
+
+/**
+ * Create an in-memory configuration backend from a string in standard
+ * git configuration file format.
+ *
+ * @param out the new backend
+ * @param cfg the configuration that is to be parsed
+ * @param len the length of the string pointed to by `cfg`
+ * @param opts the options to initialize this backend with, or NULL
+ */
+extern int git_config_backend_from_string(
+ git_config_backend **out,
+ const char *cfg,
+ size_t len,
+ git_config_backend_memory_options *opts);
+
+/**
+ * Create an in-memory configuration backend from a list of name/value
+ * pairs.
+ *
+ * @param out the new backend
+ * @param values the configuration values to set (in "key=value" format)
+ * @param len the length of the values array
+ * @param opts the options to initialize this backend with, or NULL
+ */
+extern int git_config_backend_from_values(
+ git_config_backend **out,
+ const char **values,
+ size_t len,
+ git_config_backend_memory_options *opts);
+
/** @} */
GIT_END_DECL
#endif
diff --git a/include/git2/sys/email.h b/include/git2/sys/email.h
index 6f4a286..5029f9a 100644
--- a/include/git2/sys/email.h
+++ b/include/git2/sys/email.h
@@ -7,6 +7,11 @@
#ifndef INCLUDE_sys_git_email_h__
#define INCLUDE_sys_git_email_h__
+#include "git2/common.h"
+#include "git2/diff.h"
+#include "git2/email.h"
+#include "git2/types.h"
+
/**
* @file git2/sys/email.h
* @brief Advanced git email creation routines
diff --git a/include/git2/sys/errors.h b/include/git2/sys/errors.h
new file mode 100644
index 0000000..3ae1215
--- /dev/null
+++ b/include/git2/sys/errors.h
@@ -0,0 +1,66 @@
+/*
+ * 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.
+ */
+
+#ifndef INCLUDE_sys_git_errors_h__
+#define INCLUDE_sys_git_errors_h__
+
+#include "git2/common.h"
+
+GIT_BEGIN_DECL
+
+/**
+ * Clear the last library error that occurred for this thread.
+ */
+GIT_EXTERN(void) git_error_clear(void);
+
+/**
+ * Set the error message string for this thread, using `printf`-style
+ * formatting.
+ *
+ * This function is public so that custom ODB backends and the like can
+ * relay an error message through libgit2. Most regular users of libgit2
+ * will never need to call this function -- actually, calling it in most
+ * circumstances (for example, calling from within a callback function)
+ * will just end up having the value overwritten by libgit2 internals.
+ *
+ * This error message is stored in thread-local storage and only applies
+ * to the particular thread that this libgit2 call is made from.
+ *
+ * @param error_class One of the `git_error_t` enum above describing the
+ * general subsystem that is responsible for the error.
+ * @param fmt The `printf`-style format string; subsequent arguments must
+ * be the arguments for the format string.
+ */
+GIT_EXTERN(void) git_error_set(int error_class, const char *fmt, ...)
+ GIT_FORMAT_PRINTF(2, 3);
+
+/**
+ * Set the error message string for this thread. This function is like
+ * `git_error_set` but takes a static string instead of a `printf`-style
+ * format.
+ *
+ * @param error_class One of the `git_error_t` enum above describing the
+ * general subsystem that is responsible for the error.
+ * @param string The error message to keep
+ * @return 0 on success or -1 on failure
+ */
+GIT_EXTERN(int) git_error_set_str(int error_class, const char *string);
+
+/**
+ * Set the error message to a special value for memory allocation failure.
+ *
+ * The normal `git_error_set_str()` function attempts to `strdup()` the
+ * string that is passed in. This is not a good idea when the error in
+ * question is a memory allocation failure. That circumstance has a
+ * special setter function that sets the error string to a known and
+ * statically allocated internal value.
+ */
+GIT_EXTERN(void) git_error_set_oom(void);
+
+GIT_END_DECL
+
+#endif
diff --git a/include/git2/sys/remote.h b/include/git2/sys/remote.h
index 0eae923..58950e1 100644
--- a/include/git2/sys/remote.h
+++ b/include/git2/sys/remote.h
@@ -20,12 +20,18 @@
GIT_BEGIN_DECL
+/**
+ * A remote's capabilities.
+ */
typedef enum {
/** Remote supports fetching an advertised object by ID. */
GIT_REMOTE_CAPABILITY_TIP_OID = (1 << 0),
/** Remote supports fetching an individual reachable object. */
GIT_REMOTE_CAPABILITY_REACHABLE_OID = (1 << 1),
+
+ /** Remote supports push options. */
+ GIT_REMOTE_CAPABILITY_PUSH_OPTIONS = (1 << 2),
} git_remote_capability_t;
/**
diff --git a/include/git2/sys/repository.h b/include/git2/sys/repository.h
index 892be66..080a404 100644
--- a/include/git2/sys/repository.h
+++ b/include/git2/sys/repository.h
@@ -9,6 +9,7 @@
#include "git2/common.h"
#include "git2/types.h"
+#include "git2/oid.h"
/**
* @file git2/sys/repository.h
@@ -32,7 +33,11 @@ GIT_BEGIN_DECL
* @param out The blank repository
* @return 0 on success, or an error code
*/
+#ifdef GIT_EXPERIMENTAL_SHA256
+GIT_EXTERN(int) git_repository_new(git_repository **out, git_oid_t oid_type);
+#else
GIT_EXTERN(int) git_repository_new(git_repository **out);
+#endif
/**
* Reset all the internal state in a repository.
diff --git a/include/git2/sys/stream.h b/include/git2/sys/stream.h
index 3d28d09..3277088 100644
--- a/include/git2/sys/stream.h
+++ b/include/git2/sys/stream.h
@@ -29,8 +29,8 @@ GIT_BEGIN_DECL
typedef struct git_stream {
int version;
- int encrypted : 1,
- proxy_support : 1;
+ unsigned int encrypted : 1,
+ proxy_support : 1;
/**
* Timeout for read and write operations; can be set to `0` to
diff --git a/include/git2/version.h b/include/git2/version.h
index d6aba3b..33c9625 100644
--- a/include/git2/version.h
+++ b/include/git2/version.h
@@ -11,16 +11,16 @@
* The version string for libgit2. This string follows semantic
* versioning (v2) guidelines.
*/
-#define LIBGIT2_VERSION "1.7.2"
+#define LIBGIT2_VERSION "1.8.1"
/** The major version number for this version of libgit2. */
#define LIBGIT2_VER_MAJOR 1
/** The minor version number for this version of libgit2. */
-#define LIBGIT2_VER_MINOR 7
+#define LIBGIT2_VER_MINOR 8
/** The revision ("teeny") version number for this version of libgit2. */
-#define LIBGIT2_VER_REVISION 2
+#define LIBGIT2_VER_REVISION 1
/** The Windows DLL patch number for this version of libgit2. */
#define LIBGIT2_VER_PATCH 0
@@ -33,7 +33,11 @@
*/
#define LIBGIT2_VER_PRERELEASE NULL
-/** The library ABI soversion for this version of libgit2. */
-#define LIBGIT2_SOVERSION "1.7"
+/**
+ * The library ABI soversion for this version of libgit2. This should
+ * only be changed when the library has a breaking ABI change, and so
+ * may trail the library's version number.
+ */
+#define LIBGIT2_SOVERSION "1.8"
#endif
diff --git a/include/git2/worktree.h b/include/git2/worktree.h
index 9193eaf..a6e5d17 100644
--- a/include/git2/worktree.h
+++ b/include/git2/worktree.h
@@ -11,6 +11,7 @@
#include "buffer.h"
#include "types.h"
#include "strarray.h"
+#include "checkout.h"
/**
* @file git2/worktrees.h
@@ -85,8 +86,9 @@ GIT_EXTERN(int) git_worktree_validate(const git_worktree *wt);
typedef struct git_worktree_add_options {
unsigned int version;
- int lock; /**< lock newly created worktree */
- git_reference *ref; /**< reference to use for the new worktree HEAD */
+ int lock; /**< lock newly created worktree */
+ int checkout_existing; /**< allow checkout of existing branch matching worktree name */
+ git_reference *ref; /**< reference to use for the new worktree HEAD */
/**
* Options for the checkout.
@@ -95,7 +97,8 @@ typedef struct git_worktree_add_options {
} git_worktree_add_options;
#define GIT_WORKTREE_ADD_OPTIONS_VERSION 1
-#define GIT_WORKTREE_ADD_OPTIONS_INIT {GIT_WORKTREE_ADD_OPTIONS_VERSION,0,NULL,GIT_CHECKOUT_OPTIONS_INIT}
+#define GIT_WORKTREE_ADD_OPTIONS_INIT { GIT_WORKTREE_ADD_OPTIONS_VERSION, \
+ 0, 0, NULL, GIT_CHECKOUT_OPTIONS_INIT }
/**
* Initialize git_worktree_add_options structure