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_callbacks callbacks
;
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
59 * @param opts Push options or NULL
61 * @return 0 or an error code
63 int git_push_new(git_push
**out
, git_remote
*remote
, const git_push_options
*opts
);
66 * Add a refspec to be pushed
68 * @param push The push object
69 * @param refspec Refspec string
71 * @return 0 or an error code
73 int git_push_add_refspec(git_push
*push
, const char *refspec
);
76 * Update remote tips after a push
78 * @param push The push object
79 * @param callbacks the callbacks to use for this connection
81 * @return 0 or an error code
83 int git_push_update_tips(git_push
*push
, const git_remote_callbacks
*callbacks
);
88 * This function will return an error in case of a protocol error or
89 * the server being unable to unpack the data we sent.
91 * The return value does not reflect whether the server accepted or
92 * refused any reference updates. Use `git_push_status_foreach()` in
93 * order to find out which updates were accepted or rejected.
95 * @param push The push object
97 * @return 0 or an error code
99 int git_push_finish(git_push
*push
);
102 * Invoke callback `cb' on each status entry
104 * For each of the updated references, we receive a status report in the
105 * form of `ok refs/heads/master` or `ng refs/heads/master <msg>`.
106 * `msg != NULL` means the reference has not been updated for the given
109 * Return a non-zero value from the callback to stop the loop.
111 * @param push The push object
112 * @param cb The callback to call on each object
113 * @param data The payload passed to the callback
115 * @return 0 on success, non-zero callback return value, or error code
117 int git_push_status_foreach(git_push
*push
,
118 int (*cb
)(const char *ref
, const char *msg
, void *data
),
122 * Free the given push object
124 * @param push The push object
126 void git_push_free(git_push
*push
);