From: Jonathan Tan <jonathantanmy@google.com>
To: Jonathan Nieder <jrnieder@gmail.com>
Cc: Git mailing list <git@vger.kernel.org>,
Junio C Hamano <gitster@pobox.com>,
Brandon Williams <bmwill@google.com>
Subject: Re: [PATCH 6/6] fetch-pack: introduce negotiator API
Date: Tue, 5 Jun 2018 19:17:15 -0700 [thread overview]
Message-ID: <CAGf8dgKWPy6ACsNPas=z1dT6qirAEHkkk8wCo91cFaxPVkgrhQ@mail.gmail.com> (raw)
In-Reply-To: <20180606003745.GI9266@aiede.svl.corp.google.com>
On Tue, Jun 5, 2018 at 5:37 PM, Jonathan Nieder <jrnieder@gmail.com> wrote:
>> This patch is written to be more easily reviewed: static functions are
>> moved verbatim from fetch-pack.c to negotiator/default.c, and it can be
>> seen that the lines replaced by negotiator->X() calls are present in the
>> X() functions respectively.
>
> nit: s/more//
OK.
>> +#include "fetch-negotiator.h"
>
> To avoid various standards weirdness, the first #include in all files
> should be git-compat-util.h, cache.h, or builtin.h. I tend to just
> use git-compat-util.h.
OK.
>> +#include "cache.h"
>
> What does this need from cache.h?
If I remember correctly, I needed something, but I might not. I'll
remove it if so.
>> +#include "commit.h"
>
> optional: could use a forward-declaration "struct commit;" since we
> only use pointers instead of the complete type. Do we document when
> to prefer forward-declaration and when to #include complete type
> definitions somewhere?
I'll use the forward declaration then.
> [...]
>> +struct fetch_negotiator {
>
> Neat. Can this file include an overview of the calling sequence / how
> I use this API? E.g.
>
> /*
> * Standard calling sequence:
> * 1. Obtain a struct fetch_negotiator * using [...]
> * 2. For each [etc]
> * 3. Free resources associated with the negotiator by calling
> * release(this). This frees the pointer; it cannot be
> * reused.
> */
>
> That would be a good complement to the reference documentation in the
> struct definition.
OK.
>> @@ -1061,19 +944,17 @@ static struct ref *do_fetch_pack(struct fetch_pack_args *args,
>> if (!server_supports("deepen-relative") && args->deepen_relative)
>> die(_("Server does not support --deepen"));
>>
>> - if (marked)
>> - for_each_ref(clear_marks, NULL);
>> - marked = 1;
>> - if (everything_local(&data, args, &ref, sought, nr_sought)) {
>> + if (everything_local(&negotiator, args, &ref, sought, nr_sought)) {
>> packet_flush(fd[1]);
>> goto all_done;
>> }
>> - if (find_common(&data, args, fd, &oid, ref) < 0)
>> + if (find_common(&negotiator, args, fd, &oid, ref) < 0)
>> if (!args->keep_pack)
>> /* When cloning, it is not unusual to have
>> * no common commit.
>> */
>> warning(_("no common commits"));
>> + negotiator.release(&negotiator);
>
> Should this go after the all_done so that it doesn't get bypassed in
> the everything_local case?
Good point - will do.
>> @@ -1434,6 +1316,7 @@ static struct ref *do_fetch_pack_v2(struct fetch_pack_args *args,
>> continue;
>> }
>> }
>> + negotiator.release(&negotiator);
>>
>> oidset_clear(&common);
>
> nit: could put the negotiator.release(&negotiator) after the blank
> line, in the same paragraph as the other free calls like
> oidset_clear(&common).
OK.
>> +++ b/negotiator/default.c
>> @@ -0,0 +1,173 @@
>> +#include "default.h"
>
> First #include should be "git-compat-util.h".
OK.
> [...]
>> +/*
>> + This function marks a rev and its ancestors as common.
>> + In some cases, it is desirable to mark only the ancestors (for example
>> + when only the server does not yet know that they are common).
>> +*/
>
> Not about this change: comments should have ' *' at the start of each
> line (could do in a preparatory patch or a followup).
I'll add a followup.
>> --- /dev/null
>> +++ b/negotiator/default.h
>> @@ -0,0 +1,8 @@
>> +#ifndef NEGOTIATOR_DEFAULT_H
>> +#define NEGOTIATOR_DEFAULT_H
>> +
>> +#include "fetch-negotiator.h"
>> +
>> +void default_negotiator_init(struct fetch_negotiator *negotiator);
>
> optional: same question about whether to use a forward declaration as in
> fetch-negotiator.h.
I'll use a forward declaration.
next prev parent reply other threads:[~2018-06-06 2:17 UTC|newest]
Thread overview: 47+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-06-04 17:29 [PATCH 0/6] Refactor fetch negotiation into its own API Jonathan Tan
2018-06-04 17:29 ` [PATCH 1/6] fetch-pack: clear marks before everything_local() Jonathan Tan
2018-06-05 23:08 ` Jonathan Nieder
2018-06-06 0:32 ` Jonathan Tan
2018-06-04 17:29 ` [PATCH 2/6] fetch-pack: truly stop negotiation upon ACK ready Jonathan Tan
2018-06-05 23:16 ` Jonathan Nieder
2018-06-05 23:18 ` Jonathan Nieder
2018-06-06 0:38 ` Jonathan Tan
2018-06-04 17:29 ` [PATCH 3/6] fetch-pack: in protocol v2, enqueue commons first Jonathan Tan
2018-06-05 23:30 ` Jonathan Nieder
2018-06-06 2:10 ` Jonathan Tan
2018-06-04 17:29 ` [PATCH 4/6] fetch-pack: make negotiation-related vars local Jonathan Tan
2018-06-05 23:35 ` Jonathan Nieder
2018-06-06 2:12 ` Jonathan Tan
2018-06-04 17:29 ` [PATCH 5/6] fetch-pack: move common check and marking together Jonathan Tan
2018-06-06 0:01 ` Jonathan Nieder
2018-06-06 2:12 ` Jonathan Tan
2018-06-04 17:29 ` [PATCH 6/6] fetch-pack: introduce negotiator API Jonathan Tan
2018-06-06 0:37 ` Jonathan Nieder
2018-06-06 2:17 ` Jonathan Tan [this message]
2018-06-06 20:47 ` [PATCH v2 0/8] Refactor fetch negotiation into its own API Jonathan Tan
2018-06-06 20:47 ` [PATCH v2 1/8] fetch-pack: split up everything_local() Jonathan Tan
2018-06-14 17:26 ` Brandon Williams
2018-06-06 20:47 ` [PATCH v2 2/8] fetch-pack: clear marks before re-marking Jonathan Tan
2018-06-06 20:47 ` [PATCH v2 3/8] fetch-pack: directly end negotiation if ACK ready Jonathan Tan
2018-06-14 17:29 ` Brandon Williams
2018-06-14 17:34 ` Brandon Williams
2018-06-06 20:47 ` [PATCH v2 4/8] fetch-pack: use ref adv. to prune "have" sent Jonathan Tan
2018-06-14 17:32 ` Brandon Williams
2018-06-14 19:52 ` Junio C Hamano
2018-06-06 20:47 ` [PATCH v2 5/8] fetch-pack: make negotiation-related vars local Jonathan Tan
2018-06-14 17:38 ` Brandon Williams
2018-06-14 19:36 ` Junio C Hamano
2018-06-06 20:47 ` [PATCH v2 6/8] fetch-pack: move common check and marking together Jonathan Tan
2018-06-06 20:47 ` [PATCH v2 7/8] fetch-pack: introduce negotiator API Jonathan Tan
2018-06-06 20:47 ` [PATCH v2 8/8] negotiator/default: use better style in comments Jonathan Tan
2018-06-14 17:39 ` Brandon Williams
2018-06-14 22:54 ` [PATCH v3 0/7] Refactor fetch negotiation into its own API Jonathan Tan
2018-06-14 22:54 ` [PATCH v3 1/7] fetch-pack: split up everything_local() Jonathan Tan
2018-06-14 22:54 ` [PATCH v3 2/7] fetch-pack: clear marks before re-marking Jonathan Tan
2018-06-14 22:54 ` [PATCH v3 3/7] fetch-pack: directly end negotiation if ACK ready Jonathan Tan
2018-06-15 16:04 ` Junio C Hamano
2018-06-14 22:54 ` [PATCH v3 4/7] fetch-pack: use ref adv. to prune "have" sent Jonathan Tan
2018-06-14 22:54 ` [PATCH v3 5/7] fetch-pack: make negotiation-related vars local Jonathan Tan
2018-06-14 22:54 ` [PATCH v3 6/7] fetch-pack: move common check and marking together Jonathan Tan
2018-06-14 22:54 ` [PATCH v3 7/7] fetch-pack: introduce negotiator API Jonathan Tan
2018-06-25 18:24 ` [PATCH v3 0/7] Refactor fetch negotiation into its own API Brandon Williams
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='CAGf8dgKWPy6ACsNPas=z1dT6qirAEHkkk8wCo91cFaxPVkgrhQ@mail.gmail.com' \
--to=jonathantanmy@google.com \
--cc=bmwill@google.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=jrnieder@gmail.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 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 NNTP newsgroup(s).