Re: [RFCv2 09/16] remote.h: add get_remote_capabilities, request_capabilities
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Jun 2, 2015, 21:24 UTC
- Message-ID
- <xmqqd21d248d.fsf@gitster.dls.corp.google.com>
- In-Reply-To
- <1433203338-27493-10-git-send-email-sbeller@google.com>
Stefan Beller <sbeller@google.com> writes:
Show 23 quoted lines
> Instead of calling get_remote_heads as a first command during the > protocol exchange, we need to have fine grained control over the > capability negotiation in version 2 of the protocol. > > Introduce get_remote_capabilities, which will just listen to > capabilities of the remote and request_capabilities which will > tell the selection of capabilities to the remote. > > Signed-off-by: Stefan Beller <sbeller@google.com> > --- > connect.c | 37 +++++++++++++++++++++++++++++++++++++ > remote.h | 3 +++ > 2 files changed, 40 insertions(+) > > diff --git a/connect.c b/connect.c > index a2c777e..4ebe1dc 100644 > --- a/connect.c > +++ b/connect.c > @@ -105,6 +105,43 @@ static void annotate_refs_with_symref_info(struct ref *ref) > string_list_clear(&symref, 0); > } > > +void get_remote_capabilities(int in, char *src_buf, size_t src_len)
We need to clarify that this is for v2 only in its name, no?
Show 15 quoted lines
> +{
> + string_list_clear(&server_capabilities, 1);
> + for (;;) {
> + int len;
> + char *line = packet_buffer;
> +
> + len = packet_read(in, &src_buf, &src_len,
> + packet_buffer, sizeof(packet_buffer),
> + PACKET_READ_GENTLE_ON_EOF |
> + PACKET_READ_CHOMP_NEWLINE);
> + if (len < 0)
> + die_initial_contact(0);
> +
> + if (!len)
> + break;OK, so we get sequence of capabilities, one per packet, until packet_flush(). I wonder if we want to hint that with:
if (!len) break; /* flush */
or something like that.
> + string_list_append(&server_capabilities, line); > + } > +}
> +int request_capabilities(int out, struct transport_options *options)
> +{
> + if (options->multi_ack == 2) packet_write(out, "multi_ack_detailed");Spell these just like you would do any other functions, i.e.
if (options->multi_ack == 2)
packet_write(out, "multi_ack_detailed");I think this step is sensible, and anticipate that a new method that corresponds to this will be introduced to the transport layer.