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_transports_smart_h__
8 #define INCLUDE_transports_smart_h__
17 #include "git2/sys/transport.h"
19 #define GIT_SIDE_BAND_DATA 1
20 #define GIT_SIDE_BAND_PROGRESS 2
21 #define GIT_SIDE_BAND_ERROR 3
23 #define GIT_CAP_OFS_DELTA "ofs-delta"
24 #define GIT_CAP_MULTI_ACK "multi_ack"
25 #define GIT_CAP_MULTI_ACK_DETAILED "multi_ack_detailed"
26 #define GIT_CAP_SIDE_BAND "side-band"
27 #define GIT_CAP_SIDE_BAND_64K "side-band-64k"
28 #define GIT_CAP_INCLUDE_TAG "include-tag"
29 #define GIT_CAP_DELETE_REFS "delete-refs"
30 #define GIT_CAP_REPORT_STATUS "report-status"
31 #define GIT_CAP_THIN_PACK "thin-pack"
32 #define GIT_CAP_SYMREF "symref"
33 #define GIT_CAP_WANT_TIP_SHA1 "allow-tip-sha1-in-want"
34 #define GIT_CAP_WANT_REACHABLE_SHA1 "allow-reachable-sha1-in-want"
36 extern bool git_smart__ofs_delta_enabled
;
54 /* Used for multi_ack and multi_ack_detailed */
62 /* This would be a flush pkt */
74 /* This is a pkt-line with some info in it */
85 enum git_ack_status status
;
90 char comment
[GIT_FLEX_ARRAY
];
96 char data
[GIT_FLEX_ARRAY
];
99 typedef git_pkt_data git_pkt_progress
;
104 char error
[GIT_FLEX_ARRAY
];
123 typedef struct transport_smart_caps
{
124 unsigned int common
:1,
127 multi_ack_detailed
:1,
135 want_reachable_sha1
:1;
136 } transport_smart_caps
;
138 typedef int (*packetsize_cb
)(size_t received
, void *payload
);
141 git_transport parent
;
144 git_remote_connect_options connect_opts
;
146 git_smart_subtransport
*wrapped
;
147 git_smart_subtransport_stream
*current_stream
;
148 transport_smart_caps caps
;
152 git_atomic32 cancelled
;
153 packetsize_cb packetsize_cb
;
154 void *packetsize_payload
;
159 char buffer_data
[65536];
162 /* smart_protocol.c */
163 int git_smart__store_refs(transport_smart
*t
, int flushes
);
164 int git_smart__detect_caps(git_pkt_ref
*pkt
, transport_smart_caps
*caps
, git_vector
*symrefs
);
165 int git_smart__push(git_transport
*transport
, git_push
*push
);
167 int git_smart__negotiate_fetch(
168 git_transport
*transport
,
169 git_repository
*repo
,
170 const git_remote_head
* const *refs
,
173 int git_smart__download_pack(
174 git_transport
*transport
,
175 git_repository
*repo
,
176 git_indexer_progress
*stats
);
179 int git_smart__negotiation_step(git_transport
*transport
, void *data
, size_t len
);
180 int git_smart__get_push_stream(transport_smart
*t
, git_smart_subtransport_stream
**out
);
182 int git_smart__update_heads(transport_smart
*t
, git_vector
*symrefs
);
185 int git_pkt_parse_line(git_pkt
**head
, const char **endptr
, const char *line
, size_t linelen
);
186 int git_pkt_buffer_flush(git_str
*buf
);
187 int git_pkt_send_flush(GIT_SOCKET s
);
188 int git_pkt_buffer_done(git_str
*buf
);
189 int git_pkt_buffer_wants(const git_remote_head
* const *refs
, size_t count
, transport_smart_caps
*caps
, git_str
*buf
);
190 int git_pkt_buffer_have(git_oid
*oid
, git_str
*buf
);
191 void git_pkt_free(git_pkt
*pkt
);