connect.c: teach get_remote_heads to parse "shallow" lines
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>
Nguyễn Thái Ngọc Duy committed
Dec 5, 2013 at 20:02 UTC
b06dcd7d6829c86afda6b311cadf009ee4b4dd59
6 files changed
+20
-8
builtin/fetch-pack.c
+1
-1
@@ -150,7 +150,7 @@ int cmd_fetch_pack(int argc, const char **argv, const char *prefix)
150
args.verbose ? CONNECT_VERBOSE : 0);
151
}
152
153
- get_remote_heads(fd[0], NULL, 0, &ref, 0, NULL);
153
+ get_remote_heads(fd[0], NULL, 0, &ref, 0, NULL, NULL);
154
155
ref = fetch_pack(&args, fd, conn, ref, dest,
156
sought, nr_sought, pack_lockfile_ptr);
builtin/send-pack.c
+1
-1
@@ -232,7 +232,7 @@ int cmd_send_pack(int argc, const char **argv, const char *prefix)
232
args.verbose ? CONNECT_VERBOSE : 0);
233
}
234
235
- get_remote_heads(fd[0], NULL, 0, &remote_refs, REF_NORMAL, &extra_have);
235
+ get_remote_heads(fd[0], NULL, 0, &remote_refs, REF_NORMAL, &extra_have, NULL);
236
237
transport_verify_remote_names(nr_refspecs, refspecs);
238
connect.c
+11
-1
@@ -116,7 +116,8 @@ static void annotate_refs_with_symref_info(struct ref *ref)
116
*/
117
struct ref **get_remote_heads(int in, char *src_buf, size_t src_len,
118
struct ref **list, unsigned int flags,
119
- struct sha1_array *extra_have)
119
+ struct sha1_array *extra_have,
120
+ struct sha1_array *shallow_points)
121
{
122
struct ref **orig_list = list;
123
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,
143
if (len > 4 && !prefixcmp(buffer, "ERR "))
144
die("remote error: %s", buffer + 4);
145
146
+ if (len == 48 && !prefixcmp(buffer, "shallow ")) {
147
+ if (get_sha1_hex(buffer + 8, old_sha1))
148
+ die("protocol error: expected shallow sha-1, got '%s'", buffer + 8);
149
+ if (!shallow_points)
150
+ die("repository on the other end cannot be shallow");
151
+ sha1_array_append(shallow_points, old_sha1);
152
+ continue;
153
+ }
154
+
155
if (len < 42 || get_sha1_hex(buffer, old_sha1) || buffer[40] != ' ')
156
die("protocol error: expected sha/ref, got '%s'", buffer);
157
name = buffer + 41;
remote-curl.c
+1
-1
@@ -107,7 +107,7 @@ static struct ref *parse_git_refs(struct discovery *heads, int for_push)
107
{
108
struct ref *list = NULL;
109
get_remote_heads(-1, heads->buf, heads->len, &list,
110
- for_push ? REF_NORMAL : 0, NULL);
110
+ for_push ? REF_NORMAL : 0, NULL, NULL);
111
return list;
112
}
113
remote.h
+2
-1
@@ -140,7 +140,8 @@ void free_refs(struct ref *ref);
140
struct sha1_array;
141
extern struct ref **get_remote_heads(int in, char *src_buf, size_t src_len,
142
struct ref **list, unsigned int flags,
143
- struct sha1_array *extra_have);
143
+ struct sha1_array *extra_have,
144
+ struct sha1_array *shallow);
145
146
int resolve_remote_symref(struct ref *ref, struct ref *list);
147
int ref_newer(const unsigned char *new_sha1, const unsigned char *old_sha1);
transport.c
+4
-3
@@ -512,7 +512,7 @@ static struct ref *get_refs_via_connect(struct transport *transport, int for_pus
512
513
connect_setup(transport, for_push, 0);
514
get_remote_heads(data->fd[0], NULL, 0, &refs,
515
- for_push ? REF_NORMAL : 0, &data->extra_have);
515
+ for_push ? REF_NORMAL : 0, &data->extra_have, NULL);
516
data->got_remote_heads = 1;
517
518
return refs;
@@ -542,7 +542,8 @@ static int fetch_refs_via_pack(struct transport *transport,
542
543
if (!data->got_remote_heads) {
544
connect_setup(transport, 0, 0);
545
- get_remote_heads(data->fd[0], NULL, 0, &refs_tmp, 0, NULL);
545
+ get_remote_heads(data->fd[0], NULL, 0, &refs_tmp, 0,
546
+ NULL, NULL);
547
data->got_remote_heads = 1;
548
}
549
@@ -806,7 +807,7 @@ static int git_transport_push(struct transport *transport, struct ref *remote_re
807
struct ref *tmp_refs;
808
connect_setup(transport, 1, 0);
809
809
- get_remote_heads(data->fd[0], NULL, 0, &tmp_refs, REF_NORMAL, NULL);
810
+ get_remote_heads(data->fd[0], NULL, 0, &tmp_refs, REF_NORMAL, NULL, NULL);
811
data->got_remote_heads = 1;
812
}
813