summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorAlan Rogers <alan@github.com>2014-07-22 15:08:24 +1000
committerAlan Rogers <alan@github.com>2014-07-22 15:08:24 +1000
commit7d0ab0fae04015e0bc66ff16beae495f13969b10 (patch)
tree09323e451046ef9dfa6f83754c3fe1fb3d327b48 /include
parente824e63de6724557946ba155034ff8c864f594d2 (diff)
parent091165c53b2bcd5d41fb71d43ed5a23a3d96bf5d (diff)
downloadlibgit2-7d0ab0fae04015e0bc66ff16beae495f13969b10.tar.gz
Merge remote-tracking branch 'origin/master' into fix-git-status-list-new-unreadable-folder
Diffstat (limited to 'include')
-rw-r--r--include/git2/attr.h29
-rw-r--r--include/git2/buffer.h16
-rw-r--r--include/git2/checkout.h24
-rw-r--r--include/git2/clone.h146
-rw-r--r--include/git2/remote.h15
-rw-r--r--include/git2/reset.h4
-rw-r--r--include/git2/revert.h2
-rw-r--r--include/git2/transport.h38
-rw-r--r--include/git2/tree.h6
9 files changed, 165 insertions, 115 deletions
diff --git a/include/git2/attr.h b/include/git2/attr.h
index 3adbb2c24..0238f3dd7 100644
--- a/include/git2/attr.h
+++ b/include/git2/attr.h
@@ -76,25 +76,28 @@ GIT_BEGIN_DECL
*/
#define GIT_ATTR_HAS_VALUE(attr) (git_attr_value(attr) == GIT_ATTR_VALUE_T)
+/**
+ * Possible states for an attribute
+ */
typedef enum {
- GIT_ATTR_UNSPECIFIED_T = 0,
- GIT_ATTR_TRUE_T,
- GIT_ATTR_FALSE_T,
- GIT_ATTR_VALUE_T,
+ GIT_ATTR_UNSPECIFIED_T = 0, /**< The attribute has been left unspecified */
+ GIT_ATTR_TRUE_T, /**< The attribute has been set */
+ GIT_ATTR_FALSE_T, /**< The attribute has been unset */
+ GIT_ATTR_VALUE_T, /**< This attribute has a value */
} git_attr_t;
-/*
- * Return the value type for a given attribute.
+/**
+ * Return the value type for a given attribute.
*
- * This can be either `TRUE`, `FALSE`, `UNSPECIFIED` (if the attribute
- * was not set at all), or `VALUE`, if the attribute was set to
- * an actual string.
+ * This can be either `TRUE`, `FALSE`, `UNSPECIFIED` (if the attribute
+ * was not set at all), or `VALUE`, if the attribute was set to an
+ * actual string.
*
- * If the attribute has a `VALUE` string, it can be accessed normally
- * as a NULL-terminated C string.
+ * If the attribute has a `VALUE` string, it can be accessed normally
+ * as a NULL-terminated C string.
*
- * @param attr The attribute
- * @return the value type for the attribute
+ * @param attr The attribute
+ * @return the value type for the attribute
*/
GIT_EXTERN(git_attr_t) git_attr_value(const char *attr);
diff --git a/include/git2/buffer.h b/include/git2/buffer.h
index 36a61e6c9..1c216bf3a 100644
--- a/include/git2/buffer.h
+++ b/include/git2/buffer.h
@@ -105,6 +105,22 @@ GIT_EXTERN(int) git_buf_grow(git_buf *buffer, size_t target_size);
GIT_EXTERN(int) git_buf_set(
git_buf *buffer, const void *data, size_t datalen);
+/**
+* Check quickly if buffer looks like it contains binary data
+*
+* @param buf Buffer to check
+* @return 1 if buffer looks like non-text data
+*/
+GIT_EXTERN(int) git_buf_is_binary(const git_buf *buf);
+
+/**
+* Check quickly if buffer contains a NUL byte
+*
+* @param buf Buffer to check
+* @return 1 if buffer contains a NUL byte
+*/
+GIT_EXTERN(int) git_buf_contains_nul(const git_buf *buf);
+
GIT_END_DECL
/** @} */
diff --git a/include/git2/checkout.h b/include/git2/checkout.h
index ad44173e6..fe4966aa2 100644
--- a/include/git2/checkout.h
+++ b/include/git2/checkout.h
@@ -233,18 +233,18 @@ typedef void (*git_checkout_progress_cb)(
typedef struct git_checkout_options {
unsigned int version;
- unsigned int checkout_strategy; /** default will be a dry run */
+ unsigned int checkout_strategy; /**< default will be a dry run */
- int disable_filters; /** don't apply filters like CRLF conversion */
- unsigned int dir_mode; /** default is 0755 */
- unsigned int file_mode; /** default is 0644 or 0755 as dictated by blob */
- int file_open_flags; /** default is O_CREAT | O_TRUNC | O_WRONLY */
+ int disable_filters; /**< don't apply filters like CRLF conversion */
+ unsigned int dir_mode; /**< default is 0755 */
+ unsigned int file_mode; /**< default is 0644 or 0755 as dictated by blob */
+ int file_open_flags; /**< default is O_CREAT | O_TRUNC | O_WRONLY */
- unsigned int notify_flags; /** see `git_checkout_notify_t` above */
+ unsigned int notify_flags; /**< see `git_checkout_notify_t` above */
git_checkout_notify_cb notify_cb;
void *notify_payload;
- /* Optional callback to notify the consumer of checkout progress. */
+ /** Optional callback to notify the consumer of checkout progress. */
git_checkout_progress_cb progress_cb;
void *progress_payload;
@@ -254,13 +254,13 @@ typedef struct git_checkout_options {
*/
git_strarray paths;
- git_tree *baseline; /** expected content of workdir, defaults to HEAD */
+ git_tree *baseline; /**< expected content of workdir, defaults to HEAD */
- const char *target_directory; /** alternative checkout path to workdir */
+ const char *target_directory; /**< alternative checkout path to workdir */
- const char *ancestor_label; /** the name of the common ancestor side of conflicts */
- const char *our_label; /** the name of the "our" side of conflicts */
- const char *their_label; /** the name of the "their" side of conflicts */
+ const char *ancestor_label; /**< the name of the common ancestor side of conflicts */
+ const char *our_label; /**< the name of the "our" side of conflicts */
+ const char *their_label; /**< the name of the "their" side of conflicts */
} git_checkout_options;
#define GIT_CHECKOUT_OPTIONS_VERSION 1
diff --git a/include/git2/clone.h b/include/git2/clone.h
index 05b7522ce..fa2e25b60 100644
--- a/include/git2/clone.h
+++ b/include/git2/clone.h
@@ -12,6 +12,7 @@
#include "indexer.h"
#include "checkout.h"
#include "remote.h"
+#include "transport.h"
/**
@@ -52,6 +53,47 @@ typedef enum {
} git_clone_local_t;
/**
+ * The signature of a function matching git_remote_create, with an additional
+ * void* as a callback payload.
+ *
+ * Callers of git_clone may provide a function matching this signature to override
+ * the remote creation and customization process during a clone operation.
+ *
+ * @param out the resulting remote
+ * @param repo the repository in which to create the remote
+ * @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
+ */
+typedef int (*git_remote_create_cb)(
+ git_remote **out,
+ git_repository *repo,
+ const char *name,
+ const char *url,
+ void *payload);
+
+/**
+ * The signature of a function matchin git_repository_init, with an
+ * aditional void * as callback payload.
+ *
+ * Callers of git_clone my provide a function matching this signature
+ * to override the repository creation and customization process
+ * during a clone operation.
+ *
+ * @param out the resulting repository
+ * @param path path in which to create the repository
+ * @param bare whether the repository is bare. This is the value from the clone options
+ * @param payload payload specified by the options
+ * @return 0, or a negative value to indicate error
+ */
+typedef int (*git_repository_create_cb)(
+ git_repository **out,
+ const char *path,
+ int bare,
+ void *payload);
+
+/**
* Clone options structure
*
* Use the GIT_CLONE_OPTIONS_INIT to get the default settings, like this:
@@ -72,7 +114,11 @@ typedef struct git_clone_options {
git_checkout_options checkout_opts;
/**
- * Callbacks to use for reporting fetch progress.
+ * Callbacks to use for reporting fetch progress, and for acquiring
+ * credentials in the event they are needed. This parameter is ignored if
+ * the remote_cb parameter is set; if you provide a remote creation
+ * callback, then you have the opportunity to configure remote callbacks in
+ * provided function.
*/
git_remote_callbacks remote_callbacks;
@@ -83,23 +129,11 @@ typedef struct git_clone_options {
int bare;
/**
- * Set to 1 if errors validating the remote host's certificate
- * should be ignored.
- */
- int ignore_cert_errors;
-
- /**
* Whether to use a fetch or copy the object database.
*/
git_clone_local_t local;
/**
- * The name to be given to the remote that will be
- * created. The default is "origin".
- */
- const char *remote_name;
-
- /**
* The name of the branch to checkout. NULL means use the
* remote's default branch.
*/
@@ -110,6 +144,33 @@ typedef struct git_clone_options {
* use the default signature using the config.
*/
git_signature *signature;
+
+ /**
+ * A callback used to create the new repository into which to
+ * clone. If NULL, the 'bare' field will be used to determine
+ * whether to create a bare repository.
+ */
+ git_repository_create_cb repository_cb;
+
+ /**
+ * An opaque payload to pass to the git_repository creation callback.
+ * This parameter is ignored unless repository_cb is non-NULL.
+ */
+ void *repository_cb_payload;
+
+ /**
+ * A callback used to create the git_remote, prior to its being
+ * used to perform the clone operation. See the documentation for
+ * git_remote_create_cb for details. This parameter may be NULL,
+ * indicating that git_clone should provide default behavior.
+ */
+ git_remote_create_cb remote_cb;
+
+ /**
+ * An opaque payload to pass to the git_remote creation callback.
+ * This parameter is ignored unless remote_cb is non-NULL.
+ */
+ void *remote_cb_payload;
} git_clone_options;
#define GIT_CLONE_OPTIONS_VERSION 1
@@ -130,9 +191,9 @@ GIT_EXTERN(int) git_clone_init_options(
/**
* Clone a remote repository.
*
- * This version handles the simple case. If you'd like to create the
- * repository or remote with non-default settings, you can create and
- * configure them and then use `git_clone_into()`.
+ * By default this creates its repository and initial remote to match
+ * git's defaults. You can use the options in the callback to
+ * customize how these are created.
*
* @param out pointer that will receive the resulting repository object
* @param url the remote repository to clone
@@ -149,59 +210,6 @@ GIT_EXTERN(int) git_clone(
const char *local_path,
const git_clone_options *options);
-/**
- * Clone into a repository
- *
- * After creating the repository and remote and configuring them for
- * paths and callbacks respectively, you can call this function to
- * perform the clone operation and optionally checkout files.
- *
- * @param repo the repository to use
- * @param remote the remote repository to clone from
- * @param co_opts options to use during checkout
- * @param branch the branch to checkout after the clone, pass NULL for the
- * remote's default branch
- * @param signature The identity used when updating the reflog.
- * @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_EXTERN(int) git_clone_into(
- git_repository *repo,
- git_remote *remote,
- const git_checkout_options *co_opts,
- const char *branch,
- const git_signature *signature);
-
-/**
- * Perform a local clone into a repository
- *
- * A "local clone" bypasses any git-aware protocols and simply copies
- * over the object database from the source repository. It is often
- * faster than a git-aware clone, but no verification of the data is
- * performed, and can copy over too much data.
- *
- * @param repo the repository to use
- * @param remote the remote repository to clone from
- * @param co_opts options to use during checkout
- * @param branch the branch to checkout after the clone, pass NULL for the
- * remote's default branch
- * @param link wether to use hardlinks instead of copying
- * objects. This is only possible if both repositories are on the same
- * filesystem.
- * @param signature the identity used when updating the reflog
- * @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_EXTERN(int) git_clone_local_into(
- git_repository *repo,
- git_remote *remote,
- const git_checkout_options *co_opts,
- const char *branch,
- int link,
- const git_signature *signature);
-
/** @} */
GIT_END_DECL
#endif
diff --git a/include/git2/remote.h b/include/git2/remote.h
index c72c9c8cc..c8b6ac97a 100644
--- a/include/git2/remote.h
+++ b/include/git2/remote.h
@@ -419,20 +419,19 @@ GIT_EXTERN(int) git_remote_list(git_strarray *out, git_repository *repo);
GIT_EXTERN(void) git_remote_check_cert(git_remote *remote, int check);
/**
- * 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.
+ * Sets a custom transport factory for the remote. The caller can use this
+ * function to override the transport used for this remote when performing
+ * network operations.
*
* @param remote the remote to configure
- * @param transport the transport object for the remote to use
+ * @param transport_cb the function to use to create a transport
+ * @param payload opaque parameter passed to transport_cb
* @return 0 or an error code
*/
GIT_EXTERN(int) git_remote_set_transport(
git_remote *remote,
- git_transport *transport);
+ git_transport_cb transport_cb,
+ void *payload);
/**
* Argument to the completion callback which tells it which operation
diff --git a/include/git2/reset.h b/include/git2/reset.h
index b8c580339..ea7217efe 100644
--- a/include/git2/reset.h
+++ b/include/git2/reset.h
@@ -7,6 +7,10 @@
#ifndef INCLUDE_git_reset_h__
#define INCLUDE_git_reset_h__
+#include "common.h"
+#include "types.h"
+#include "strarray.h"
+
/**
* @file git2/reset.h
* @brief Git reset management routines
diff --git a/include/git2/revert.h b/include/git2/revert.h
index fc1767c93..ab9dd9af9 100644
--- a/include/git2/revert.h
+++ b/include/git2/revert.h
@@ -59,7 +59,7 @@ GIT_EXTERN(int) git_revert_init_options(
* @param merge_options the merge options (or null for defaults)
* @return zero on success, -1 on failure.
*/
-int git_revert_commit(
+GIT_EXTERN(int) git_revert_commit(
git_index **out,
git_repository *repo,
git_commit *revert_commit,
diff --git a/include/git2/transport.h b/include/git2/transport.h
index af7812b5d..67939a747 100644
--- a/include/git2/transport.h
+++ b/include/git2/transport.h
@@ -11,10 +11,6 @@
#include "net.h"
#include "types.h"
-#ifdef GIT_SSH
-#include <libssh2.h>
-#endif
-
/**
* @file git2/transport.h
* @brief Git transport interfaces and functions
@@ -61,14 +57,20 @@ typedef struct {
char *password;
} git_cred_userpass_plaintext;
-#ifdef GIT_SSH
-typedef LIBSSH2_USERAUTH_PUBLICKEY_SIGN_FUNC((*git_cred_sign_callback));
-typedef LIBSSH2_USERAUTH_KBDINT_RESPONSE_FUNC((*git_cred_ssh_interactive_callback));
-#else
-typedef int (*git_cred_sign_callback)(void *, ...);
-typedef int (*git_cred_ssh_interactive_callback)(void *, ...);
+
+/*
+ * If the user hasn't included libssh2.h before git2.h, we need to
+ * define a few types for the callback signatures.
+ */
+#ifndef LIBSSH2_VERSION
+typedef struct _LIBSSH2_SESSION LIBSSH2_SESSION;
+typedef struct _LIBSSH2_USERAUTH_KBDINT_PROMPT LIBSSH2_USERAUTH_KBDINT_PROMPT;
+typedef struct _LIBSSH2_USERAUTH_KBDINT_RESPONSE LIBSSH2_USERAUTH_KBDINT_RESPONSE;
#endif
+typedef int (*git_cred_sign_callback)(LIBSSH2_SESSION *session, unsigned char **sig, size_t *sig_len, const unsigned char *data, size_t data_len, void **abstract);
+typedef void (*git_cred_ssh_interactive_callback)(const char* name, int name_len, const char* instruction, int instruction_len, int num_prompts, const LIBSSH2_USERAUTH_KBDINT_PROMPT* prompts, LIBSSH2_USERAUTH_KBDINT_RESPONSE* responses, void **abstract);
+
/**
* A ssh key from disk
*/
@@ -334,6 +336,22 @@ GIT_EXTERN(int) git_transport_init(
*/
GIT_EXTERN(int) git_transport_new(git_transport **out, git_remote *owner, const char *url);
+/**
+ * Create an ssh transport with custom git command paths
+ *
+ * This is a factory function suitable for setting as the transport
+ * callback in a remote (or for a clone in the options).
+ *
+ * The payload argument must be a strarray pointer with the paths for
+ * the `git-upload-pack` and `git-receive-pack` at index 0 and 1.
+ *
+ * @param out the resulting transport
+ * @param owner the owning remote
+ * @param payload a strarray with the paths
+ * @return 0 or an error code
+ */
+GIT_EXTERN(int) git_transport_ssh_with_paths(git_transport **out, git_remote *owner, void *payload);
+
/* Signature of a function which creates a transport */
typedef int (*git_transport_cb)(git_transport **out, git_remote *owner, void *param);
diff --git a/include/git2/tree.h b/include/git2/tree.h
index 56922d40b..42b68193e 100644
--- a/include/git2/tree.h
+++ b/include/git2/tree.h
@@ -301,8 +301,10 @@ GIT_EXTERN(const git_tree_entry *) git_treebuilder_get(
* If an entry named `filename` already exists, its attributes
* will be updated with the given ones.
*
- * The optional pointer `out` can be used to retrieve a pointer to
- * the newly created/updated entry. Pass NULL if you do not need it.
+ * The optional pointer `out` can be used to retrieve a pointer to the
+ * newly created/updated entry. Pass NULL if you do not need it. The
+ * pointer may not be valid past the next operation in this
+ * builder. Duplicate the entry if you want to keep it.
*
* No attempt is being made to ensure that the provided oid points
* to an existing git object in the object database, nor that the