]> git.proxmox.com Git - libgit2.git/blob - src/push.h
New upstream version 1.4.3+dfsg.1
[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_callbacks callbacks;
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 * @param opts Push options or NULL
60 *
61 * @return 0 or an error code
62 */
63 int git_push_new(git_push **out, git_remote *remote, const git_push_options *opts);
64
65 /**
66 * Add a refspec to be pushed
67 *
68 * @param push The push object
69 * @param refspec Refspec string
70 *
71 * @return 0 or an error code
72 */
73 int git_push_add_refspec(git_push *push, const char *refspec);
74
75 /**
76 * Update remote tips after a push
77 *
78 * @param push The push object
79 * @param callbacks the callbacks to use for this connection
80 *
81 * @return 0 or an error code
82 */
83 int git_push_update_tips(git_push *push, const git_remote_callbacks *callbacks);
84
85 /**
86 * Perform the push
87 *
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.
90 *
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.
94 *
95 * @param push The push object
96 *
97 * @return 0 or an error code
98 */
99 int git_push_finish(git_push *push);
100
101 /**
102 * Invoke callback `cb' on each status entry
103 *
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
107 * reason.
108 *
109 * Return a non-zero value from the callback to stop the loop.
110 *
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
114 *
115 * @return 0 on success, non-zero callback return value, or error code
116 */
117 int git_push_status_foreach(git_push *push,
118 int (*cb)(const char *ref, const char *msg, void *data),
119 void *data);
120
121 /**
122 * Free the given push object
123 *
124 * @param push The push object
125 */
126 void git_push_free(git_push *push);
127
128 #endif