From: Junio C Hamano Date: Tue, 5 Feb 2019 22:26:11 +0000 (-0800) Subject: Merge branch 'jt/fetch-v2-sideband' X-Git-Tag: v2.21.0-rc0~50 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=5f8b86db94e789bc07258f98cc5ba25d18273d83;p=thirdparty%2Fgit.git Merge branch 'jt/fetch-v2-sideband' "git fetch" and "git upload-pack" learned to send all exchange over the sideband channel while talking the v2 protocol. * jt/fetch-v2-sideband: tests: define GIT_TEST_SIDEBAND_ALL {fetch,upload}-pack: sideband v2 fetch response sideband: reverse its dependency on pkt-line pkt-line: introduce struct packet_writer pack-protocol.txt: accept error packets in any context Use packet_reader instead of packet_read_line --- 5f8b86db94e789bc07258f98cc5ba25d18273d83 diff --cc builtin/fetch-pack.c index f6a513495e,85dbc2af87..153a2bd282 --- a/builtin/fetch-pack.c +++ b/builtin/fetch-pack.c @@@ -218,13 -217,12 +218,14 @@@ int cmd_fetch_pack(int argc, const cha packet_reader_init(&reader, fd[0], NULL, 0, PACKET_READ_CHOMP_NEWLINE | - PACKET_READ_GENTLE_ON_EOF); + PACKET_READ_GENTLE_ON_EOF | + PACKET_READ_DIE_ON_ERR_PACKET); - switch (discover_version(&reader)) { + version = discover_version(&reader); + switch (version) { case protocol_v2: - die("support for protocol v2 not implemented yet"); + get_remote_refs(fd[1], &reader, &ref, 0, NULL, NULL); + break; case protocol_v1: case protocol_v0: get_remote_heads(&reader, &ref, 0, NULL, &shallow); diff --cc upload-pack.c index ee89381585,0c1feccaab..d098ef5982 --- a/upload-pack.c +++ b/upload-pack.c @@@ -664,10 -666,7 +668,9 @@@ static void send_unshallow(struct packe } } +static int check_ref(const char *refname_full, const struct object_id *oid, + int flag, void *cb_data); - - static void deepen(int depth, int deepen_relative, + static void deepen(struct packet_writer *writer, int depth, int deepen_relative, struct object_array *shallows, struct object_array *want_obj) { if (depth == INFINITE_DEPTH && !is_repository_shallow(the_repository)) { @@@ -721,10 -714,10 +725,11 @@@ static void deepen_by_rev_list(struct p } /* Returns 1 if a shallow list is sent or 0 otherwise */ - static int send_shallow_list(int depth, int deepen_rev_list, + static int send_shallow_list(struct packet_writer *writer, + int depth, int deepen_rev_list, timestamp_t deepen_since, struct string_list *deepen_not, + int deepen_relative, struct object_array *shallows, struct object_array *want_obj) { @@@ -847,9 -840,10 +852,11 @@@ static void receive_needs(struct packet int has_non_tip = 0; timestamp_t deepen_since = 0; int deepen_rev_list = 0; + int deepen_relative = 0; + struct packet_writer writer; shallow_nr = 0; + packet_writer_init(&writer, 1); for (;;) { struct object *o; const char *features; @@@ -938,9 -931,8 +944,9 @@@ if (depth == 0 && !deepen_rev_list && shallows.nr == 0) return; - if (send_shallow_list(depth, deepen_rev_list, deepen_since, + if (send_shallow_list(&writer, depth, deepen_rev_list, deepen_since, - &deepen_not, &shallows, want_obj)) + &deepen_not, deepen_relative, &shallows, + want_obj)) packet_flush(1); object_array_clear(&shallows); } @@@ -1409,15 -1416,15 +1430,16 @@@ static void send_shallow_info(struct up !is_repository_shallow(the_repository)) return; - packet_write_fmt(1, "shallow-info\n"); + packet_writer_write(&data->writer, "shallow-info\n"); - if (!send_shallow_list(data->depth, data->deepen_rev_list, + if (!send_shallow_list(&data->writer, data->depth, + data->deepen_rev_list, data->deepen_since, &data->deepen_not, + data->deepen_relative, &data->shallows, want_obj) && is_repository_shallow(the_repository)) - deepen(INFINITE_DEPTH, data->deepen_relative, &data->shallows, - want_obj); + deepen(&data->writer, INFINITE_DEPTH, data->deepen_relative, + &data->shallows, want_obj); packet_delim(1); }