]> git.proxmox.com Git - libgit2.git/blob - src/push.h
Refresh patches
[libgit2.git] / src / push.h
1 /*
2 * Copyright (C) the libgit2 contributors. All rights reserved.
3 *
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.
6 */
7 #ifndef INCLUDE_push_h__
8 #define INCLUDE_push_h__
9
10 #include "common.h"
11
12 #include "git2.h"
13 #include "refspec.h"
14 #include "remote.h"
15
16 typedef struct push_spec {
17 struct git_refspec refspec;
18
19 git_oid loid;
20 git_oid roid;
21 } push_spec;
22
23 typedef struct push_status {
24 bool ok;
25
26 char *ref;
27 char *msg;
28 } push_status;
29
30 struct git_push {
31 git_repository *repo;
32 git_packbuilder *pb;
33 git_remote *remote;
34 git_vector specs;
35 git_vector updates;
36 bool report_status;
37
38 /* report-status */
39 bool unpack_ok;
40 git_vector status;
41
42 /* options */
43 unsigned pb_parallelism;
44 git_remote_connection_opts connection;
45 };
46
47 /**
48 * Free the given push status object
49 *
50 * @param status The push status object
51 */
52 void git_push_status_free(push_status *status);
53
54 /**
55 * Create a new push object
56 *
57 * @param out New push object
58 * @param remote Remote instance
59 *
60 * @return 0 or an error code
61 */
62 int git_push_new(git_push **out, git_remote *remote);
63
64 /**
65 * Set options on a push object
66 *
67 * @param push The push object
68 * @param opts The options to set on the push object
69 *
70 * @return 0 or an error code
71 */
72 int git_push_set_options(
73 git_push *push,
74 const git_push_options *opts);
75
76 /**
77 * Add a refspec to be pushed
78 *
79 * @param push The push object
80 * @param refspec Refspec string
81 *
82 * @return 0 or an error code
83 */
84 int git_push_add_refspec(git_push *push, const char *refspec);
85
86 /**
87 * Update remote tips after a push
88 *
89 * @param push The push object
90 * @param callbacks the callbacks to use for this connection
91 *
92 * @return 0 or an error code
93 */
94 int git_push_update_tips(git_push *push, const git_remote_callbacks *callbacks);
95
96 /**
97 * Perform the push
98 *
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.
101 *
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.
105 *
106 * @param push The push object
107 * @param callbacks the callbacks to use for this connection
108 *
109 * @return 0 or an error code
110 */
111 int git_push_finish(git_push *push, const git_remote_callbacks *callbacks);
112
113 /**
114 * Invoke callback `cb' on each status entry
115 *
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
119 * reason.
120 *
121 * Return a non-zero value from the callback to stop the loop.
122 *
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
126 *
127 * @return 0 on success, non-zero callback return value, or error code
128 */
129 int git_push_status_foreach(git_push *push,
130 int (*cb)(const char *ref, const char *msg, void *data),
131 void *data);
132
133 /**
134 * Free the given push object
135 *
136 * @param push The push object
137 */
138 void git_push_free(git_push *push);
139
140 #endif