summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorCarlos Martín Nieto <cmn@dwim.me>2015-04-19 00:55:00 +0200
committerCarlos Martín Nieto <cmn@dwim.me>2015-04-19 01:02:29 +0200
commitefc2fec50e3bb725b2b244fdeacfb2dfad6ee78e (patch)
tree996e1ba559244e36596d98b7bb2fe4754ac94ee3 /include
parent4c02d393748d0db382450871ad9ef6898a2ce360 (diff)
downloadlibgit2-efc2fec50e3bb725b2b244fdeacfb2dfad6ee78e.tar.gz
push: report the update plan to the callercmn/negotiation-notify
It can be useful for the caller to know which update commands will be sent to the server before the packfile is pushed up. git does this via the pre-push hook. We don't have hooks, but as it adds introspection into what is happening, we can add a callback which performs the same function.
Diffstat (limited to 'include')
-rw-r--r--include/git2/push.h30
-rw-r--r--include/git2/remote.h6
-rw-r--r--include/git2/types.h1
3 files changed, 37 insertions, 0 deletions
diff --git a/include/git2/push.h b/include/git2/push.h
index ecabff397..3f850453d 100644
--- a/include/git2/push.h
+++ b/include/git2/push.h
@@ -59,6 +59,36 @@ typedef int (*git_push_transfer_progress)(
size_t bytes,
void* payload);
+/**
+ * Represents an update which will be performed on the remote during push
+ */
+typedef struct {
+ /**
+ * The source name of the reference
+ */
+ char *src_refname;
+ /**
+ * The name of the reference to update on the server
+ */
+ char *dst_refname;
+ /**
+ * The current target of the reference
+ */
+ git_oid src;
+ /**
+ * The new target for the reference
+ */
+ git_oid dst;
+} git_push_update;
+
+/**
+ * @param updates an array containing the updates which will be sent
+ * as commands to the destination.
+ * @param len number of elements in `updates`
+ * @param payload Payload provided by the caller
+ */
+typedef int (*git_push_negotiation)(const git_push_update **updates, size_t len, void *payload);
+
/** @} */
GIT_END_DECL
#endif
diff --git a/include/git2/remote.h b/include/git2/remote.h
index f85c38429..6e88a4680 100644
--- a/include/git2/remote.h
+++ b/include/git2/remote.h
@@ -521,6 +521,12 @@ struct git_remote_callbacks {
int (*push_update_reference)(const char *refname, const char *status, void *data);
/**
+ * Called once between the negotiation step and the upload. It
+ * provides information about what updates will be performed.
+ */
+ git_push_negotiation push_negotiation;
+
+ /**
* This will be passed to each of the callbacks in this struct
* as the last parameter.
*/
diff --git a/include/git2/types.h b/include/git2/types.h
index c90ac4776..fdb5f2b09 100644
--- a/include/git2/types.h
+++ b/include/git2/types.h
@@ -273,6 +273,7 @@ typedef int (*git_transfer_progress_cb)(const git_transfer_progress *stats, void
*/
typedef int (*git_transport_message_cb)(const char *str, int len, void *payload);
+
/**
* Type of host certificate structure that is passed to the check callback
*/