remote: provide read access to the callback structure This should make it easier for bindings to dynamically override their own callbacks.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
diff --git a/include/git2/remote.h b/include/git2/remote.h
index d57321f..578fcf5 100644
--- a/include/git2/remote.h
+++ b/include/git2/remote.h
@@ -520,6 +520,17 @@ GIT_EXTERN(int) git_remote_init_callbacks(
GIT_EXTERN(int) git_remote_set_callbacks(git_remote *remote, const git_remote_callbacks *callbacks);
/**
+ * Retrieve the current callback structure
+ *
+ * This provides read access to the callbacks structure as the remote
+ * sees it.
+ *
+ * @param remote the remote to query
+ * @return a pointer to the callbacks structure
+ */
+GIT_EXTERN(const git_remote_callbacks *) git_remote_get_callbacks(git_remote *remote);
+
+/**
* Get the statistics structure that is filled in by the fetch operation.
*/
GIT_EXTERN(const git_transfer_progress *) git_remote_stats(git_remote *remote);
diff --git a/src/remote.c b/src/remote.c
index 243086b..c23a464 100644
--- a/src/remote.c
+++ b/src/remote.c
@@ -1253,6 +1253,13 @@ int git_remote_set_callbacks(git_remote *remote, const git_remote_callbacks *cal
return 0;
}
+const git_remote_callbacks *git_remote_get_callbacks(git_remote *remote)
+{
+ assert(remote);
+
+ return &remote->callbacks;
+}
+
int git_remote_set_transport(git_remote *remote, git_transport *transport)
{
assert(remote && transport);