connect.c: teach get_remote_heads to parse "shallow" lines
authorNguyễn Thái Ngọc Duy <pclouds@gmail.com>
Thu, 5 Dec 2013 13:02:33 +0000 (20:02 +0700)
committerJunio C Hamano <gitster@pobox.com>
Wed, 11 Dec 2013 00:14:16 +0000 (16:14 -0800)
No callers pass a non-empty pointer as shallow_points at this
stage. As a result, all clients still refuse to talk to shallow
repository on the other end.

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/fetch-pack.c
builtin/send-pack.c
connect.c
remote-curl.c
remote.h
transport.c
index c8e858232a8e7a3536ef4d296efdc618e034c36e..c1d918fe1bb6772871308e6fabca91fe2f8393e0 100644 (file)
@@ -150,7 +150,7 @@ int cmd_fetch_pack(int argc, const char **argv, const char *prefix)
                                   args.verbose ? CONNECT_VERBOSE : 0);
        }
 
-       get_remote_heads(fd[0], NULL, 0, &ref, 0, NULL);
+       get_remote_heads(fd[0], NULL, 0, &ref, 0, NULL, NULL);
 
        ref = fetch_pack(&args, fd, conn, ref, dest,
                         sought, nr_sought, pack_lockfile_ptr);
index 961df04deaf9497074db9f5ad1790962cd67e402..62cc4d3681da1358772fa13e7e683b1a76c12be0 100644 (file)
@@ -232,7 +232,7 @@ int cmd_send_pack(int argc, const char **argv, const char *prefix)
                        args.verbose ? CONNECT_VERBOSE : 0);
        }
 
-       get_remote_heads(fd[0], NULL, 0, &remote_refs, REF_NORMAL, &extra_have);
+       get_remote_heads(fd[0], NULL, 0, &remote_refs, REF_NORMAL, &extra_have, NULL);
 
        transport_verify_remote_names(nr_refspecs, refspecs);
 
index 48eec414f7e25ffc704b8a394077a3b60c2a1b61..efadd3cbeb0c95f00c7ffd3d1d8d01eae0d9e483 100644 (file)
--- a/connect.c
+++ b/connect.c
@@ -116,7 +116,8 @@ static void annotate_refs_with_symref_info(struct ref *ref)
  */
 struct ref **get_remote_heads(int in, char *src_buf, size_t src_len,
                              struct ref **list, unsigned int flags,
-                             struct sha1_array *extra_have)
+                             struct sha1_array *extra_have,
+                             struct sha1_array *shallow_points)
 {
        struct ref **orig_list = list;
        int got_at_least_one_head = 0;
@@ -142,6 +143,15 @@ struct ref **get_remote_heads(int in, char *src_buf, size_t src_len,
                if (len > 4 && !prefixcmp(buffer, "ERR "))
                        die("remote error: %s", buffer + 4);
 
+               if (len == 48 && !prefixcmp(buffer, "shallow ")) {
+                       if (get_sha1_hex(buffer + 8, old_sha1))
+                               die("protocol error: expected shallow sha-1, got '%s'", buffer + 8);
+                       if (!shallow_points)
+                               die("repository on the other end cannot be shallow");
+                       sha1_array_append(shallow_points, old_sha1);
+                       continue;
+               }
+
                if (len < 42 || get_sha1_hex(buffer, old_sha1) || buffer[40] != ' ')
                        die("protocol error: expected sha/ref, got '%s'", buffer);
                name = buffer + 41;
index c9b891adbf134193f07681a631ae368671e04aa6..222210fd31c7067ab5b5cae63b6f781b15a22d96 100644 (file)
@@ -107,7 +107,7 @@ static struct ref *parse_git_refs(struct discovery *heads, int for_push)
 {
        struct ref *list = NULL;
        get_remote_heads(-1, heads->buf, heads->len, &list,
-                        for_push ? REF_NORMAL : 0, NULL);
+                        for_push ? REF_NORMAL : 0, NULL, NULL);
        return list;
 }
 
index 984519bc6212fe70808088e3c5f54ad498ae3ceb..5d217d5397d58796c427a90f3233d7047880a446 100644 (file)
--- a/remote.h
+++ b/remote.h
@@ -140,7 +140,8 @@ void free_refs(struct ref *ref);
 struct sha1_array;
 extern struct ref **get_remote_heads(int in, char *src_buf, size_t src_len,
                                     struct ref **list, unsigned int flags,
-                                    struct sha1_array *extra_have);
+                                    struct sha1_array *extra_have,
+                                    struct sha1_array *shallow);
 
 int resolve_remote_symref(struct ref *ref, struct ref *list);
 int ref_newer(const unsigned char *new_sha1, const unsigned char *old_sha1);
index 12e46ad661a074bc480f8c72481a01ff808aa74c..90453df9c6ffc08b39a49002e31468d4ff6f5b3d 100644 (file)
@@ -512,7 +512,7 @@ static struct ref *get_refs_via_connect(struct transport *transport, int for_pus
 
        connect_setup(transport, for_push, 0);
        get_remote_heads(data->fd[0], NULL, 0, &refs,
-                        for_push ? REF_NORMAL : 0, &data->extra_have);
+                        for_push ? REF_NORMAL : 0, &data->extra_have, NULL);
        data->got_remote_heads = 1;
 
        return refs;
@@ -542,7 +542,8 @@ static int fetch_refs_via_pack(struct transport *transport,
 
        if (!data->got_remote_heads) {
                connect_setup(transport, 0, 0);
-               get_remote_heads(data->fd[0], NULL, 0, &refs_tmp, 0, NULL);
+               get_remote_heads(data->fd[0], NULL, 0, &refs_tmp, 0,
+                                NULL, NULL);
                data->got_remote_heads = 1;
        }
 
@@ -806,7 +807,7 @@ static int git_transport_push(struct transport *transport, struct ref *remote_re
                struct ref *tmp_refs;
                connect_setup(transport, 1, 0);
 
-               get_remote_heads(data->fd[0], NULL, 0, &tmp_refs, REF_NORMAL, NULL);
+               get_remote_heads(data->fd[0], NULL, 0, &tmp_refs, REF_NORMAL, NULL, NULL);
                data->got_remote_heads = 1;
        }