All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Ævar Arnfjörð Bjarmason" <avarab@gmail.com>
To: Jonathan Tan <jonathantanmy@google.com>
Cc: git@vger.kernel.org, bmwill@google.com, gitster@pobox.com
Subject: Re: [PATCH v4] fetch-pack: support negotiation tip whitelist
Date: Tue, 18 Jun 2019 15:36:31 +0200	[thread overview]
Message-ID: <87o92v817k.fsf@evledraar.gmail.com> (raw)
In-Reply-To: <20180702223944.224755-1-jonathantanmy@google.com>


On Tue, Jul 03 2018, Jonathan Tan wrote:

> During negotiation, fetch-pack eventually reports as "have" lines all
> commits reachable from all refs. Allow the user to restrict the commits
> sent in this way by providing a whitelist of tips; only the tips
> themselves and their ancestors will be sent.

I discovered a bug in this...

> @@ -230,7 +246,7 @@ static int find_common(struct fetch_negotiator *negotiator,
>  	if (args->stateless_rpc && multi_ack == 1)
>  		die(_("--stateless-rpc requires multi_ack_detailed"));
>
> -	for_each_ref(rev_list_insert_ref_oid, negotiator);
> +	mark_tips(negotiator, args->negotiation_tips);
>  	for_each_cached_alternate(negotiator, insert_one_alternate_object);
>
>  	fetching = 0;

Here we blindly add objects found in an alternate repo. I found and
debugged this with this:

    diff --git a/fetch-negotiator.h b/fetch-negotiator.h
    index 9e3967ce66..cbe71c9c8d 100644
    --- a/fetch-negotiator.h
    +++ b/fetch-negotiator.h
    @@ -33,2 +33,3 @@ struct fetch_negotiator {
            void (*add_tip)(struct fetch_negotiator *, struct commit *);
    +       int done_adding;

    diff --git a/fetch-pack.c b/fetch-pack.c
    index 3f24d0c8a6..6b43b4f8f1 100644
    --- a/fetch-pack.c
    +++ b/fetch-pack.c
    @@ -238,2 +238,3 @@ static void mark_tips(struct fetch_negotiator *negotiator,
                                        &negotiation_tips->oid[i]);
    +       negotiator->done_adding = 1;
            return;
    diff --git a/negotiator/default.c b/negotiator/default.c
    index 4b78f6bf36..4e45f05f25 100644
    --- a/negotiator/default.c
    +++ b/negotiator/default.c
    @@ -137,2 +137,4 @@ static void add_tip(struct fetch_negotiator *n, struct commit *c)
     {
    +       if (n->done_adding)
    +               return;
            n->known_common = NULL;
    @@ -166,2 +168,3 @@ void default_negotiator_init(struct fetch_negotiator *negotiator)
            negotiator->add_tip = add_tip;
    +       negotiator->done_adding = 0;
            negotiator->next = next;

Perhaps something like that with an assert() is a good idea for the
negotiation backend code in general? It seems rather fragile to depend
on there being no other codepath that calls add_tip() again after some
other code (--negotiation-tip=*) that expects it not to be called again.

  parent reply	other threads:[~2019-06-18 13:36 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-06-25 19:37 [PATCH] fetch-pack: support negotiation tip whitelist Jonathan Tan
2018-06-26 17:53 ` Jonathan Nieder
2018-06-26 18:59 ` Junio C Hamano
2018-06-27 18:28 ` [PATCH v2] " Jonathan Tan
2018-06-28 15:56   ` Brandon Williams
2018-06-28 16:12     ` Jonathan Tan
2018-06-28 16:16       ` Brandon Williams
2018-06-28 22:15 ` [PATCH v3] " Jonathan Tan
2018-06-28 22:20   ` Brandon Williams
2018-06-29 16:28   ` Junio C Hamano
2018-07-02 22:39 ` [PATCH v4] " Jonathan Tan
2018-07-22  9:09   ` Duy Nguyen
2019-06-18 13:36   ` Ævar Arnfjörð Bjarmason [this message]
2019-06-18 17:30     ` 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

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

  git send-email \
    --in-reply-to=87o92v817k.fsf@evledraar.gmail.com \
    --to=avarab@gmail.com \
    --cc=bmwill@google.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --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.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.