]> git.ipfire.org Git - thirdparty/git.git/commitdiff
Merge branch 'jt/fetch-v2-sideband'
authorJunio C Hamano <gitster@pobox.com>
Tue, 5 Feb 2019 22:26:11 +0000 (14:26 -0800)
committerJunio C Hamano <gitster@pobox.com>
Tue, 5 Feb 2019 22:26:11 +0000 (14:26 -0800)
"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

1  2 
Documentation/technical/protocol-v2.txt
builtin/fetch-pack.c
fetch-pack.c
remote-curl.c
sideband.c
t/README
t/lib-httpd/apache.conf
t/t5702-protocol-v2.sh
upload-pack.c

index f6a513495ea77e4350aa6ec5282c3ab2969ee027,85dbc2af87b9098ef3c37274a6fd3dd033f6cc5f..153a2bd282cac47ba72c101eaf0ca1b867d3f2cd
@@@ -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 fetch-pack.c
Simple merge
diff --cc remote-curl.c
Simple merge
diff --cc sideband.c
Simple merge
diff --cc t/README
Simple merge
Simple merge
Simple merge
diff --cc upload-pack.c
index ee893815854bf59f6bcc7dbb7dc169750af41c2e,0c1feccaabac10fcb26828e0265f5aa053952253..d098ef598289d16956309cb73d4518a92c1206af
@@@ -664,10 -666,7 +668,9 @@@ static void send_unshallow(struct packe
        }
  }
  
- static void deepen(int depth, int deepen_relative,
 +static int check_ref(const char *refname_full, const struct object_id *oid,
 +                   int flag, void *cb_data);
+ 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;
        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);
  }