2 * Copyright (C) the libgit2 contributors. All rights reserved.
4 * This file is part of libgit2, distributed under the GNU GPL v2 with
5 * a Linking Exception. For full terms see the included COPYING file.
7 #ifndef INCLUDE_push_h__
8 #define INCLUDE_push_h__
16 typedef struct push_spec
{
17 struct git_refspec refspec
;
23 typedef struct push_status
{
43 unsigned pb_parallelism
;
44 git_remote_connection_opts connection
;
48 * Free the given push status object
50 * @param status The push status object
52 void git_push_status_free(push_status
*status
);
55 * Create a new push object
57 * @param out New push object
58 * @param remote Remote instance
60 * @return 0 or an error code
62 int git_push_new(git_push
**out
, git_remote
*remote
);
65 * Set options on a push object
67 * @param push The push object
68 * @param opts The options to set on the push object
70 * @return 0 or an error code
72 int git_push_set_options(
74 const git_push_options
*opts
);
77 * Add a refspec to be pushed
79 * @param push The push object
80 * @param refspec Refspec string
82 * @return 0 or an error code
84 int git_push_add_refspec(git_push
*push
, const char *refspec
);
87 * Update remote tips after a push
89 * @param push The push object
90 * @param callbacks the callbacks to use for this connection
92 * @return 0 or an error code
94 int git_push_update_tips(git_push
*push
, const git_remote_callbacks
*callbacks
);
99 * This function will return an error in case of a protocol error or
100 * the server being unable to unpack the data we sent.
102 * The return value does not reflect whether the server accepted or
103 * refused any reference updates. Use `git_push_status_foreach()` in
104 * order to find out which updates were accepted or rejected.
106 * @param push The push object
107 * @param callbacks the callbacks to use for this connection
109 * @return 0 or an error code
111 int git_push_finish(git_push
*push
, const git_remote_callbacks
*callbacks
);
114 * Invoke callback `cb' on each status entry
116 * For each of the updated references, we receive a status report in the
117 * form of `ok refs/heads/master` or `ng refs/heads/master <msg>`.
118 * `msg != NULL` means the reference has not been updated for the given
121 * Return a non-zero value from the callback to stop the loop.
123 * @param push The push object
124 * @param cb The callback to call on each object
125 * @param data The payload passed to the callback
127 * @return 0 on success, non-zero callback return value, or error code
129 int git_push_status_foreach(git_push
*push
,
130 int (*cb
)(const char *ref
, const char *msg
, void *data
),
134 * Free the given push object
136 * @param push The push object
138 void git_push_free(git_push
*push
);