]> git.proxmox.com Git - libgit2.git/blame - src/transports/smart.h
push: remove own copy of callbacks
[libgit2.git] / src / transports / smart.h
CommitLineData
41fb1ca0 1/*
359fc2d2 2 * Copyright (C) the libgit2 contributors. All rights reserved.
41fb1ca0
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#include "git2.h"
8#include "vector.h"
9#include "netops.h"
10#include "buffer.h"
613d5eb9 11#include "push.h"
c180c065 12#include "git2/sys/transport.h"
41fb1ca0
PK
13
14#define GIT_SIDE_BAND_DATA 1
15#define GIT_SIDE_BAND_PROGRESS 2
16#define GIT_SIDE_BAND_ERROR 3
17
18#define GIT_CAP_OFS_DELTA "ofs-delta"
19#define GIT_CAP_MULTI_ACK "multi_ack"
2f8c481c 20#define GIT_CAP_MULTI_ACK_DETAILED "multi_ack_detailed"
41fb1ca0
PK
21#define GIT_CAP_SIDE_BAND "side-band"
22#define GIT_CAP_SIDE_BAND_64K "side-band-64k"
23#define GIT_CAP_INCLUDE_TAG "include-tag"
613d5eb9
PK
24#define GIT_CAP_DELETE_REFS "delete-refs"
25#define GIT_CAP_REPORT_STATUS "report-status"
b4342b11 26#define GIT_CAP_THIN_PACK "thin-pack"
8156835d 27#define GIT_CAP_SYMREF "symref"
41fb1ca0
PK
28
29enum git_pkt_type {
30 GIT_PKT_CMD,
31 GIT_PKT_FLUSH,
32 GIT_PKT_REF,
33 GIT_PKT_HAVE,
34 GIT_PKT_ACK,
35 GIT_PKT_NAK,
36 GIT_PKT_PACK,
37 GIT_PKT_COMMENT,
38 GIT_PKT_ERR,
39 GIT_PKT_DATA,
40 GIT_PKT_PROGRESS,
613d5eb9
PK
41 GIT_PKT_OK,
42 GIT_PKT_NG,
43 GIT_PKT_UNPACK,
41fb1ca0
PK
44};
45
2f8c481c 46/* Used for multi_ack and mutli_ack_detailed */
41fb1ca0
PK
47enum git_ack_status {
48 GIT_ACK_NONE,
49 GIT_ACK_CONTINUE,
50 GIT_ACK_COMMON,
51 GIT_ACK_READY
52};
53
54/* This would be a flush pkt */
55typedef struct {
56 enum git_pkt_type type;
57} git_pkt;
58
59struct git_pkt_cmd {
60 enum git_pkt_type type;
61 char *cmd;
62 char *path;
63 char *host;
64};
65
66/* This is a pkt-line with some info in it */
67typedef struct {
68 enum git_pkt_type type;
69 git_remote_head head;
70 char *capabilities;
71} git_pkt_ref;
72
73/* Useful later */
74typedef struct {
75 enum git_pkt_type type;
76 git_oid oid;
77 enum git_ack_status status;
78} git_pkt_ack;
79
80typedef struct {
81 enum git_pkt_type type;
82 char comment[GIT_FLEX_ARRAY];
83} git_pkt_comment;
84
85typedef struct {
86 enum git_pkt_type type;
87 int len;
88 char data[GIT_FLEX_ARRAY];
89} git_pkt_data;
90
91typedef git_pkt_data git_pkt_progress;
92
93typedef struct {
94 enum git_pkt_type type;
b8c32580 95 int len;
41fb1ca0
PK
96 char error[GIT_FLEX_ARRAY];
97} git_pkt_err;
98
613d5eb9
PK
99typedef struct {
100 enum git_pkt_type type;
101 char *ref;
102} git_pkt_ok;
103
104typedef struct {
105 enum git_pkt_type type;
106 char *ref;
107 char *msg;
108} git_pkt_ng;
109
110typedef struct {
111 enum git_pkt_type type;
112 int unpack_ok;
113} git_pkt_unpack;
114
41fb1ca0
PK
115typedef struct transport_smart_caps {
116 int common:1,
117 ofs_delta:1,
118 multi_ack: 1,
2f8c481c 119 multi_ack_detailed: 1,
41fb1ca0
PK
120 side_band:1,
121 side_band_64k:1,
613d5eb9
PK
122 include_tag:1,
123 delete_refs:1,
b4342b11
CMN
124 report_status:1,
125 thin_pack:1;
41fb1ca0
PK
126} transport_smart_caps;
127
5b188225 128typedef int (*packetsize_cb)(size_t received, void *payload);
41fb1ca0
PK
129
130typedef struct {
131 git_transport parent;
613d5eb9 132 git_remote *owner;
41fb1ca0 133 char *url;
091361f5 134 git_cred_acquire_cb cred_acquire_cb;
59bccf33 135 void *cred_acquire_payload;
41fb1ca0
PK
136 int direction;
137 int flags;
138 git_transport_message_cb progress_cb;
139 git_transport_message_cb error_cb;
9b940586 140 git_transport_certificate_check_cb certificate_check_cb;
41fb1ca0
PK
141 void *message_cb_payload;
142 git_smart_subtransport *wrapped;
143 git_smart_subtransport_stream *current_stream;
144 transport_smart_caps caps;
145 git_vector refs;
359dce72 146 git_vector heads;
41fb1ca0
PK
147 git_vector common;
148 git_atomic cancelled;
149 packetsize_cb packetsize_cb;
150 void *packetsize_payload;
151 unsigned rpc : 1,
152 have_refs : 1,
153 connected : 1;
154 gitno_buffer buffer;
155 char buffer_data[65536];
156} transport_smart;
157
158/* smart_protocol.c */
159int git_smart__store_refs(transport_smart *t, int flushes);
8156835d 160int git_smart__detect_caps(git_pkt_ref *pkt, transport_smart_caps *caps, git_vector *symrefs);
613d5eb9 161int git_smart__push(git_transport *transport, git_push *push);
41fb1ca0
PK
162
163int git_smart__negotiate_fetch(
164 git_transport *transport,
165 git_repository *repo,
166 const git_remote_head * const *refs,
167 size_t count);
168
169int git_smart__download_pack(
170 git_transport *transport,
171 git_repository *repo,
172 git_transfer_progress *stats,
48e60ae7 173 git_transfer_progress_cb progress_cb,
41fb1ca0
PK
174 void *progress_payload);
175
176/* smart.c */
177int git_smart__negotiation_step(git_transport *transport, void *data, size_t len);
613d5eb9 178int git_smart__get_push_stream(transport_smart *t, git_smart_subtransport_stream **out);
41fb1ca0 179
8156835d 180int git_smart__update_heads(transport_smart *t, git_vector *symrefs);
a6192d7c 181
41fb1ca0
PK
182/* smart_pkt.c */
183int git_pkt_parse_line(git_pkt **head, const char *line, const char **out, size_t len);
184int git_pkt_buffer_flush(git_buf *buf);
185int git_pkt_send_flush(GIT_SOCKET s);
186int git_pkt_buffer_done(git_buf *buf);
187int git_pkt_buffer_wants(const git_remote_head * const *refs, size_t count, transport_smart_caps *caps, git_buf *buf);
188int git_pkt_buffer_have(git_oid *oid, git_buf *buf);
189void git_pkt_free(git_pkt *pkt);