summaryrefslogtreecommitdiff
path: root/include/git2/remote.h
diff options
context:
space:
mode:
authorCarlos Martín Nieto <cmn@elego.de>2012-07-21 17:52:51 +0200
committerCarlos Martín Nieto <cmn@elego.de>2012-07-21 18:44:01 +0200
commitb3aaa7a7c887006d38b7262b73575d40f51beca5 (patch)
treef6ab0f132ebf96d598074e11a61922e73e2f4f87 /include/git2/remote.h
parent5d9cfa07ac62ad15ebb669b01e723a990450383e (diff)
downloadlibgit2-b3aaa7a7c887006d38b7262b73575d40f51beca5.tar.gz
Add a struct for network callbacks
Currently only update_tips is used, but it prepares the way for progress output during download.
Diffstat (limited to 'include/git2/remote.h')
-rw-r--r--include/git2/remote.h35
1 files changed, 34 insertions, 1 deletions
diff --git a/include/git2/remote.h b/include/git2/remote.h
index 5c01949d2..dc6642cc5 100644
--- a/include/git2/remote.h
+++ b/include/git2/remote.h
@@ -190,7 +190,7 @@ GIT_EXTERN(void) git_remote_free(git_remote *remote);
* @param remote the remote to update
* @param cb callback to run on each ref update. 'a' is the old value, 'b' is then new value
*/
-GIT_EXTERN(int) git_remote_update_tips(git_remote *remote, int (*cb)(const char *refname, const git_oid *a, const git_oid *b));
+GIT_EXTERN(int) git_remote_update_tips(git_remote *remote);
/**
* Return whether a string is a valid remote URL
@@ -238,6 +238,39 @@ GIT_EXTERN(int) git_remote_add(git_remote **out, git_repository *repo, const cha
GIT_EXTERN(void) git_remote_check_cert(git_remote *remote, int check);
+/**
+ * Argument to the completion callback which tells it which operation
+ * finished.
+ */
+typedef enum git_remote_completion_type {
+ GIT_REMOTE_COMPLETION_DOWNLOAD,
+ GIT_REMOTE_COMPLETION_INDEXING,
+ GIT_REMOTE_COMPLETION_ERROR,
+} git_remote_completion_type;
+
+/**
+ * The callback settings structure
+ *
+ * Set the calbacks to be called by the remote.
+ */
+struct git_remote_callbacks {
+ int (*progress)(const char *str, void *data);
+ int (*completion)(git_remote_completion_type type, void *data);
+ int (*update_tips)(const char *refname, const git_oid *a, const git_oid *b, void *data);
+ void *data;
+};
+
+/**
+ * Set the callbacks for a remote
+ *
+ * Note that the remote keeps its own copy of the data and you need to
+ * call this function again if you want to change the callbacks.
+ *
+ * @param remote the remote to configure
+ * @param callbacks a pointer to the user's callback settings
+ */
+GIT_EXTERN(void) git_remote_set_callbacks(git_remote *remote, git_remote_callbacks *callbacks);
+
/** @} */
GIT_END_DECL
#endif