7 #include "run-command.h"
10 #include "argv-array.h"
11 #include "credential.h"
13 static struct remote
*remote
;
14 static const char *url
; /* always ends with a trailing slash */
19 unsigned progress
: 1,
24 static struct options options
;
26 static int set_option(const char *name
, const char *value
)
28 if (!strcmp(name
, "verbosity")) {
30 int v
= strtol(value
, &end
, 10);
31 if (value
== end
|| *end
)
33 options
.verbosity
= v
;
36 else if (!strcmp(name
, "progress")) {
37 if (!strcmp(value
, "true"))
39 else if (!strcmp(value
, "false"))
45 else if (!strcmp(name
, "depth")) {
47 unsigned long v
= strtoul(value
, &end
, 10);
48 if (value
== end
|| *end
)
53 else if (!strcmp(name
, "followtags")) {
54 if (!strcmp(value
, "true"))
55 options
.followtags
= 1;
56 else if (!strcmp(value
, "false"))
57 options
.followtags
= 0;
62 else if (!strcmp(name
, "dry-run")) {
63 if (!strcmp(value
, "true"))
65 else if (!strcmp(value
, "false"))
72 return 1 /* unsupported */;
82 unsigned proto_git
: 1;
84 static struct discovery
*last_discovery
;
86 static struct ref
*parse_git_refs(struct discovery
*heads
, int for_push
)
88 struct ref
*list
= NULL
;
89 get_remote_heads(-1, heads
->buf
, heads
->len
, &list
,
90 for_push
? REF_NORMAL
: 0, NULL
);
94 static struct ref
*parse_info_refs(struct discovery
*heads
)
96 char *data
, *start
, *mid
;
100 struct ref
*refs
= NULL
;
101 struct ref
*ref
= NULL
;
102 struct ref
*last_ref
= NULL
;
107 while (i
< heads
->len
) {
113 if (data
[i
] == '\n') {
114 if (mid
- start
!= 40)
115 die("%sinfo/refs not valid: is this a git repository?", url
);
118 ref
= xmalloc(sizeof(struct ref
) +
119 strlen(ref_name
) + 1);
120 memset(ref
, 0, sizeof(struct ref
));
121 strcpy(ref
->name
, ref_name
);
122 get_sha1_hex(start
, ref
->old_sha1
);
126 last_ref
->next
= ref
;
133 ref
= alloc_ref("HEAD");
134 if (!http_fetch_ref(url
, ref
) &&
135 !resolve_remote_symref(ref
, refs
)) {
145 static void free_discovery(struct discovery
*d
)
148 if (d
== last_discovery
)
149 last_discovery
= NULL
;
156 static int show_http_message(struct strbuf
*type
, struct strbuf
*msg
)
161 * We only show text/plain parts, as other types are likely
162 * to be ugly to look at on the user's terminal.
164 * TODO should handle "; charset=XXX", and re-encode into
167 if (strcasecmp(type
->buf
, "text/plain"))
176 eol
= strchrnul(p
, '\n');
177 fprintf(stderr
, "remote: %.*s\n", (int)(eol
- p
), p
);
183 static struct discovery
* discover_refs(const char *service
, int for_push
)
185 struct strbuf exp
= STRBUF_INIT
;
186 struct strbuf type
= STRBUF_INIT
;
187 struct strbuf buffer
= STRBUF_INIT
;
188 struct strbuf refs_url
= STRBUF_INIT
;
189 struct discovery
*last
= last_discovery
;
190 int http_ret
, maybe_smart
= 0;
191 struct http_get_options options
;
193 if (last
&& !strcmp(service
, last
->service
))
195 free_discovery(last
);
197 strbuf_addf(&refs_url
, "%sinfo/refs", url
);
198 if ((!prefixcmp(url
, "http://") || !prefixcmp(url
, "https://")) &&
199 git_env_bool("GIT_SMART_HTTP", 1)) {
201 if (!strchr(url
, '?'))
202 strbuf_addch(&refs_url
, '?');
204 strbuf_addch(&refs_url
, '&');
205 strbuf_addf(&refs_url
, "service=%s", service
);
208 memset(&options
, 0, sizeof(options
));
209 options
.content_type
= &type
;
210 options
.no_cache
= 1;
211 options
.keep_error
= 1;
213 http_ret
= http_get_strbuf(refs_url
.buf
, &buffer
, &options
);
217 case HTTP_MISSING_TARGET
:
218 show_http_message(&type
, &buffer
);
219 die("repository '%s' not found", url
);
221 show_http_message(&type
, &buffer
);
222 die("Authentication failed for '%s'", url
);
224 show_http_message(&type
, &buffer
);
225 die("unable to access '%s': %s", url
, curl_errorstr
);
228 last
= xcalloc(1, sizeof(*last_discovery
));
229 last
->service
= service
;
230 last
->buf_alloc
= strbuf_detach(&buffer
, &last
->len
);
231 last
->buf
= last
->buf_alloc
;
233 strbuf_addf(&exp
, "application/x-%s-advertisement", service
);
235 (5 <= last
->len
&& last
->buf
[4] == '#') &&
236 !strbuf_cmp(&exp
, &type
)) {
240 * smart HTTP response; validate that the service
241 * pkt-line matches our request.
243 line
= packet_read_line_buf(&last
->buf
, &last
->len
, NULL
);
246 strbuf_addf(&exp
, "# service=%s", service
);
247 if (strcmp(line
, exp
.buf
))
248 die("invalid server response; got '%s'", line
);
249 strbuf_release(&exp
);
251 /* The header can include additional metadata lines, up
252 * until a packet flush marker. Ignore these now, but
253 * in the future we might start to scan them.
255 while (packet_read_line_buf(&last
->buf
, &last
->len
, NULL
))
262 last
->refs
= parse_git_refs(last
, for_push
);
264 last
->refs
= parse_info_refs(last
);
266 strbuf_release(&refs_url
);
267 strbuf_release(&exp
);
268 strbuf_release(&type
);
269 strbuf_release(&buffer
);
270 last_discovery
= last
;
274 static struct ref
*get_refs(int for_push
)
276 struct discovery
*heads
;
279 heads
= discover_refs("git-receive-pack", for_push
);
281 heads
= discover_refs("git-upload-pack", for_push
);
286 static void output_refs(struct ref
*refs
)
289 for (posn
= refs
; posn
; posn
= posn
->next
) {
291 printf("@%s %s\n", posn
->symref
, posn
->name
);
293 printf("%s %s\n", sha1_to_hex(posn
->old_sha1
), posn
->name
);
300 const char *service_name
;
302 struct strbuf
*stdin_preamble
;
304 char *hdr_content_type
;
312 struct strbuf result
;
313 unsigned gzip_request
: 1;
314 unsigned initial_buffer
: 1;
317 static size_t rpc_out(void *ptr
, size_t eltsize
,
318 size_t nmemb
, void *buffer_
)
320 size_t max
= eltsize
* nmemb
;
321 struct rpc_state
*rpc
= buffer_
;
322 size_t avail
= rpc
->len
- rpc
->pos
;
325 rpc
->initial_buffer
= 0;
326 avail
= packet_read(rpc
->out
, NULL
, NULL
, rpc
->buf
, rpc
->alloc
, 0);
335 memcpy(ptr
, rpc
->buf
+ rpc
->pos
, avail
);
340 #ifndef NO_CURL_IOCTL
341 static curlioerr
rpc_ioctl(CURL
*handle
, int cmd
, void *clientp
)
343 struct rpc_state
*rpc
= clientp
;
349 case CURLIOCMD_RESTARTREAD
:
350 if (rpc
->initial_buffer
) {
354 fprintf(stderr
, "Unable to rewind rpc post data - try increasing http.postBuffer\n");
355 return CURLIOE_FAILRESTART
;
358 return CURLIOE_UNKNOWNCMD
;
363 static size_t rpc_in(char *ptr
, size_t eltsize
,
364 size_t nmemb
, void *buffer_
)
366 size_t size
= eltsize
* nmemb
;
367 struct rpc_state
*rpc
= buffer_
;
368 write_or_die(rpc
->in
, ptr
, size
);
372 static int run_slot(struct active_request_slot
*slot
)
375 struct slot_results results
;
377 slot
->results
= &results
;
378 slot
->curl_result
= curl_easy_perform(slot
->curl
);
379 finish_active_slot(slot
);
381 err
= handle_curl_result(&results
);
382 if (err
!= HTTP_OK
&& err
!= HTTP_REAUTH
) {
383 error("RPC failed; result=%d, HTTP code = %ld",
384 results
.curl_result
, results
.http_code
);
390 static int probe_rpc(struct rpc_state
*rpc
)
392 struct active_request_slot
*slot
;
393 struct curl_slist
*headers
= NULL
;
394 struct strbuf buf
= STRBUF_INIT
;
397 slot
= get_active_slot();
399 headers
= curl_slist_append(headers
, rpc
->hdr_content_type
);
400 headers
= curl_slist_append(headers
, rpc
->hdr_accept
);
402 curl_easy_setopt(slot
->curl
, CURLOPT_NOBODY
, 0);
403 curl_easy_setopt(slot
->curl
, CURLOPT_POST
, 1);
404 curl_easy_setopt(slot
->curl
, CURLOPT_URL
, rpc
->service_url
);
405 curl_easy_setopt(slot
->curl
, CURLOPT_ENCODING
, NULL
);
406 curl_easy_setopt(slot
->curl
, CURLOPT_POSTFIELDS
, "0000");
407 curl_easy_setopt(slot
->curl
, CURLOPT_POSTFIELDSIZE
, 4);
408 curl_easy_setopt(slot
->curl
, CURLOPT_HTTPHEADER
, headers
);
409 curl_easy_setopt(slot
->curl
, CURLOPT_WRITEFUNCTION
, fwrite_buffer
);
410 curl_easy_setopt(slot
->curl
, CURLOPT_FILE
, &buf
);
412 err
= run_slot(slot
);
414 curl_slist_free_all(headers
);
415 strbuf_release(&buf
);
419 static int post_rpc(struct rpc_state
*rpc
)
421 struct active_request_slot
*slot
;
422 struct curl_slist
*headers
= NULL
;
423 int use_gzip
= rpc
->gzip_request
;
424 char *gzip_body
= NULL
;
425 size_t gzip_size
= 0;
426 int err
, large_request
= 0;
428 /* Try to load the entire request, if we can fit it into the
429 * allocated buffer space we can use HTTP/1.0 and avoid the
430 * chunked encoding mess.
433 size_t left
= rpc
->alloc
- rpc
->len
;
434 char *buf
= rpc
->buf
+ rpc
->len
;
437 if (left
< LARGE_PACKET_MAX
) {
443 n
= packet_read(rpc
->out
, NULL
, NULL
, buf
, left
, 0);
451 err
= probe_rpc(rpc
);
452 if (err
== HTTP_REAUTH
)
453 credential_fill(&http_auth
);
454 } while (err
== HTTP_REAUTH
);
459 headers
= curl_slist_append(headers
, rpc
->hdr_content_type
);
460 headers
= curl_slist_append(headers
, rpc
->hdr_accept
);
461 headers
= curl_slist_append(headers
, "Expect:");
464 slot
= get_active_slot();
466 curl_easy_setopt(slot
->curl
, CURLOPT_NOBODY
, 0);
467 curl_easy_setopt(slot
->curl
, CURLOPT_POST
, 1);
468 curl_easy_setopt(slot
->curl
, CURLOPT_URL
, rpc
->service_url
);
469 curl_easy_setopt(slot
->curl
, CURLOPT_ENCODING
, "gzip");
472 /* The request body is large and the size cannot be predicted.
473 * We must use chunked encoding to send it.
475 headers
= curl_slist_append(headers
, "Transfer-Encoding: chunked");
476 rpc
->initial_buffer
= 1;
477 curl_easy_setopt(slot
->curl
, CURLOPT_READFUNCTION
, rpc_out
);
478 curl_easy_setopt(slot
->curl
, CURLOPT_INFILE
, rpc
);
479 #ifndef NO_CURL_IOCTL
480 curl_easy_setopt(slot
->curl
, CURLOPT_IOCTLFUNCTION
, rpc_ioctl
);
481 curl_easy_setopt(slot
->curl
, CURLOPT_IOCTLDATA
, rpc
);
483 if (options
.verbosity
> 1) {
484 fprintf(stderr
, "POST %s (chunked)\n", rpc
->service_name
);
488 } else if (gzip_body
) {
490 * If we are looping to retry authentication, then the previous
491 * run will have set up the headers and gzip buffer already,
492 * and we just need to send it.
494 curl_easy_setopt(slot
->curl
, CURLOPT_POSTFIELDS
, gzip_body
);
495 curl_easy_setopt(slot
->curl
, CURLOPT_POSTFIELDSIZE
, gzip_size
);
497 } else if (use_gzip
&& 1024 < rpc
->len
) {
498 /* The client backend isn't giving us compressed data so
499 * we can try to deflate it ourselves, this may save on.
505 memset(&stream
, 0, sizeof(stream
));
506 git_deflate_init_gzip(&stream
, Z_BEST_COMPRESSION
);
507 gzip_size
= git_deflate_bound(&stream
, rpc
->len
);
508 gzip_body
= xmalloc(gzip_size
);
510 stream
.next_in
= (unsigned char *)rpc
->buf
;
511 stream
.avail_in
= rpc
->len
;
512 stream
.next_out
= (unsigned char *)gzip_body
;
513 stream
.avail_out
= gzip_size
;
515 ret
= git_deflate(&stream
, Z_FINISH
);
516 if (ret
!= Z_STREAM_END
)
517 die("cannot deflate request; zlib deflate error %d", ret
);
519 ret
= git_deflate_end_gently(&stream
);
521 die("cannot deflate request; zlib end error %d", ret
);
523 gzip_size
= stream
.total_out
;
525 headers
= curl_slist_append(headers
, "Content-Encoding: gzip");
526 curl_easy_setopt(slot
->curl
, CURLOPT_POSTFIELDS
, gzip_body
);
527 curl_easy_setopt(slot
->curl
, CURLOPT_POSTFIELDSIZE
, gzip_size
);
529 if (options
.verbosity
> 1) {
530 fprintf(stderr
, "POST %s (gzip %lu to %lu bytes)\n",
532 (unsigned long)rpc
->len
, (unsigned long)gzip_size
);
536 /* We know the complete request size in advance, use the
537 * more normal Content-Length approach.
539 curl_easy_setopt(slot
->curl
, CURLOPT_POSTFIELDS
, rpc
->buf
);
540 curl_easy_setopt(slot
->curl
, CURLOPT_POSTFIELDSIZE
, rpc
->len
);
541 if (options
.verbosity
> 1) {
542 fprintf(stderr
, "POST %s (%lu bytes)\n",
543 rpc
->service_name
, (unsigned long)rpc
->len
);
548 curl_easy_setopt(slot
->curl
, CURLOPT_HTTPHEADER
, headers
);
549 curl_easy_setopt(slot
->curl
, CURLOPT_WRITEFUNCTION
, rpc_in
);
550 curl_easy_setopt(slot
->curl
, CURLOPT_FILE
, rpc
);
552 err
= run_slot(slot
);
553 if (err
== HTTP_REAUTH
&& !large_request
) {
554 credential_fill(&http_auth
);
560 curl_slist_free_all(headers
);
565 static int rpc_service(struct rpc_state
*rpc
, struct discovery
*heads
)
567 const char *svc
= rpc
->service_name
;
568 struct strbuf buf
= STRBUF_INIT
;
569 struct strbuf
*preamble
= rpc
->stdin_preamble
;
570 struct child_process client
;
573 memset(&client
, 0, sizeof(client
));
577 client
.argv
= rpc
->argv
;
578 if (start_command(&client
))
581 write_or_die(client
.in
, preamble
->buf
, preamble
->len
);
583 write_or_die(client
.in
, heads
->buf
, heads
->len
);
585 rpc
->alloc
= http_post_buffer
;
586 rpc
->buf
= xmalloc(rpc
->alloc
);
588 rpc
->out
= client
.out
;
589 strbuf_init(&rpc
->result
, 0);
591 strbuf_addf(&buf
, "%s%s", url
, svc
);
592 rpc
->service_url
= strbuf_detach(&buf
, NULL
);
594 strbuf_addf(&buf
, "Content-Type: application/x-%s-request", svc
);
595 rpc
->hdr_content_type
= strbuf_detach(&buf
, NULL
);
597 strbuf_addf(&buf
, "Accept: application/x-%s-result", svc
);
598 rpc
->hdr_accept
= strbuf_detach(&buf
, NULL
);
601 int n
= packet_read(rpc
->out
, NULL
, NULL
, rpc
->buf
, rpc
->alloc
, 0);
606 err
|= post_rpc(rpc
);
612 strbuf_read(&rpc
->result
, client
.out
, 0);
616 if (xread(client
.out
, buf
, sizeof(buf
)) <= 0)
623 err
|= finish_command(&client
);
624 free(rpc
->service_url
);
625 free(rpc
->hdr_content_type
);
626 free(rpc
->hdr_accept
);
628 strbuf_release(&buf
);
632 static int fetch_dumb(int nr_heads
, struct ref
**to_fetch
)
634 struct walker
*walker
;
635 char **targets
= xmalloc(nr_heads
* sizeof(char*));
639 die("dumb http transport does not support --depth");
640 for (i
= 0; i
< nr_heads
; i
++)
641 targets
[i
] = xstrdup(sha1_to_hex(to_fetch
[i
]->old_sha1
));
643 walker
= get_http_walker(url
);
645 walker
->get_tree
= 1;
646 walker
->get_history
= 1;
647 walker
->get_verbosely
= options
.verbosity
>= 3;
648 walker
->get_recover
= 0;
649 ret
= walker_fetch(walker
, nr_heads
, targets
, NULL
, NULL
);
652 for (i
= 0; i
< nr_heads
; i
++)
656 return ret
? error("Fetch failed.") : 0;
659 static int fetch_git(struct discovery
*heads
,
660 int nr_heads
, struct ref
**to_fetch
)
662 struct rpc_state rpc
;
663 struct strbuf preamble
= STRBUF_INIT
;
664 char *depth_arg
= NULL
;
665 int argc
= 0, i
, err
;
666 const char *argv
[15];
668 argv
[argc
++] = "fetch-pack";
669 argv
[argc
++] = "--stateless-rpc";
670 argv
[argc
++] = "--stdin";
671 argv
[argc
++] = "--lock-pack";
672 if (options
.followtags
)
673 argv
[argc
++] = "--include-tag";
675 argv
[argc
++] = "--thin";
676 if (options
.verbosity
>= 3) {
680 if (!options
.progress
)
681 argv
[argc
++] = "--no-progress";
683 struct strbuf buf
= STRBUF_INIT
;
684 strbuf_addf(&buf
, "--depth=%lu", options
.depth
);
685 depth_arg
= strbuf_detach(&buf
, NULL
);
686 argv
[argc
++] = depth_arg
;
691 for (i
= 0; i
< nr_heads
; i
++) {
692 struct ref
*ref
= to_fetch
[i
];
693 if (!ref
->name
|| !*ref
->name
)
694 die("cannot fetch by sha1 over smart http");
695 packet_buf_write(&preamble
, "%s\n", ref
->name
);
697 packet_buf_flush(&preamble
);
699 memset(&rpc
, 0, sizeof(rpc
));
700 rpc
.service_name
= "git-upload-pack",
702 rpc
.stdin_preamble
= &preamble
;
703 rpc
.gzip_request
= 1;
705 err
= rpc_service(&rpc
, heads
);
707 write_or_die(1, rpc
.result
.buf
, rpc
.result
.len
);
708 strbuf_release(&rpc
.result
);
709 strbuf_release(&preamble
);
714 static int fetch(int nr_heads
, struct ref
**to_fetch
)
716 struct discovery
*d
= discover_refs("git-upload-pack", 0);
718 return fetch_git(d
, nr_heads
, to_fetch
);
720 return fetch_dumb(nr_heads
, to_fetch
);
723 static void parse_fetch(struct strbuf
*buf
)
725 struct ref
**to_fetch
= NULL
;
726 struct ref
*list_head
= NULL
;
727 struct ref
**list
= &list_head
;
728 int alloc_heads
= 0, nr_heads
= 0;
731 if (!prefixcmp(buf
->buf
, "fetch ")) {
732 char *p
= buf
->buf
+ strlen("fetch ");
735 unsigned char old_sha1
[20];
737 if (strlen(p
) < 40 || get_sha1_hex(p
, old_sha1
))
738 die("protocol error: expected sha/ref, got %s'", p
);
744 die("protocol error: expected sha/ref, got %s'", p
);
746 ref
= alloc_ref(name
);
747 hashcpy(ref
->old_sha1
, old_sha1
);
752 ALLOC_GROW(to_fetch
, nr_heads
+ 1, alloc_heads
);
753 to_fetch
[nr_heads
++] = ref
;
756 die("http transport does not support %s", buf
->buf
);
759 if (strbuf_getline(buf
, stdin
, '\n') == EOF
)
765 if (fetch(nr_heads
, to_fetch
))
766 exit(128); /* error already reported */
767 free_refs(list_head
);
775 static int push_dav(int nr_spec
, char **specs
)
777 const char **argv
= xmalloc((10 + nr_spec
) * sizeof(char*));
780 argv
[argc
++] = "http-push";
781 argv
[argc
++] = "--helper-status";
783 argv
[argc
++] = "--dry-run";
784 if (options
.verbosity
> 1)
785 argv
[argc
++] = "--verbose";
787 for (i
= 0; i
< nr_spec
; i
++)
788 argv
[argc
++] = specs
[i
];
791 if (run_command_v_opt(argv
, RUN_GIT_CMD
))
792 die("git-%s failed", argv
[0]);
797 static int push_git(struct discovery
*heads
, int nr_spec
, char **specs
)
799 struct rpc_state rpc
;
801 struct argv_array args
;
803 argv_array_init(&args
);
804 argv_array_pushl(&args
, "send-pack", "--stateless-rpc", "--helper-status",
808 argv_array_push(&args
, "--thin");
810 argv_array_push(&args
, "--dry-run");
811 if (options
.verbosity
== 0)
812 argv_array_push(&args
, "--quiet");
813 else if (options
.verbosity
> 1)
814 argv_array_push(&args
, "--verbose");
815 argv_array_push(&args
, options
.progress
? "--progress" : "--no-progress");
816 argv_array_push(&args
, url
);
817 for (i
= 0; i
< nr_spec
; i
++)
818 argv_array_push(&args
, specs
[i
]);
820 memset(&rpc
, 0, sizeof(rpc
));
821 rpc
.service_name
= "git-receive-pack",
822 rpc
.argv
= args
.argv
;
824 err
= rpc_service(&rpc
, heads
);
826 write_or_die(1, rpc
.result
.buf
, rpc
.result
.len
);
827 strbuf_release(&rpc
.result
);
828 argv_array_clear(&args
);
832 static int push(int nr_spec
, char **specs
)
834 struct discovery
*heads
= discover_refs("git-receive-pack", 1);
837 if (heads
->proto_git
)
838 ret
= push_git(heads
, nr_spec
, specs
);
840 ret
= push_dav(nr_spec
, specs
);
841 free_discovery(heads
);
845 static void parse_push(struct strbuf
*buf
)
848 int alloc_spec
= 0, nr_spec
= 0, i
, ret
;
851 if (!prefixcmp(buf
->buf
, "push ")) {
852 ALLOC_GROW(specs
, nr_spec
+ 1, alloc_spec
);
853 specs
[nr_spec
++] = xstrdup(buf
->buf
+ 5);
856 die("http transport does not support %s", buf
->buf
);
859 if (strbuf_getline(buf
, stdin
, '\n') == EOF
)
865 ret
= push(nr_spec
, specs
);
870 exit(128); /* error already reported */
873 for (i
= 0; i
< nr_spec
; i
++)
878 int main(int argc
, const char **argv
)
880 struct strbuf buf
= STRBUF_INIT
;
883 git_extract_argv0_path(argv
[0]);
884 setup_git_directory_gently(&nongit
);
886 fprintf(stderr
, "Remote needed\n");
890 options
.verbosity
= 1;
891 options
.progress
= !!isatty(2);
894 remote
= remote_get(argv
[1]);
897 end_url_with_slash(&buf
, argv
[2]);
899 end_url_with_slash(&buf
, remote
->url
[0]);
902 url
= strbuf_detach(&buf
, NULL
);
904 http_init(remote
, url
, 0);
907 if (strbuf_getline(&buf
, stdin
, '\n') == EOF
) {
909 fprintf(stderr
, "Error reading command stream\n");
911 fprintf(stderr
, "Unexpected end of command stream\n");
916 if (!prefixcmp(buf
.buf
, "fetch ")) {
918 die("Fetch attempted without a local repo");
921 } else if (!strcmp(buf
.buf
, "list") || !prefixcmp(buf
.buf
, "list ")) {
922 int for_push
= !!strstr(buf
.buf
+ 4, "for-push");
923 output_refs(get_refs(for_push
));
925 } else if (!prefixcmp(buf
.buf
, "push ")) {
928 } else if (!prefixcmp(buf
.buf
, "option ")) {
929 char *name
= buf
.buf
+ strlen("option ");
930 char *value
= strchr(name
, ' ');
938 result
= set_option(name
, value
);
942 printf("error invalid value\n");
944 printf("unsupported\n");
947 } else if (!strcmp(buf
.buf
, "capabilities")) {
954 fprintf(stderr
, "Unknown command '%s'\n", buf
.buf
);