1 #include "git-compat-util.h"
2 #include "git-curl-compat.h"
4 #include "environment.h"
12 #include "run-command.h"
14 #include "string-list.h"
16 #include "credential.h"
17 #include "oid-array.h"
18 #include "send-pack.h"
23 #include "transport.h"
25 #include "write-or-die.h"
27 static struct remote
*remote
;
28 /* always ends with a trailing slash */
29 static struct strbuf url
= STRBUF_INIT
;
35 struct string_list deepen_not
;
36 struct string_list push_options
;
38 unsigned progress
: 1,
39 check_self_contained_and_connected
: 1,
45 /* One of the SEND_PACK_PUSH_CERT_* constants. */
49 /* see documentation of corresponding flag in fetch-pack.h */
55 force_if_includes
: 1;
56 const struct git_hash_algo
*hash_algo
;
58 static struct options options
;
59 static struct string_list cas_options
= STRING_LIST_INIT_DUP
;
61 static int set_option(const char *name
, size_t namelen
, const char *value
)
63 if (!strncmp(name
, "verbosity", namelen
)) {
65 int v
= strtol(value
, &end
, 10);
66 if (value
== end
|| *end
)
68 options
.verbosity
= v
;
71 else if (!strncmp(name
, "progress", namelen
)) {
72 if (!strcmp(value
, "true"))
74 else if (!strcmp(value
, "false"))
80 else if (!strncmp(name
, "depth", namelen
)) {
82 unsigned long v
= strtoul(value
, &end
, 10);
83 if (value
== end
|| *end
)
88 else if (!strncmp(name
, "deepen-since", namelen
)) {
89 options
.deepen_since
= xstrdup(value
);
92 else if (!strncmp(name
, "deepen-not", namelen
)) {
93 string_list_append(&options
.deepen_not
, value
);
96 else if (!strncmp(name
, "deepen-relative", namelen
)) {
97 if (!strcmp(value
, "true"))
98 options
.deepen_relative
= 1;
99 else if (!strcmp(value
, "false"))
100 options
.deepen_relative
= 0;
105 else if (!strncmp(name
, "followtags", namelen
)) {
106 if (!strcmp(value
, "true"))
107 options
.followtags
= 1;
108 else if (!strcmp(value
, "false"))
109 options
.followtags
= 0;
114 else if (!strncmp(name
, "dry-run", namelen
)) {
115 if (!strcmp(value
, "true"))
117 else if (!strcmp(value
, "false"))
123 else if (!strncmp(name
, "check-connectivity", namelen
)) {
124 if (!strcmp(value
, "true"))
125 options
.check_self_contained_and_connected
= 1;
126 else if (!strcmp(value
, "false"))
127 options
.check_self_contained_and_connected
= 0;
132 else if (!strncmp(name
, "cas", namelen
)) {
133 struct strbuf val
= STRBUF_INIT
;
134 strbuf_addstr(&val
, "--force-with-lease=");
136 strbuf_addstr(&val
, value
);
137 else if (unquote_c_style(&val
, value
, NULL
))
139 string_list_append(&cas_options
, val
.buf
);
140 strbuf_release(&val
);
142 } else if (!strncmp(name
, TRANS_OPT_FORCE_IF_INCLUDES
, namelen
)) {
143 if (!strcmp(value
, "true"))
144 options
.force_if_includes
= 1;
145 else if (!strcmp(value
, "false"))
146 options
.force_if_includes
= 0;
150 } else if (!strncmp(name
, "cloning", namelen
)) {
151 if (!strcmp(value
, "true"))
153 else if (!strcmp(value
, "false"))
158 } else if (!strncmp(name
, "update-shallow", namelen
)) {
159 if (!strcmp(value
, "true"))
160 options
.update_shallow
= 1;
161 else if (!strcmp(value
, "false"))
162 options
.update_shallow
= 0;
166 } else if (!strncmp(name
, "pushcert", namelen
)) {
167 if (!strcmp(value
, "true"))
168 options
.push_cert
= SEND_PACK_PUSH_CERT_ALWAYS
;
169 else if (!strcmp(value
, "false"))
170 options
.push_cert
= SEND_PACK_PUSH_CERT_NEVER
;
171 else if (!strcmp(value
, "if-asked"))
172 options
.push_cert
= SEND_PACK_PUSH_CERT_IF_ASKED
;
176 } else if (!strncmp(name
, "atomic", namelen
)) {
177 if (!strcmp(value
, "true"))
179 else if (!strcmp(value
, "false"))
184 } else if (!strncmp(name
, "push-option", namelen
)) {
186 string_list_append(&options
.push_options
, value
);
188 struct strbuf unquoted
= STRBUF_INIT
;
189 if (unquote_c_style(&unquoted
, value
, NULL
) < 0)
190 die(_("invalid quoting in push-option value: '%s'"), value
);
191 string_list_append_nodup(&options
.push_options
,
192 strbuf_detach(&unquoted
, NULL
));
195 } else if (!strncmp(name
, "family", namelen
)) {
196 if (!strcmp(value
, "ipv4"))
197 git_curl_ipresolve
= CURL_IPRESOLVE_V4
;
198 else if (!strcmp(value
, "ipv6"))
199 git_curl_ipresolve
= CURL_IPRESOLVE_V6
;
200 else if (!strcmp(value
, "all"))
201 git_curl_ipresolve
= CURL_IPRESOLVE_WHATEVER
;
205 } else if (!strncmp(name
, "from-promisor", namelen
)) {
206 options
.from_promisor
= 1;
208 } else if (!strncmp(name
, "refetch", namelen
)) {
211 } else if (!strncmp(name
, "filter", namelen
)) {
212 options
.filter
= xstrdup(value
);
214 } else if (!strncmp(name
, "object-format", namelen
)) {
215 options
.object_format
= 1;
216 if (strcmp(value
, "true"))
217 die(_("unknown value for object-format: %s"), value
);
220 return 1 /* unsupported */;
230 struct oid_array shallow
;
231 enum protocol_version version
;
232 unsigned proto_git
: 1;
234 static struct discovery
*last_discovery
;
236 static struct ref
*parse_git_refs(struct discovery
*heads
, int for_push
)
238 struct ref
*list
= NULL
;
239 struct packet_reader reader
;
241 packet_reader_init(&reader
, -1, heads
->buf
, heads
->len
,
242 PACKET_READ_CHOMP_NEWLINE
|
243 PACKET_READ_GENTLE_ON_EOF
|
244 PACKET_READ_DIE_ON_ERR_PACKET
);
246 heads
->version
= discover_version(&reader
);
247 switch (heads
->version
) {
250 * Do nothing. This isn't a list of refs but rather a
251 * capability advertisement. Client would have run
252 * 'stateless-connect' so we'll dump this capability listing
253 * and let them request the refs themselves.
258 get_remote_heads(&reader
, &list
, for_push
? REF_NORMAL
: 0,
259 NULL
, &heads
->shallow
);
260 options
.hash_algo
= reader
.hash_algo
;
262 case protocol_unknown_version
:
263 BUG("unknown protocol version");
270 * Try to detect the hash algorithm used by the remote repository when using
271 * the dumb HTTP transport. As dumb transports cannot tell us the object hash
272 * directly have to derive it from the advertised ref lengths.
274 static const struct git_hash_algo
*detect_hash_algo(struct discovery
*heads
)
276 const char *p
= memchr(heads
->buf
, '\t', heads
->len
);
280 * In case the remote has no refs we have no way to reliably determine
281 * the object hash used by that repository. In that case we simply fall
282 * back to SHA1, which may or may not be correct.
285 return &hash_algos
[GIT_HASH_SHA1
];
287 algo
= hash_algo_by_length((p
- heads
->buf
) / 2);
288 if (algo
== GIT_HASH_UNKNOWN
)
290 return &hash_algos
[algo
];
293 static struct ref
*parse_info_refs(struct discovery
*heads
)
295 char *data
, *start
, *mid
;
299 struct ref
*refs
= NULL
;
300 struct ref
*ref
= NULL
;
301 struct ref
*last_ref
= NULL
;
303 options
.hash_algo
= detect_hash_algo(heads
);
304 if (!options
.hash_algo
)
305 die("%sinfo/refs not valid: could not determine hash algorithm; "
306 "is this a git repository?",
307 transport_anonymize_url(url
.buf
));
310 * Set the repository's hash algo to whatever we have just detected.
311 * This ensures that we can correctly parse the remote references.
313 repo_set_hash_algo(the_repository
, hash_algo_by_ptr(options
.hash_algo
));
318 while (i
< heads
->len
) {
324 if (data
[i
] == '\n') {
325 if (mid
- start
!= options
.hash_algo
->hexsz
)
326 die(_("%sinfo/refs not valid: is this a git repository?"),
327 transport_anonymize_url(url
.buf
));
330 ref
= alloc_ref(ref_name
);
331 get_oid_hex_algop(start
, &ref
->old_oid
, options
.hash_algo
);
335 last_ref
->next
= ref
;
342 ref
= alloc_ref("HEAD");
343 if (!http_fetch_ref(url
.buf
, ref
) &&
344 !resolve_remote_symref(ref
, refs
)) {
354 static void free_discovery(struct discovery
*d
)
357 if (d
== last_discovery
)
358 last_discovery
= NULL
;
359 free(d
->shallow
.oid
);
367 static int show_http_message(struct strbuf
*type
, struct strbuf
*charset
,
373 * We only show text/plain parts, as other types are likely
374 * to be ugly to look at on the user's terminal.
376 if (strcmp(type
->buf
, "text/plain"))
379 strbuf_reencode(msg
, charset
->buf
, get_log_output_encoding());
387 eol
= strchrnul(p
, '\n');
388 fprintf(stderr
, "remote: %.*s\n", (int)(eol
- p
), p
);
394 static int get_protocol_http_header(enum protocol_version version
,
395 struct strbuf
*header
)
398 strbuf_addf(header
, GIT_PROTOCOL_HEADER
": version=%d",
407 static void check_smart_http(struct discovery
*d
, const char *service
,
411 struct packet_reader reader
;
414 * If we don't see x-$service-advertisement, then it's not smart-http.
415 * But once we do, we commit to it and assume any other protocol
416 * violations are hard errors.
418 if (!skip_prefix(type
->buf
, "application/x-", &p
) ||
419 !skip_prefix(p
, service
, &p
) ||
420 strcmp(p
, "-advertisement"))
423 packet_reader_init(&reader
, -1, d
->buf
, d
->len
,
424 PACKET_READ_CHOMP_NEWLINE
|
425 PACKET_READ_DIE_ON_ERR_PACKET
);
426 if (packet_reader_read(&reader
) != PACKET_READ_NORMAL
)
427 die(_("invalid server response; expected service, got flush packet"));
429 if (skip_prefix(reader
.line
, "# service=", &p
) && !strcmp(p
, service
)) {
431 * The header can include additional metadata lines, up
432 * until a packet flush marker. Ignore these now, but
433 * in the future we might start to scan them.
436 packet_reader_read(&reader
);
437 if (reader
.pktlen
<= 0) {
443 * v0 smart http; callers expect us to soak up the
444 * service and header packets
446 d
->buf
= reader
.src_buffer
;
447 d
->len
= reader
.src_len
;
450 } else if (!strcmp(reader
.line
, "version 2")) {
452 * v2 smart http; do not consume version packet, which will
453 * be handled elsewhere.
458 die(_("invalid server response; got '%s'"), reader
.line
);
462 static struct discovery
*discover_refs(const char *service
, int for_push
)
464 struct strbuf type
= STRBUF_INIT
;
465 struct strbuf charset
= STRBUF_INIT
;
466 struct strbuf buffer
= STRBUF_INIT
;
467 struct strbuf refs_url
= STRBUF_INIT
;
468 struct strbuf effective_url
= STRBUF_INIT
;
469 struct strbuf protocol_header
= STRBUF_INIT
;
470 struct string_list extra_headers
= STRING_LIST_INIT_DUP
;
471 struct discovery
*last
= last_discovery
;
472 int http_ret
, maybe_smart
= 0;
473 struct http_get_options http_options
;
474 enum protocol_version version
= get_protocol_version_config();
476 if (last
&& !strcmp(service
, last
->service
))
478 free_discovery(last
);
480 strbuf_addf(&refs_url
, "%sinfo/refs", url
.buf
);
481 if ((starts_with(url
.buf
, "http://") || starts_with(url
.buf
, "https://")) &&
482 git_env_bool("GIT_SMART_HTTP", 1)) {
484 if (!strchr(url
.buf
, '?'))
485 strbuf_addch(&refs_url
, '?');
487 strbuf_addch(&refs_url
, '&');
488 strbuf_addf(&refs_url
, "service=%s", service
);
492 * NEEDSWORK: If we are trying to use protocol v2 and we are planning
493 * to perform any operation that doesn't involve upload-pack (i.e., a
494 * fetch, ls-remote, etc), then fallback to v0 since we don't know how
495 * to do anything else (like push or remote archive) via v2.
497 if (version
== protocol_v2
&& strcmp("git-upload-pack", service
))
498 version
= protocol_v0
;
500 /* Add the extra Git-Protocol header */
501 if (get_protocol_http_header(version
, &protocol_header
))
502 string_list_append(&extra_headers
, protocol_header
.buf
);
504 memset(&http_options
, 0, sizeof(http_options
));
505 http_options
.content_type
= &type
;
506 http_options
.charset
= &charset
;
507 http_options
.effective_url
= &effective_url
;
508 http_options
.base_url
= &url
;
509 http_options
.extra_headers
= &extra_headers
;
510 http_options
.initial_request
= 1;
511 http_options
.no_cache
= 1;
513 http_ret
= http_get_strbuf(refs_url
.buf
, &buffer
, &http_options
);
517 case HTTP_MISSING_TARGET
:
518 show_http_message(&type
, &charset
, &buffer
);
519 die(_("repository '%s' not found"),
520 transport_anonymize_url(url
.buf
));
522 show_http_message(&type
, &charset
, &buffer
);
523 die(_("Authentication failed for '%s'"),
524 transport_anonymize_url(url
.buf
));
525 case HTTP_NOMATCHPUBLICKEY
:
526 show_http_message(&type
, &charset
, &buffer
);
527 die(_("unable to access '%s' with http.pinnedPubkey configuration: %s"),
528 transport_anonymize_url(url
.buf
), curl_errorstr
);
530 show_http_message(&type
, &charset
, &buffer
);
531 die(_("unable to access '%s': %s"),
532 transport_anonymize_url(url
.buf
), curl_errorstr
);
535 if (options
.verbosity
&& !starts_with(refs_url
.buf
, url
.buf
)) {
536 char *u
= transport_anonymize_url(url
.buf
);
537 warning(_("redirecting to %s"), u
);
541 last
= xcalloc(1, sizeof(*last_discovery
));
542 last
->service
= xstrdup(service
);
543 last
->buf_alloc
= strbuf_detach(&buffer
, &last
->len
);
544 last
->buf
= last
->buf_alloc
;
547 check_smart_http(last
, service
, &type
);
550 last
->refs
= parse_git_refs(last
, for_push
);
552 last
->refs
= parse_info_refs(last
);
554 strbuf_release(&refs_url
);
555 strbuf_release(&type
);
556 strbuf_release(&charset
);
557 strbuf_release(&effective_url
);
558 strbuf_release(&buffer
);
559 strbuf_release(&protocol_header
);
560 string_list_clear(&extra_headers
, 0);
561 last_discovery
= last
;
565 static struct ref
*get_refs(int for_push
)
567 struct discovery
*heads
;
570 heads
= discover_refs("git-receive-pack", for_push
);
572 heads
= discover_refs("git-upload-pack", for_push
);
577 static void output_refs(struct ref
*refs
)
580 if (options
.object_format
&& options
.hash_algo
) {
581 printf(":object-format %s\n", options
.hash_algo
->name
);
582 repo_set_hash_algo(the_repository
,
583 hash_algo_by_ptr(options
.hash_algo
));
585 for (posn
= refs
; posn
; posn
= posn
->next
) {
587 printf("@%s %s\n", posn
->symref
, posn
->name
);
589 printf("%s %s\n", hash_to_hex_algop(posn
->old_oid
.hash
,
598 const char *service_name
;
600 char *hdr_content_type
;
602 char *hdr_accept_language
;
603 char *protocol_header
;
611 unsigned gzip_request
: 1;
612 unsigned initial_buffer
: 1;
615 * Whenever a pkt-line is read into buf, append the 4 characters
616 * denoting its length before appending the payload.
618 unsigned write_line_lengths
: 1;
621 * Used by rpc_out; initialize to 0. This is true if a flush has been
622 * read, but the corresponding line length (if write_line_lengths is
623 * true) and EOF have not been sent to libcurl. Since each flush marks
624 * the end of a request, each flush must be completely sent before any
625 * further reading occurs.
627 unsigned flush_read_but_not_sent
: 1;
630 #define RPC_STATE_INIT { 0 }
633 * Appends the result of reading from rpc->out to the string represented by
634 * rpc->buf and rpc->len if there is enough space. Returns 1 if there was
635 * enough space, 0 otherwise.
637 * If rpc->write_line_lengths is true, appends the line length as a 4-byte
638 * hexadecimal string before appending the result described above.
640 * Writes the total number of bytes appended into appended.
642 static int rpc_read_from_out(struct rpc_state
*rpc
, int options
,
644 enum packet_read_status
*status
) {
649 if (rpc
->write_line_lengths
) {
650 left
= rpc
->alloc
- rpc
->len
- 4;
651 buf
= rpc
->buf
+ rpc
->len
+ 4;
653 left
= rpc
->alloc
- rpc
->len
;
654 buf
= rpc
->buf
+ rpc
->len
;
657 if (left
< LARGE_PACKET_MAX
)
660 *status
= packet_read_with_status(rpc
->out
, NULL
, NULL
, buf
,
661 left
, &pktlen_raw
, options
);
662 if (*status
!= PACKET_READ_EOF
) {
663 *appended
= pktlen_raw
+ (rpc
->write_line_lengths
? 4 : 0);
664 rpc
->len
+= *appended
;
667 if (rpc
->write_line_lengths
) {
669 case PACKET_READ_EOF
:
670 if (!(options
& PACKET_READ_GENTLE_ON_EOF
))
671 die(_("shouldn't have EOF when not gentle on EOF"));
673 case PACKET_READ_NORMAL
:
674 set_packet_header(buf
- 4, *appended
);
676 case PACKET_READ_DELIM
:
677 memcpy(buf
- 4, "0001", 4);
679 case PACKET_READ_FLUSH
:
680 memcpy(buf
- 4, "0000", 4);
682 case PACKET_READ_RESPONSE_END
:
683 die(_("remote server sent unexpected response end packet"));
690 static size_t rpc_out(void *ptr
, size_t eltsize
,
691 size_t nmemb
, void *buffer_
)
693 size_t max
= eltsize
* nmemb
;
694 struct rpc_state
*rpc
= buffer_
;
695 size_t avail
= rpc
->len
- rpc
->pos
;
696 enum packet_read_status status
;
699 rpc
->initial_buffer
= 0;
702 if (!rpc
->flush_read_but_not_sent
) {
703 if (!rpc_read_from_out(rpc
, 0, &avail
, &status
))
704 BUG("The entire rpc->buf should be larger than LARGE_PACKET_MAX");
705 if (status
== PACKET_READ_FLUSH
)
706 rpc
->flush_read_but_not_sent
= 1;
709 * If flush_read_but_not_sent is true, we have already read one
710 * full request but have not fully sent it + EOF, which is why
711 * we need to refrain from reading.
714 if (rpc
->flush_read_but_not_sent
) {
717 * The line length either does not need to be sent at
718 * all or has already been completely sent. Now we can
719 * return 0, indicating EOF, meaning that the flush has
722 rpc
->flush_read_but_not_sent
= 0;
726 * If avail is non-zero, the line length for the flush still
727 * hasn't been fully sent. Proceed with sending the line
734 memcpy(ptr
, rpc
->buf
+ rpc
->pos
, avail
);
739 static int rpc_seek(void *clientp
, curl_off_t offset
, int origin
)
741 struct rpc_state
*rpc
= clientp
;
743 if (origin
!= SEEK_SET
)
744 BUG("rpc_seek only handles SEEK_SET, not %d", origin
);
746 if (rpc
->initial_buffer
) {
747 if (offset
< 0 || offset
> rpc
->len
) {
748 error("curl seek would be outside of rpc buffer");
749 return CURL_SEEKFUNC_FAIL
;
752 return CURL_SEEKFUNC_OK
;
754 error(_("unable to rewind rpc post data - try increasing http.postBuffer"));
755 return CURL_SEEKFUNC_FAIL
;
758 struct check_pktline_state
{
764 static void check_pktline(struct check_pktline_state
*state
, const char *ptr
, size_t size
)
767 if (!state
->remaining
) {
768 int digits_remaining
= 4 - state
->len_filled
;
769 if (digits_remaining
> size
)
770 digits_remaining
= size
;
771 memcpy(&state
->len_buf
[state
->len_filled
], ptr
, digits_remaining
);
772 state
->len_filled
+= digits_remaining
;
773 ptr
+= digits_remaining
;
774 size
-= digits_remaining
;
776 if (state
->len_filled
== 4) {
777 state
->remaining
= packet_length(state
->len_buf
,
778 sizeof(state
->len_buf
));
779 if (state
->remaining
< 0) {
780 die(_("remote-curl: bad line length character: %.4s"), state
->len_buf
);
781 } else if (state
->remaining
== 2) {
782 die(_("remote-curl: unexpected response end packet"));
783 } else if (state
->remaining
< 4) {
784 state
->remaining
= 0;
786 state
->remaining
-= 4;
788 state
->len_filled
= 0;
792 if (state
->remaining
) {
793 int remaining
= state
->remaining
;
794 if (remaining
> size
)
798 state
->remaining
-= remaining
;
804 struct rpc_state
*rpc
;
805 struct active_request_slot
*slot
;
807 struct check_pktline_state pktline_state
;
811 * A callback for CURLOPT_WRITEFUNCTION. The return value is the bytes consumed
814 static size_t rpc_in(char *ptr
, size_t eltsize
,
815 size_t nmemb
, void *buffer_
)
817 size_t size
= eltsize
* nmemb
;
818 struct rpc_in_data
*data
= buffer_
;
821 if (curl_easy_getinfo(data
->slot
->curl
, CURLINFO_RESPONSE_CODE
,
822 &response_code
) != CURLE_OK
)
824 if (response_code
>= 300)
827 data
->rpc
->any_written
= 1;
828 if (data
->check_pktline
)
829 check_pktline(&data
->pktline_state
, ptr
, size
);
830 write_or_die(data
->rpc
->in
, ptr
, size
);
834 static int run_slot(struct active_request_slot
*slot
,
835 struct slot_results
*results
)
838 struct slot_results results_buf
;
841 results
= &results_buf
;
843 err
= run_one_slot(slot
, results
);
845 if (err
!= HTTP_OK
&& err
!= HTTP_REAUTH
) {
846 struct strbuf msg
= STRBUF_INIT
;
847 if (results
->http_code
&& results
->http_code
!= 200)
848 strbuf_addf(&msg
, "HTTP %ld", results
->http_code
);
849 if (results
->curl_result
!= CURLE_OK
) {
851 strbuf_addch(&msg
, ' ');
852 strbuf_addf(&msg
, "curl %d", results
->curl_result
);
853 if (curl_errorstr
[0]) {
854 strbuf_addch(&msg
, ' ');
855 strbuf_addstr(&msg
, curl_errorstr
);
858 error(_("RPC failed; %s"), msg
.buf
);
859 strbuf_release(&msg
);
865 static int probe_rpc(struct rpc_state
*rpc
, struct slot_results
*results
)
867 struct active_request_slot
*slot
;
868 struct curl_slist
*headers
= http_copy_default_headers();
869 struct strbuf buf
= STRBUF_INIT
;
872 slot
= get_active_slot();
874 headers
= curl_slist_append(headers
, rpc
->hdr_content_type
);
875 headers
= curl_slist_append(headers
, rpc
->hdr_accept
);
877 curl_easy_setopt(slot
->curl
, CURLOPT_NOBODY
, 0);
878 curl_easy_setopt(slot
->curl
, CURLOPT_POST
, 1);
879 curl_easy_setopt(slot
->curl
, CURLOPT_URL
, rpc
->service_url
);
880 curl_easy_setopt(slot
->curl
, CURLOPT_ENCODING
, NULL
);
881 curl_easy_setopt(slot
->curl
, CURLOPT_POSTFIELDS
, "0000");
882 curl_easy_setopt(slot
->curl
, CURLOPT_POSTFIELDSIZE
, 4);
883 curl_easy_setopt(slot
->curl
, CURLOPT_HTTPHEADER
, headers
);
884 curl_easy_setopt(slot
->curl
, CURLOPT_WRITEFUNCTION
, fwrite_buffer
);
885 curl_easy_setopt(slot
->curl
, CURLOPT_WRITEDATA
, &buf
);
887 err
= run_slot(slot
, results
);
889 curl_slist_free_all(headers
);
890 strbuf_release(&buf
);
894 static curl_off_t
xcurl_off_t(size_t len
)
896 uintmax_t size
= len
;
897 if (size
> maximum_signed_value_of_type(curl_off_t
))
898 die(_("cannot handle pushes this big"));
899 return (curl_off_t
)size
;
903 * If flush_received is true, do not attempt to read any more; just use what's
906 static int post_rpc(struct rpc_state
*rpc
, int stateless_connect
, int flush_received
)
908 struct active_request_slot
*slot
;
909 struct curl_slist
*headers
= NULL
;
910 int use_gzip
= rpc
->gzip_request
;
911 char *gzip_body
= NULL
;
912 size_t gzip_size
= 0;
913 int err
, large_request
= 0;
914 int needs_100_continue
= 0;
915 struct rpc_in_data rpc_in_data
;
917 /* Try to load the entire request, if we can fit it into the
918 * allocated buffer space we can use HTTP/1.0 and avoid the
919 * chunked encoding mess.
921 if (!flush_received
) {
924 enum packet_read_status status
;
926 if (!rpc_read_from_out(rpc
, 0, &n
, &status
)) {
931 if (status
== PACKET_READ_FLUSH
)
937 struct slot_results results
;
940 err
= probe_rpc(rpc
, &results
);
941 if (err
== HTTP_REAUTH
)
942 credential_fill(&http_auth
, 0);
943 } while (err
== HTTP_REAUTH
);
947 if (results
.auth_avail
& CURLAUTH_GSSNEGOTIATE
|| http_auth
.authtype
)
948 needs_100_continue
= 1;
952 headers
= http_copy_default_headers();
953 headers
= curl_slist_append(headers
, rpc
->hdr_content_type
);
954 headers
= curl_slist_append(headers
, rpc
->hdr_accept
);
955 headers
= curl_slist_append(headers
, needs_100_continue
?
956 "Expect: 100-continue" : "Expect:");
958 headers
= http_append_auth_header(&http_auth
, headers
);
960 /* Add Accept-Language header */
961 if (rpc
->hdr_accept_language
)
962 headers
= curl_slist_append(headers
, rpc
->hdr_accept_language
);
964 /* Add the extra Git-Protocol header */
965 if (rpc
->protocol_header
)
966 headers
= curl_slist_append(headers
, rpc
->protocol_header
);
968 slot
= get_active_slot();
970 curl_easy_setopt(slot
->curl
, CURLOPT_NOBODY
, 0);
971 curl_easy_setopt(slot
->curl
, CURLOPT_POST
, 1);
972 curl_easy_setopt(slot
->curl
, CURLOPT_URL
, rpc
->service_url
);
973 curl_easy_setopt(slot
->curl
, CURLOPT_ENCODING
, "");
976 /* The request body is large and the size cannot be predicted.
977 * We must use chunked encoding to send it.
979 #ifdef GIT_CURL_NEED_TRANSFER_ENCODING_HEADER
980 headers
= curl_slist_append(headers
, "Transfer-Encoding: chunked");
982 rpc
->initial_buffer
= 1;
983 curl_easy_setopt(slot
->curl
, CURLOPT_READFUNCTION
, rpc_out
);
984 curl_easy_setopt(slot
->curl
, CURLOPT_INFILE
, rpc
);
985 curl_easy_setopt(slot
->curl
, CURLOPT_SEEKFUNCTION
, rpc_seek
);
986 curl_easy_setopt(slot
->curl
, CURLOPT_SEEKDATA
, rpc
);
987 if (options
.verbosity
> 1) {
988 fprintf(stderr
, "POST %s (chunked)\n", rpc
->service_name
);
992 } else if (gzip_body
) {
994 * If we are looping to retry authentication, then the previous
995 * run will have set up the headers and gzip buffer already,
996 * and we just need to send it.
998 curl_easy_setopt(slot
->curl
, CURLOPT_POSTFIELDS
, gzip_body
);
999 curl_easy_setopt(slot
->curl
, CURLOPT_POSTFIELDSIZE_LARGE
, xcurl_off_t(gzip_size
));
1001 } else if (use_gzip
&& 1024 < rpc
->len
) {
1002 /* The client backend isn't giving us compressed data so
1003 * we can try to deflate it ourselves, this may save on
1004 * the transfer time.
1009 git_deflate_init_gzip(&stream
, Z_BEST_COMPRESSION
);
1010 gzip_size
= git_deflate_bound(&stream
, rpc
->len
);
1011 gzip_body
= xmalloc(gzip_size
);
1013 stream
.next_in
= (unsigned char *)rpc
->buf
;
1014 stream
.avail_in
= rpc
->len
;
1015 stream
.next_out
= (unsigned char *)gzip_body
;
1016 stream
.avail_out
= gzip_size
;
1018 ret
= git_deflate(&stream
, Z_FINISH
);
1019 if (ret
!= Z_STREAM_END
)
1020 die(_("cannot deflate request; zlib deflate error %d"), ret
);
1022 ret
= git_deflate_end_gently(&stream
);
1024 die(_("cannot deflate request; zlib end error %d"), ret
);
1026 gzip_size
= stream
.total_out
;
1028 headers
= curl_slist_append(headers
, "Content-Encoding: gzip");
1029 curl_easy_setopt(slot
->curl
, CURLOPT_POSTFIELDS
, gzip_body
);
1030 curl_easy_setopt(slot
->curl
, CURLOPT_POSTFIELDSIZE_LARGE
, xcurl_off_t(gzip_size
));
1032 if (options
.verbosity
> 1) {
1033 fprintf(stderr
, "POST %s (gzip %lu to %lu bytes)\n",
1035 (unsigned long)rpc
->len
, (unsigned long)gzip_size
);
1039 /* We know the complete request size in advance, use the
1040 * more normal Content-Length approach.
1042 curl_easy_setopt(slot
->curl
, CURLOPT_POSTFIELDS
, rpc
->buf
);
1043 curl_easy_setopt(slot
->curl
, CURLOPT_POSTFIELDSIZE_LARGE
, xcurl_off_t(rpc
->len
));
1044 if (options
.verbosity
> 1) {
1045 fprintf(stderr
, "POST %s (%lu bytes)\n",
1046 rpc
->service_name
, (unsigned long)rpc
->len
);
1051 curl_easy_setopt(slot
->curl
, CURLOPT_HTTPHEADER
, headers
);
1052 curl_easy_setopt(slot
->curl
, CURLOPT_WRITEFUNCTION
, rpc_in
);
1053 rpc_in_data
.rpc
= rpc
;
1054 rpc_in_data
.slot
= slot
;
1055 rpc_in_data
.check_pktline
= stateless_connect
;
1056 memset(&rpc_in_data
.pktline_state
, 0, sizeof(rpc_in_data
.pktline_state
));
1057 curl_easy_setopt(slot
->curl
, CURLOPT_WRITEDATA
, &rpc_in_data
);
1058 curl_easy_setopt(slot
->curl
, CURLOPT_FAILONERROR
, 0);
1061 rpc
->any_written
= 0;
1062 err
= run_slot(slot
, NULL
);
1063 if (err
== HTTP_REAUTH
&& !large_request
) {
1064 credential_fill(&http_auth
, 0);
1065 curl_slist_free_all(headers
);
1071 if (!rpc
->any_written
)
1074 if (rpc_in_data
.pktline_state
.len_filled
)
1075 err
= error(_("%d bytes of length header were received"), rpc_in_data
.pktline_state
.len_filled
);
1076 if (rpc_in_data
.pktline_state
.remaining
)
1077 err
= error(_("%d bytes of body are still expected"), rpc_in_data
.pktline_state
.remaining
);
1079 if (stateless_connect
)
1080 packet_response_end(rpc
->in
);
1082 curl_slist_free_all(headers
);
1087 static int rpc_service(struct rpc_state
*rpc
, struct discovery
*heads
,
1088 const char **client_argv
, const struct strbuf
*preamble
,
1089 struct strbuf
*rpc_result
)
1091 const char *svc
= rpc
->service_name
;
1092 struct strbuf buf
= STRBUF_INIT
;
1093 struct child_process client
= CHILD_PROCESS_INIT
;
1099 strvec_pushv(&client
.args
, client_argv
);
1100 if (start_command(&client
))
1102 write_or_die(client
.in
, preamble
->buf
, preamble
->len
);
1104 write_or_die(client
.in
, heads
->buf
, heads
->len
);
1106 rpc
->alloc
= http_post_buffer
;
1107 rpc
->buf
= xmalloc(rpc
->alloc
);
1108 rpc
->in
= client
.in
;
1109 rpc
->out
= client
.out
;
1111 strbuf_addf(&buf
, "%s%s", url
.buf
, svc
);
1112 rpc
->service_url
= strbuf_detach(&buf
, NULL
);
1114 rpc
->hdr_accept_language
= xstrdup_or_null(http_get_accept_language_header());
1116 strbuf_addf(&buf
, "Content-Type: application/x-%s-request", svc
);
1117 rpc
->hdr_content_type
= strbuf_detach(&buf
, NULL
);
1119 strbuf_addf(&buf
, "Accept: application/x-%s-result", svc
);
1120 rpc
->hdr_accept
= strbuf_detach(&buf
, NULL
);
1122 if (get_protocol_http_header(heads
->version
, &buf
))
1123 rpc
->protocol_header
= strbuf_detach(&buf
, NULL
);
1125 rpc
->protocol_header
= NULL
;
1128 int n
= packet_read(rpc
->out
, rpc
->buf
, rpc
->alloc
, 0);
1133 err
|= post_rpc(rpc
, 0, 0);
1139 strbuf_read(rpc_result
, client
.out
, 0);
1143 if (xread(client
.out
, buf
, sizeof(buf
)) <= 0)
1150 err
|= finish_command(&client
);
1151 free(rpc
->service_url
);
1152 free(rpc
->hdr_content_type
);
1153 free(rpc
->hdr_accept
);
1154 free(rpc
->hdr_accept_language
);
1155 free(rpc
->protocol_header
);
1157 strbuf_release(&buf
);
1161 static int fetch_dumb(int nr_heads
, struct ref
**to_fetch
)
1163 struct walker
*walker
;
1167 ALLOC_ARRAY(targets
, nr_heads
);
1168 if (options
.depth
|| options
.deepen_since
)
1169 die(_("dumb http transport does not support shallow capabilities"));
1170 for (i
= 0; i
< nr_heads
; i
++)
1171 targets
[i
] = xstrdup(oid_to_hex(&to_fetch
[i
]->old_oid
));
1173 walker
= get_http_walker(url
.buf
);
1174 walker
->get_verbosely
= options
.verbosity
>= 3;
1175 walker
->get_progress
= options
.progress
;
1176 walker
->get_recover
= 0;
1177 ret
= walker_fetch(walker
, nr_heads
, targets
, NULL
, NULL
);
1178 walker_free(walker
);
1180 for (i
= 0; i
< nr_heads
; i
++)
1184 return ret
? error(_("fetch failed.")) : 0;
1187 static int fetch_git(struct discovery
*heads
,
1188 int nr_heads
, struct ref
**to_fetch
)
1190 struct rpc_state rpc
= RPC_STATE_INIT
;
1191 struct strbuf preamble
= STRBUF_INIT
;
1193 struct strvec args
= STRVEC_INIT
;
1194 struct strbuf rpc_result
= STRBUF_INIT
;
1196 strvec_pushl(&args
, "fetch-pack", "--stateless-rpc",
1197 "--stdin", "--lock-pack", NULL
);
1198 if (options
.followtags
)
1199 strvec_push(&args
, "--include-tag");
1201 strvec_push(&args
, "--thin");
1202 if (options
.verbosity
>= 3)
1203 strvec_pushl(&args
, "-v", "-v", NULL
);
1204 if (options
.check_self_contained_and_connected
)
1205 strvec_push(&args
, "--check-self-contained-and-connected");
1206 if (options
.cloning
)
1207 strvec_push(&args
, "--cloning");
1208 if (options
.update_shallow
)
1209 strvec_push(&args
, "--update-shallow");
1210 if (!options
.progress
)
1211 strvec_push(&args
, "--no-progress");
1213 strvec_pushf(&args
, "--depth=%lu", options
.depth
);
1214 if (options
.deepen_since
)
1215 strvec_pushf(&args
, "--shallow-since=%s", options
.deepen_since
);
1216 for (i
= 0; i
< options
.deepen_not
.nr
; i
++)
1217 strvec_pushf(&args
, "--shallow-exclude=%s",
1218 options
.deepen_not
.items
[i
].string
);
1219 if (options
.deepen_relative
&& options
.depth
)
1220 strvec_push(&args
, "--deepen-relative");
1221 if (options
.from_promisor
)
1222 strvec_push(&args
, "--from-promisor");
1223 if (options
.refetch
)
1224 strvec_push(&args
, "--refetch");
1226 strvec_pushf(&args
, "--filter=%s", options
.filter
);
1227 strvec_push(&args
, url
.buf
);
1229 for (i
= 0; i
< nr_heads
; i
++) {
1230 struct ref
*ref
= to_fetch
[i
];
1232 die(_("cannot fetch by sha1 over smart http"));
1233 packet_buf_write(&preamble
, "%s %s\n",
1234 oid_to_hex(&ref
->old_oid
), ref
->name
);
1236 packet_buf_flush(&preamble
);
1238 memset(&rpc
, 0, sizeof(rpc
));
1239 rpc
.service_name
= "git-upload-pack",
1240 rpc
.gzip_request
= 1;
1242 err
= rpc_service(&rpc
, heads
, args
.v
, &preamble
, &rpc_result
);
1244 write_or_die(1, rpc_result
.buf
, rpc_result
.len
);
1245 strbuf_release(&rpc_result
);
1246 strbuf_release(&preamble
);
1247 strvec_clear(&args
);
1251 static int fetch(int nr_heads
, struct ref
**to_fetch
)
1253 struct discovery
*d
= discover_refs("git-upload-pack", 0);
1255 return fetch_git(d
, nr_heads
, to_fetch
);
1257 return fetch_dumb(nr_heads
, to_fetch
);
1260 static void parse_fetch(struct strbuf
*buf
)
1262 struct ref
**to_fetch
= NULL
;
1263 struct ref
*list_head
= NULL
;
1264 struct ref
**list
= &list_head
;
1265 int alloc_heads
= 0, nr_heads
= 0;
1269 if (skip_prefix(buf
->buf
, "fetch ", &p
)) {
1272 struct object_id old_oid
;
1275 if (parse_oid_hex(p
, &old_oid
, &q
))
1276 die(_("protocol error: expected sha/ref, got '%s'"), p
);
1282 die(_("protocol error: expected sha/ref, got '%s'"), p
);
1284 ref
= alloc_ref(name
);
1285 oidcpy(&ref
->old_oid
, &old_oid
);
1290 ALLOC_GROW(to_fetch
, nr_heads
+ 1, alloc_heads
);
1291 to_fetch
[nr_heads
++] = ref
;
1294 die(_("http transport does not support %s"), buf
->buf
);
1297 if (strbuf_getline_lf(buf
, stdin
) == EOF
)
1303 if (fetch(nr_heads
, to_fetch
))
1304 exit(128); /* error already reported */
1305 free_refs(list_head
);
1313 static void parse_get(const char *arg
)
1315 struct strbuf url
= STRBUF_INIT
;
1316 struct strbuf path
= STRBUF_INIT
;
1319 space
= strchr(arg
, ' ');
1322 die(_("protocol error: expected '<url> <path>', missing space"));
1324 strbuf_add(&url
, arg
, space
- arg
);
1325 strbuf_addstr(&path
, space
+ 1);
1327 if (http_get_file(url
.buf
, path
.buf
, NULL
))
1328 die(_("failed to download file at URL '%s'"), url
.buf
);
1330 strbuf_release(&url
);
1331 strbuf_release(&path
);
1336 static int push_dav(int nr_spec
, const char **specs
)
1338 struct child_process child
= CHILD_PROCESS_INIT
;
1342 strvec_push(&child
.args
, "http-push");
1343 strvec_push(&child
.args
, "--helper-status");
1344 if (options
.dry_run
)
1345 strvec_push(&child
.args
, "--dry-run");
1346 if (options
.verbosity
> 1)
1347 strvec_push(&child
.args
, "--verbose");
1348 strvec_push(&child
.args
, url
.buf
);
1349 for (i
= 0; i
< nr_spec
; i
++)
1350 strvec_push(&child
.args
, specs
[i
]);
1352 if (run_command(&child
))
1353 die(_("git-http-push failed"));
1357 static int push_git(struct discovery
*heads
, int nr_spec
, const char **specs
)
1359 struct rpc_state rpc
= RPC_STATE_INIT
;
1362 struct string_list_item
*cas_option
;
1363 struct strbuf preamble
= STRBUF_INIT
;
1364 struct strbuf rpc_result
= STRBUF_INIT
;
1367 strvec_pushl(&args
, "send-pack", "--stateless-rpc", "--helper-status",
1371 strvec_push(&args
, "--thin");
1372 if (options
.dry_run
)
1373 strvec_push(&args
, "--dry-run");
1374 if (options
.push_cert
== SEND_PACK_PUSH_CERT_ALWAYS
)
1375 strvec_push(&args
, "--signed=yes");
1376 else if (options
.push_cert
== SEND_PACK_PUSH_CERT_IF_ASKED
)
1377 strvec_push(&args
, "--signed=if-asked");
1379 strvec_push(&args
, "--atomic");
1380 if (options
.verbosity
== 0)
1381 strvec_push(&args
, "--quiet");
1382 else if (options
.verbosity
> 1)
1383 strvec_push(&args
, "--verbose");
1384 for (i
= 0; i
< options
.push_options
.nr
; i
++)
1385 strvec_pushf(&args
, "--push-option=%s",
1386 options
.push_options
.items
[i
].string
);
1387 strvec_push(&args
, options
.progress
? "--progress" : "--no-progress");
1388 for_each_string_list_item(cas_option
, &cas_options
)
1389 strvec_push(&args
, cas_option
->string
);
1390 strvec_push(&args
, url
.buf
);
1392 if (options
.force_if_includes
)
1393 strvec_push(&args
, "--force-if-includes");
1395 strvec_push(&args
, "--stdin");
1396 for (i
= 0; i
< nr_spec
; i
++)
1397 packet_buf_write(&preamble
, "%s\n", specs
[i
]);
1398 packet_buf_flush(&preamble
);
1400 memset(&rpc
, 0, sizeof(rpc
));
1401 rpc
.service_name
= "git-receive-pack",
1403 err
= rpc_service(&rpc
, heads
, args
.v
, &preamble
, &rpc_result
);
1405 write_or_die(1, rpc_result
.buf
, rpc_result
.len
);
1406 strbuf_release(&rpc_result
);
1407 strbuf_release(&preamble
);
1408 strvec_clear(&args
);
1412 static int push(int nr_spec
, const char **specs
)
1414 struct discovery
*heads
= discover_refs("git-receive-pack", 1);
1417 if (heads
->proto_git
)
1418 ret
= push_git(heads
, nr_spec
, specs
);
1420 ret
= push_dav(nr_spec
, specs
);
1421 free_discovery(heads
);
1425 static void parse_push(struct strbuf
*buf
)
1427 struct strvec specs
= STRVEC_INIT
;
1432 if (skip_prefix(buf
->buf
, "push ", &arg
))
1433 strvec_push(&specs
, arg
);
1435 die(_("http transport does not support %s"), buf
->buf
);
1438 if (strbuf_getline_lf(buf
, stdin
) == EOF
)
1444 ret
= push(specs
.nr
, specs
.v
);
1449 exit(128); /* error already reported */
1452 strvec_clear(&specs
);
1455 static int stateless_connect(const char *service_name
)
1457 struct discovery
*discover
;
1458 struct rpc_state rpc
= RPC_STATE_INIT
;
1459 struct strbuf buf
= STRBUF_INIT
;
1460 const char *accept_language
;
1463 * Run the info/refs request and see if the server supports protocol
1464 * v2. If and only if the server supports v2 can we successfully
1465 * establish a stateless connection, otherwise we need to tell the
1466 * client to fallback to using other transport helper functions to
1467 * complete their request.
1469 * The "git-upload-archive" service is a read-only operation. Fallback
1470 * to use "git-upload-pack" service to discover protocol version.
1472 if (!strcmp(service_name
, "git-upload-archive"))
1473 discover
= discover_refs("git-upload-pack", 0);
1475 discover
= discover_refs(service_name
, 0);
1476 if (discover
->version
!= protocol_v2
) {
1477 printf("fallback\n");
1481 /* Stateless Connection established */
1485 accept_language
= http_get_accept_language_header();
1486 if (accept_language
)
1487 rpc
.hdr_accept_language
= xstrfmt("%s", accept_language
);
1489 rpc
.service_name
= service_name
;
1490 rpc
.service_url
= xstrfmt("%s%s", url
.buf
, rpc
.service_name
);
1491 rpc
.hdr_content_type
= xstrfmt("Content-Type: application/x-%s-request", rpc
.service_name
);
1492 rpc
.hdr_accept
= xstrfmt("Accept: application/x-%s-result", rpc
.service_name
);
1493 if (get_protocol_http_header(discover
->version
, &buf
)) {
1494 rpc
.protocol_header
= strbuf_detach(&buf
, NULL
);
1496 rpc
.protocol_header
= NULL
;
1497 strbuf_release(&buf
);
1499 rpc
.buf
= xmalloc(http_post_buffer
);
1500 rpc
.alloc
= http_post_buffer
;
1505 rpc
.any_written
= 0;
1506 rpc
.gzip_request
= 1;
1507 rpc
.initial_buffer
= 0;
1508 rpc
.write_line_lengths
= 1;
1509 rpc
.flush_read_but_not_sent
= 0;
1512 * Dump the capability listing that we got from the server earlier
1513 * during the info/refs request. This does not work with the
1514 * "git-upload-archive" service.
1516 if (strcmp(service_name
, "git-upload-archive"))
1517 write_or_die(rpc
.in
, discover
->buf
, discover
->len
);
1519 /* Until we see EOF keep sending POSTs */
1522 enum packet_read_status status
;
1524 if (!rpc_read_from_out(&rpc
, PACKET_READ_GENTLE_ON_EOF
, &avail
,
1526 BUG("The entire rpc->buf should be larger than LARGE_PACKET_MAX");
1527 if (status
== PACKET_READ_EOF
)
1529 if (post_rpc(&rpc
, 1, status
== PACKET_READ_FLUSH
))
1530 /* We would have an err here */
1532 /* Reset the buffer for next request */
1536 free(rpc
.service_url
);
1537 free(rpc
.hdr_content_type
);
1538 free(rpc
.hdr_accept
);
1539 free(rpc
.hdr_accept_language
);
1540 free(rpc
.protocol_header
);
1542 strbuf_release(&buf
);
1547 int cmd_main(int argc
, const char **argv
)
1549 struct strbuf buf
= STRBUF_INIT
;
1553 setup_git_directory_gently(&nongit
);
1555 error(_("remote-curl: usage: git remote-curl <remote> [<url>]"));
1559 options
.verbosity
= 1;
1560 options
.progress
= !!isatty(2);
1562 string_list_init_dup(&options
.deepen_not
);
1563 string_list_init_dup(&options
.push_options
);
1566 * Just report "remote-curl" here (folding all the various aliases
1567 * ("git-remote-http", "git-remote-https", and etc.) here since they
1568 * are all just copies of the same actual executable.
1570 trace2_cmd_name("remote-curl");
1572 remote
= remote_get(argv
[1]);
1575 end_url_with_slash(&url
, argv
[2]);
1577 end_url_with_slash(&url
, remote
->url
[0]);
1580 http_init(remote
, url
.buf
, 0);
1585 if (strbuf_getline_lf(&buf
, stdin
) == EOF
) {
1587 error(_("remote-curl: error reading command stream from git"));
1592 if (starts_with(buf
.buf
, "fetch ")) {
1594 setup_git_directory_gently(&nongit
);
1596 die(_("remote-curl: fetch attempted without a local repo"));
1600 } else if (!strcmp(buf
.buf
, "list") || starts_with(buf
.buf
, "list ")) {
1601 int for_push
= !!strstr(buf
.buf
+ 4, "for-push");
1602 output_refs(get_refs(for_push
));
1604 } else if (starts_with(buf
.buf
, "push ")) {
1607 } else if (skip_prefix(buf
.buf
, "option ", &arg
)) {
1608 const char *value
= strchrnul(arg
, ' ');
1609 size_t arglen
= value
- arg
;
1613 value
++; /* skip over SP */
1617 result
= set_option(arg
, arglen
, value
);
1620 else if (result
< 0)
1621 printf("error invalid value\n");
1623 printf("unsupported\n");
1626 } else if (skip_prefix(buf
.buf
, "get ", &arg
)) {
1630 } else if (!strcmp(buf
.buf
, "capabilities")) {
1631 printf("stateless-connect\n");
1636 printf("check-connectivity\n");
1637 printf("object-format\n");
1640 } else if (skip_prefix(buf
.buf
, "stateless-connect ", &arg
)) {
1641 if (!stateless_connect(arg
))
1644 error(_("remote-curl: unknown command '%s' from git"), buf
.buf
);
1653 strbuf_release(&buf
);