Re: [PATCH v2] upload-pack: allow stateless client EOF just prior to haves
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Oct 30, 2020, 23:45 UTC
- Message-ID
- <xmqqzh4346sb.fsf@gitster.c.googlers.com>
- In-Reply-To
- <20201030223504.45978-1-dan@mutual.io>
> t/t5705-upload-pack-stateless-shallow-eof.sh | 24 ++++++++++++++++++++ > upload-pack.c | 13 ++++++++++- > 2 files changed, 36 insertions(+), 1 deletion(-) > create mode 100755 t/t5705-upload-pack-stateless-shallow-eof.sh
Yuck. Adding a new test file, only to hold a single test?
I'd rather see it folded in an existing test, if it makes sense.
Of course if we do not have any test for upload-pack, that's a different story, but I suspect we already do test the command in existing scripts.
Show 24 quoted lines
> diff --git a/upload-pack.c b/upload-pack.c
> index 3b858eb457..5dc8e1f844 100644
> --- a/upload-pack.c
> +++ b/upload-pack.c
> @@ -1344,7 +1344,18 @@ void upload_pack(struct upload_pack_options *options)
> PACKET_READ_DIE_ON_ERR_PACKET);
>
> receive_needs(&data, &reader);
> - if (data.want_obj.nr) {
> +
> + /*
> + * An EOF at this exact point in negotiation should be
> + * acceptable from stateless clients as they will consume the
> + * shallow list before doing subsequent rpc with haves/etc.
> + */
> + if (data.stateless_rpc)
> + reader.options |= PACKET_READ_GENTLE_ON_EOF;
> +
> + if (data.want_obj.nr &&
> + packet_reader_peek(&reader) != PACKET_READ_EOF) {
> + reader.options &= ~PACKET_READ_GENTLE_ON_EOF;
> get_common_commits(&data, &reader);
> create_pack_file(&data, NULL);
> }Thanks.