diff options
author | Junio C Hamano <gitster@pobox.com> | 2023-01-02 21:37:18 +0900 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2023-01-02 21:37:18 +0900 |
commit | 0903d8bbdef6c2607f2e0bf43a4d10cf54b03744 (patch) | |
tree | cfa616909c89d5830ef6c1251e7fd46bcb04edc9 /connect.c | |
parent | 3f2e4c09c769dc2fbbabfcfa625451f9d98bd49a (diff) | |
parent | 876094ac16870727207e6afc0b26060101a52359 (diff) | |
download | git-0903d8bbdef6c2607f2e0bf43a4d10cf54b03744.tar.gz |
Merge branch 'ds/bundle-uri-4'
Bundle URIs part 4.
* ds/bundle-uri-4:
clone: unbundle the advertised bundles
bundle-uri: download bundles from an advertised list
bundle-uri: allow relative URLs in bundle lists
strbuf: introduce strbuf_strip_file_from_path()
bundle-uri: serve bundle.* keys from config
bundle-uri client: add helper for testing server
transport: rename got_remote_heads
bundle-uri client: add boolean transfer.bundleURI setting
clone: request the 'bundle-uri' command when available
t: create test harness for 'bundle-uri' command
protocol v2: add server-side "bundle-uri" skeleton
Diffstat (limited to 'connect.c')
-rw-r--r-- | connect.c | 44 |
1 files changed, 44 insertions, 0 deletions
@@ -15,6 +15,7 @@ #include "version.h" #include "protocol.h" #include "alias.h" +#include "bundle-uri.h" static char *server_capabilities_v1; static struct strvec server_capabilities_v2 = STRVEC_INIT; @@ -493,6 +494,49 @@ static void send_capabilities(int fd_out, struct packet_reader *reader) } } +int get_remote_bundle_uri(int fd_out, struct packet_reader *reader, + struct bundle_list *bundles, int stateless_rpc) +{ + int line_nr = 1; + + /* Assert bundle-uri support */ + ensure_server_supports_v2("bundle-uri"); + + /* (Re-)send capabilities */ + send_capabilities(fd_out, reader); + + /* Send command */ + packet_write_fmt(fd_out, "command=bundle-uri\n"); + packet_delim(fd_out); + + packet_flush(fd_out); + + /* Process response from server */ + while (packet_reader_read(reader) == PACKET_READ_NORMAL) { + const char *line = reader->line; + line_nr++; + + if (!bundle_uri_parse_line(bundles, line)) + continue; + + return error(_("error on bundle-uri response line %d: %s"), + line_nr, line); + } + + if (reader->status != PACKET_READ_FLUSH) + return error(_("expected flush after bundle-uri listing")); + + /* + * Might die(), but obscure enough that that's OK, e.g. in + * serve.c we'll call BUG() on its equivalent (the + * PACKET_READ_RESPONSE_END check). + */ + check_stateless_delimiter(stateless_rpc, reader, + _("expected response end packet after ref listing")); + + return 0; +} + struct ref **get_remote_refs(int fd_out, struct packet_reader *reader, struct ref **list, int for_push, struct transport_ls_refs_options *transport_options, |