]> git.ipfire.org Git - thirdparty/git.git/commitdiff
Merge branch 'ds/bundle-uri-4'
authorJunio C Hamano <gitster@pobox.com>
Mon, 2 Jan 2023 12:37:18 +0000 (21:37 +0900)
committerJunio C Hamano <gitster@pobox.com>
Mon, 2 Jan 2023 12:37:18 +0000 (21:37 +0900)
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

1  2 
builtin/clone.c
connect.c
transport.c

diff --cc builtin/clone.c
Simple merge
diff --cc connect.c
index eef752f14b803e4ac770264abe900f250fedb01d,624a10f18eec6ee623ad3788b7cf904fa50f72ae..63e59641c0d4d5c60fc4bee2761e6acd471535a2
+++ b/connect.c
@@@ -493,6 -492,49 +494,49 @@@ static void send_capabilities(int fd_ou
        }
  }
  
 -      server_supports_v2("bundle-uri", 1);
+ 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,
diff --cc transport.c
index e7b97194c103a3a7fad6d4174e40c96db9ff2a4c,241f8a6ba2dc8c1f2f12e33db9513c0adf4ee24f..77a61a9d7bb06a5cfc7992c6fc4f9f3aa8a8ada5
@@@ -359,6 -360,39 +360,39 @@@ static struct ref *get_refs_via_connect
        return handshake(transport, for_push, options, 1);
  }
  
 -      if (!server_supports_v2("bundle-uri", 0))
+ static int get_bundle_uri(struct transport *transport)
+ {
+       struct git_transport_data *data = transport->data;
+       struct packet_reader reader;
+       int stateless_rpc = transport->stateless_rpc;
+       if (!transport->bundles) {
+               CALLOC_ARRAY(transport->bundles, 1);
+               init_bundle_list(transport->bundles);
+       }
+       if (!data->finished_handshake) {
+               struct ref *refs = handshake(transport, 0, NULL, 0);
+               if (refs)
+                       free_refs(refs);
+       }
+       /*
+        * "Support" protocol v0 and v2 without bundle-uri support by
+        * silently degrading to a NOOP.
+        */
++      if (!server_supports_v2("bundle-uri"))
+               return 0;
+       packet_reader_init(&reader, data->fd[0], NULL, 0,
+                          PACKET_READ_CHOMP_NEWLINE |
+                          PACKET_READ_GENTLE_ON_EOF);
+       return get_remote_bundle_uri(data->fd[1], &reader,
+                                    transport->bundles, stateless_rpc);
+ }
  static int fetch_refs_via_pack(struct transport *transport,
                               int nr_heads, struct ref **to_fetch)
  {