]>
Commit | Line | Data |
---|---|---|
613d5eb9 | 1 | /* |
359fc2d2 | 2 | * Copyright (C) the libgit2 contributors. All rights reserved. |
613d5eb9 PK |
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 | ||
eae0bfdc PP |
10 | #include "common.h" |
11 | ||
613d5eb9 | 12 | #include "git2.h" |
aad638f3 | 13 | #include "refspec.h" |
ac3d33df | 14 | #include "remote.h" |
613d5eb9 PK |
15 | |
16 | typedef struct push_spec { | |
aad638f3 | 17 | struct git_refspec refspec; |
613d5eb9 PK |
18 | |
19 | git_oid loid; | |
20 | git_oid roid; | |
613d5eb9 PK |
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; | |
efc2fec5 | 35 | git_vector updates; |
613d5eb9 PK |
36 | bool report_status; |
37 | ||
38 | /* report-status */ | |
39 | bool unpack_ok; | |
40 | git_vector status; | |
b8b897bb PK |
41 | |
42 | /* options */ | |
43 | unsigned pb_parallelism; | |
ac3d33df | 44 | git_remote_connection_opts connection; |
613d5eb9 PK |
45 | }; |
46 | ||
20858f6e | 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 | ||
fe794b2e CMN |
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 | ||
fe794b2e CMN |
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 | |
6d8f3a51 | 90 | * @param callbacks the callbacks to use for this connection |
fe794b2e CMN |
91 | * |
92 | * @return 0 or an error code | |
93 | */ | |
8f0104ec | 94 | int git_push_update_tips(git_push *push, const git_remote_callbacks *callbacks); |
fe794b2e CMN |
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 | |
6d8f3a51 | 107 | * @param callbacks the callbacks to use for this connection |
fe794b2e CMN |
108 | * |
109 | * @return 0 or an error code | |
110 | */ | |
8f0104ec | 111 | int git_push_finish(git_push *push, const git_remote_callbacks *callbacks); |
fe794b2e CMN |
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 | |
6d8f3a51 | 125 | * @param data The payload passed to the callback |
fe794b2e CMN |
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 | ||
613d5eb9 | 140 | #endif |