Re: [PATCH v3 06/28] connect.c: teach get_remote_heads to parse "shallow" lines
On Tue, Nov 26, 2013 at 5:42 AM, Junio C Hamano wrote: > Junio C Hamano writes: > >> Perhaps a preparatory patch needs to rename the structure type to >> object_name_list or something. And then we can make the variable >> names, not typenames, responsible for signalling what they mean, >> i.e. >> >> get_remote_heads(... >> struct list_of_objects *extra_have, >> struct list_of_objects *shallow_points); >> >> when we introduce the new parameter. > > Yuck, and these are not "list-of-objects", either. They are > "list-of-object-names". I was thinking of renaming it to sha1_array and what do you know, we do have 'struct sha1_array' with exact same (or better) functionality that extra_have_objects provides. Will replace extra_have_objects with current sha1_array. -- Duy -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH v3 06/28] connect.c: teach get_remote_heads to parse "shallow" lines
Junio C Hamano writes: > Perhaps a preparatory patch needs to rename the structure type to > object_name_list or something. And then we can make the variable > names, not typenames, responsible for signalling what they mean, > i.e. > > get_remote_heads(... > struct list_of_objects *extra_have, > struct list_of_objects *shallow_points); > > when we introduce the new parameter. Yuck, and these are not "list-of-objects", either. They are "list-of-object-names". -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH v3 06/28] connect.c: teach get_remote_heads to parse "shallow" lines
Nguyễn Thái Ngọc Duy writes: > 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 > --- > builtin/fetch-pack.c | 2 +- > builtin/send-pack.c | 2 +- > connect.c| 12 +++- > remote-curl.c| 2 +- > remote.h | 3 ++- > transport.c | 7 --- > 6 files changed, 20 insertions(+), 8 deletions(-) > > diff --git a/builtin/fetch-pack.c b/builtin/fetch-pack.c > index c8e8582..c1d918f 100644 > --- a/builtin/fetch-pack.c > +++ b/builtin/fetch-pack.c > @@ -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); > diff --git a/builtin/send-pack.c b/builtin/send-pack.c > index 51121f2..bfa9253 100644 > --- a/builtin/send-pack.c > +++ b/builtin/send-pack.c > @@ -233,7 +233,7 @@ int cmd_send_pack(int argc, const char **argv, const char > *prefix) > > memset(&extra_have, 0, sizeof(extra_have)); > > - 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); > > diff --git a/connect.c b/connect.c > index 06e88b0..d0602b0 100644 > --- a/connect.c > +++ b/connect.c > @@ -122,7 +122,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 extra_have_objects *extra_have) > + struct extra_have_objects *extra_have, > + struct extra_have_objects *shallow_points) The _shape_ of the information you would want to keep track of for the shallow cut-off points may exactly be the same as that is for extra-have endspoints, but it still feels wrong to throw these shallow cut-off points into a structure called "extra have". After all, these are objects the other end does not have, which is the direct opposite of extra-have. Perhaps a preparatory patch needs to rename the structure type to object_name_list or something. And then we can make the variable names, not typenames, responsible for signalling what they mean, i.e. get_remote_heads(... struct list_of_objects *extra_have, struct list_of_objects *shallow_points); when we introduce the new parameter. -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v3 06/28] 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 --- builtin/fetch-pack.c | 2 +- builtin/send-pack.c | 2 +- connect.c| 12 +++- remote-curl.c| 2 +- remote.h | 3 ++- transport.c | 7 --- 6 files changed, 20 insertions(+), 8 deletions(-) diff --git a/builtin/fetch-pack.c b/builtin/fetch-pack.c index c8e8582..c1d918f 100644 --- a/builtin/fetch-pack.c +++ b/builtin/fetch-pack.c @@ -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); diff --git a/builtin/send-pack.c b/builtin/send-pack.c index 51121f2..bfa9253 100644 --- a/builtin/send-pack.c +++ b/builtin/send-pack.c @@ -233,7 +233,7 @@ int cmd_send_pack(int argc, const char **argv, const char *prefix) memset(&extra_have, 0, sizeof(extra_have)); - 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); diff --git a/connect.c b/connect.c index 06e88b0..d0602b0 100644 --- a/connect.c +++ b/connect.c @@ -122,7 +122,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 extra_have_objects *extra_have) + struct extra_have_objects *extra_have, + struct extra_have_objects *shallow_points) { struct ref **orig_list = list; int got_at_least_one_head = 0; @@ -148,6 +149,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, got '%s'", buffer + 8); + if (!shallow_points) + die("repository on the other end cannot be shallow"); + add_extra_have(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; diff --git a/remote-curl.c b/remote-curl.c index c9b891a..10f 100644 --- a/remote-curl.c +++ b/remote-curl.c @@ -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; } diff --git a/remote.h b/remote.h index 131130a..773faa9 100644 --- a/remote.h +++ b/remote.h @@ -143,7 +143,8 @@ struct extra_have_objects { }; extern struct ref **get_remote_heads(int in, char *src_buf, size_t src_len, struct ref **list, unsigned int flags, -struct extra_have_objects *); +struct extra_have_objects *have, +struct extra_have_objects *shallow); int resolve_remote_symref(struct ref *ref, struct ref *list); int ref_newer(const unsigned char *new_sha1, const unsigned char *old_sha1); diff --git a/transport.c b/transport.c index 7202b77..9c51767 100644 --- a/transport.c +++ b/transport.c @@ -511,7 +511,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; @@ -541,7 +541,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, +