git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Jeff King <peff@peff.net>
To: Jonathan Tan <jonathantanmy@google.com>
Cc: git@vger.kernel.org
Subject: Re: [PATCH 1/2] fetch-pack: call prepare_shallow_info only if v0
Date: Tue, 26 Mar 2019 01:00:12 -0400	[thread overview]
Message-ID: <20190326050011.GA1933@sigill.intra.peff.net> (raw)
In-Reply-To: <d2eb101709cc9b300e38151b14c97f96a2b14188.1553546216.git.jonathantanmy@google.com>

On Mon, Mar 25, 2019 at 01:43:22PM -0700, Jonathan Tan wrote:

> In fetch_pack(), be clearer that there is no shallow information before
> the fetch when v2 is used - memset the struct shallow_info to 0 instead
> of calling prepare_shallow_info().
> 
> This patch is in preparation for a future patch in which a v2 fetch
> might call prepare_shallow_info() after shallow info has been retrieved
> during the fetch, so I needed to ensure that prepare_shallow_info() is
> not called before the fetch.

Makes sense.

I wondered here:

> diff --git a/fetch-pack.c b/fetch-pack.c
> index e69993b2eb..a0eb268dfc 100644
> --- a/fetch-pack.c
> +++ b/fetch-pack.c
> @@ -1648,13 +1648,17 @@ struct ref *fetch_pack(struct fetch_pack_args *args,
>  		packet_flush(fd[1]);
>  		die(_("no matching remote head"));
>  	}
> -	prepare_shallow_info(&si, shallow);
> -	if (version == protocol_v2)
> +	if (version == protocol_v2) {
> +		if (shallow && shallow->nr)
> +			BUG("Protocol V2 does not provide shallows at this point in the fetch");
> +		memset(&si, 0, sizeof(si));
>  		ref_cpy = do_fetch_pack_v2(args, fd, ref, sought, nr_sought,
>  					   pack_lockfile);

...who actually might set "shallow". Specifically, I was curious whether
a v2 server could erroneously send us shallow lines, which would trigger
our BUG(), when in fact we should be complaining about the server.

But the answer is no, they have no opportunity. AFAICT, this would only
be set by a call to get_remote_heads(), which we do only for v0/v1
protocols. So there's no way to trigger the BUG. Good.

-Peff

  reply	other threads:[~2019-03-26  5:00 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-03-25 20:43 [PATCH 0/2] Last big GIT_TEST_PROTOCOL_VERSION=2 fix, hopefully Jonathan Tan
2019-03-25 20:43 ` [PATCH 1/2] fetch-pack: call prepare_shallow_info only if v0 Jonathan Tan
2019-03-26  5:00   ` Jeff King [this message]
2019-03-25 20:43 ` [PATCH 2/2] fetch-pack: respect --no-update-shallow in v2 Jonathan Tan
2019-03-26  5:20   ` Jeff King
2019-03-26 10:14     ` Duy Nguyen
2019-03-26 15:18       ` Jeff King
2019-03-26 15:39         ` Duy Nguyen
2019-03-26 17:37     ` Jonathan Tan
2019-03-26 18:18       ` Jeff King
2019-03-26 17:53 ` [PATCH v2 0/2] Last big GIT_TEST_PROTOCOL_VERSION=2 fix, hopefully Jonathan Tan
2019-03-26 17:53   ` [PATCH v2 1/2] fetch-pack: call prepare_shallow_info only if v0 Jonathan Tan
2019-03-26 17:53   ` [PATCH v2 2/2] fetch-pack: respect --no-update-shallow in v2 Jonathan Tan
2019-03-26 18:23     ` Jeff King
2019-03-26 18:20   ` [PATCH v2 0/2] Last big GIT_TEST_PROTOCOL_VERSION=2 fix, hopefully Jeff King
2019-03-26 19:31 ` [PATCH v3 " Jonathan Tan
2019-03-26 19:31   ` [PATCH v3 1/2] fetch-pack: call prepare_shallow_info only if v0 Jonathan Tan
2019-03-26 19:31   ` [PATCH v3 2/2] fetch-pack: respect --no-update-shallow in v2 Jonathan Tan

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190326050011.GA1933@sigill.intra.peff.net \
    --to=peff@peff.net \
    --cc=git@vger.kernel.org \
    --cc=jonathantanmy@google.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).