From: Jonathan Tan <jonathantanmy@google.com>
To: bmwill@google.com
Cc: git@vger.kernel.org, jonathantanmy@google.com, gitster@pobox.com,
sbeller@google.com
Subject: Re: [PATCH v3 2/8] upload-pack: implement ref-in-want
Date: Mon, 25 Jun 2018 10:40:56 -0700 [thread overview]
Message-ID: <20180625174056.53053-1-jonathantanmy@google.com> (raw)
In-Reply-To: <20180620213235.10952-3-bmwill@google.com>
> + wanted-refs section
> + * This section is only included if the client has requested a
> + ref using a 'want-ref' line and if a packfile section is also
> + included in the response.
> +
> + * Always begins with the section header "wanted-refs"
Add a period at the end to be consistent with the others.
> + * The server will send a ref listing ("<oid> <refname>") for
> + each reference requested using 'want-ref' lines.
> +
> + * The server MUST NOT send any refs which were not requested
> + using 'want-ref' lines.
We might want tag following refs to be included here in the future, but
at that time, I think we can amend this to say that if include-tag-ref
is sent by the user, the server may send additional refs, otherwise the
server must not do so. So this is fine.
> +test_expect_success 'mix want and want-ref' '
> + cat >expected_refs <<-EOF &&
> + $(git rev-parse f) refs/heads/master
> + EOF
> + git rev-parse e f | sort >expected_commits &&
> +
> + test-pkt-line pack >in <<-EOF &&
> + command=fetch
> + 0001
> + no-progress
> + want-ref refs/heads/master
> + want $(git rev-parse e)
> + have $(git rev-parse a)
> + done
> + 0000
> + EOF
> +
> + git serve --stateless-rpc >out <in &&
> + check_output
> +'
Overall the tests look good, although I might be a bit biased since they
are based on what I wrote a while ago [1]. I was wondering about the
behavior when the client mixes "want" and "want-ref" (as will happen if
they fetch both a ref by name and an exact SHA-1), and this test indeed
shows the expected behavior.
[1] https://public-inbox.org/git/d0d42b3bb4cf755f122591e191354c53848f197d.1485381677.git.jonathantanmy@google.com/
> +test_expect_success 'want-ref with ref we already have commit for' '
> + cat >expected_refs <<-EOF &&
> + $(git rev-parse c) refs/heads/o/foo
> + EOF
> + >expected_commits &&
> +
> + test-pkt-line pack >in <<-EOF &&
> + command=fetch
> + 0001
> + no-progress
> + want-ref refs/heads/o/foo
> + have $(git rev-parse c)
> + done
> + 0000
> + EOF
> +
> + git serve --stateless-rpc >out <in &&
> + check_output
> +'
Likewise for this test - the ref is still reported, but the packfile
does not contain the requested object.
> struct upload_pack_data {
> struct object_array wants;
> + struct string_list wanted_refs;
Document here that this is a map from ref names to owned struct
object_id instances.
> +static int parse_want_ref(const char *line, struct string_list *wanted_refs)
> +{
> + const char *arg;
> + if (skip_prefix(line, "want-ref ", &arg)) {
> + struct object_id oid;
> + struct string_list_item *item;
> + struct object *o;
> +
> + if (read_ref(arg, &oid))
> + die("unknown ref %s", arg);
> +
> + item = string_list_append(wanted_refs, arg);
> + item->util = oiddup(&oid);
> +
> + o = parse_object_or_die(&oid, arg);
> + if (!(o->flags & WANTED)) {
> + o->flags |= WANTED;
> + add_object_array(o, NULL, &want_obj);
> + }
Makes sense - besides adding it to wanted_refs, this adds the object to
want_obj, just like how the other code paths for "want" adds it.
> +static void send_wanted_ref_info(struct upload_pack_data *data)
> +{
> + const struct string_list_item *item;
> +
> + if (!data->wanted_refs.nr)
> + return;
> +
> + packet_write_fmt(1, "wanted-refs\n");
> +
> + for_each_string_list_item(item, &data->wanted_refs) {
> + packet_write_fmt(1, "%s %s\n",
> + oid_to_hex(item->util),
> + item->string);
> + }
> +
> + packet_delim(1);
> +}
The documentation states that the "wanted-refs" section is only sent if
there is at least one "want-ref" from the client, and each "want-ref"
causes one entry to be added to data->wanted_refs, so this is correct.
Thanks - besides adding the period in the documentation, this patch
looks good to me.
next prev parent reply other threads:[~2018-06-25 17:41 UTC|newest]
Thread overview: 122+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-06-05 17:51 [PATCH 0/8] ref-in-want Brandon Williams
2018-06-05 17:51 ` [PATCH 1/8] test-pkt-line: add unpack-sideband subcommand Brandon Williams
2018-06-05 17:51 ` [PATCH 2/8] upload-pack: implement ref-in-want Brandon Williams
2018-06-05 19:11 ` Ramsay Jones
2018-06-05 20:32 ` Ævar Arnfjörð Bjarmason
2018-06-06 21:32 ` Brandon Williams
2018-06-06 22:42 ` Ævar Arnfjörð Bjarmason
2018-06-06 22:45 ` Brandon Williams
2018-06-05 17:51 ` [PATCH 3/8] upload-pack: test negotiation with changing repository Brandon Williams
2018-06-05 17:51 ` [PATCH 4/8] fetch: refactor the population of peer ref OIDs Brandon Williams
2018-06-05 17:51 ` [PATCH 5/8] fetch: refactor fetch_refs into two functions Brandon Williams
2018-06-05 17:51 ` [PATCH 6/8] fetch: refactor to make function args narrower Brandon Williams
2018-06-05 17:51 ` [PATCH 7/8] fetch-pack: put shallow info in output parameter Brandon Williams
2018-06-05 17:51 ` [PATCH 8/8] fetch-pack: implement ref-in-want Brandon Williams
2018-06-13 21:39 ` [PATCH v2 0/8] ref-in-want Brandon Williams
2018-06-13 21:39 ` [PATCH v2 1/8] test-pkt-line: add unpack-sideband subcommand Brandon Williams
2018-06-14 18:09 ` Stefan Beller
2018-06-14 19:21 ` Brandon Williams
2018-06-13 21:39 ` [PATCH v2 2/8] upload-pack: implement ref-in-want Brandon Williams
2018-06-14 18:40 ` Stefan Beller
2018-06-14 18:52 ` Brandon Williams
2018-06-15 21:08 ` Junio C Hamano
2018-06-15 21:14 ` Junio C Hamano
2018-06-19 18:50 ` Brandon Williams
2018-06-19 20:37 ` Junio C Hamano
2018-06-19 23:14 ` Brandon Williams
2018-06-21 16:38 ` Junio C Hamano
2018-06-13 21:39 ` [PATCH v2 3/8] upload-pack: test negotiation with changing repository Brandon Williams
2018-06-14 19:23 ` Stefan Beller
2018-06-13 21:39 ` [PATCH v2 4/8] fetch: refactor the population of peer ref OIDs Brandon Williams
2018-06-13 21:39 ` [PATCH v2 5/8] fetch: refactor fetch_refs into two functions Brandon Williams
2018-06-13 21:39 ` [PATCH v2 6/8] fetch: refactor to make function args narrower Brandon Williams
2018-06-14 19:32 ` Stefan Beller
2018-06-13 21:39 ` [PATCH v2 7/8] fetch-pack: put shallow info in output parameter Brandon Williams
2018-06-14 19:42 ` Stefan Beller
2018-06-14 23:59 ` Jonathan Tan
2018-06-19 17:41 ` Brandon Williams
2018-06-13 21:39 ` [PATCH v2 8/8] fetch-pack: implement ref-in-want Brandon Williams
2018-06-14 19:56 ` Stefan Beller
2018-06-14 21:18 ` Brandon Williams
2018-06-22 22:29 ` Jonathan Nieder
2018-06-15 21:20 ` [PATCH v2 0/8] ref-in-want Junio C Hamano
2018-06-18 18:05 ` Brandon Williams
2018-06-20 21:32 ` [PATCH v3 " Brandon Williams
2018-06-20 21:32 ` [PATCH v3 1/8] test-pkt-line: add unpack-sideband subcommand Brandon Williams
2018-06-22 21:12 ` Jonathan Nieder
2018-06-20 21:32 ` [PATCH v3 2/8] upload-pack: implement ref-in-want Brandon Williams
2018-06-25 17:40 ` Jonathan Tan [this message]
2018-06-25 18:09 ` Jonathan Tan
2018-06-25 18:20 ` Brandon Williams
2018-06-20 21:32 ` [PATCH v3 3/8] upload-pack: test negotiation with changing repository Brandon Williams
2018-06-20 21:32 ` [PATCH v3 4/8] fetch: refactor the population of peer ref OIDs Brandon Williams
2018-06-25 17:45 ` Jonathan Tan
2018-06-20 21:32 ` [PATCH v3 5/8] fetch: refactor fetch_refs into two functions Brandon Williams
2018-06-22 21:26 ` Jonathan Nieder
2018-06-22 21:42 ` Jonathan Nieder
2018-06-20 21:32 ` [PATCH v3 6/8] fetch: refactor to make function args narrower Brandon Williams
2018-06-20 21:32 ` [PATCH v3 7/8] fetch-pack: put shallow info in output parameter Brandon Williams
2018-06-25 18:03 ` Jonathan Tan
2018-06-25 18:18 ` Brandon Williams
2018-06-20 21:32 ` [PATCH v3 8/8] fetch-pack: implement ref-in-want Brandon Williams
2018-06-22 23:01 ` Jonathan Nieder
2018-06-25 18:08 ` Brandon Williams
2018-06-25 18:53 ` [PATCH v4 0/8] ref-in-want Brandon Williams
2018-06-25 18:53 ` [PATCH v4 1/8] test-pkt-line: add unpack-sideband subcommand Brandon Williams
2018-06-25 18:53 ` [PATCH v4 2/8] upload-pack: implement ref-in-want Brandon Williams
2018-06-25 18:53 ` [PATCH v4 3/8] upload-pack: test negotiation with changing repository Brandon Williams
2018-06-25 22:27 ` Jonathan Tan
2018-06-25 18:53 ` [PATCH v4 4/8] fetch: refactor the population of peer ref OIDs Brandon Williams
2018-06-25 18:53 ` [PATCH v4 5/8] fetch: refactor fetch_refs into two functions Brandon Williams
2018-06-25 18:53 ` [PATCH v4 6/8] fetch: refactor to make function args narrower Brandon Williams
2018-06-25 22:36 ` Jonathan Tan
2018-06-25 18:53 ` [PATCH v4 7/8] fetch-pack: put shallow info in output parameter Brandon Williams
2018-06-25 18:53 ` [PATCH v4 8/8] fetch-pack: implement ref-in-want Brandon Williams
2018-06-25 23:03 ` [PATCH v4 0/8] ref-in-want Jonathan Tan
2018-06-26 20:54 ` [PATCH v5 " Brandon Williams
2018-06-26 20:54 ` [PATCH v5 1/8] test-pkt-line: add unpack-sideband subcommand Brandon Williams
2018-06-26 20:54 ` [PATCH v5 2/8] upload-pack: implement ref-in-want Brandon Williams
2018-06-26 21:25 ` Junio C Hamano
2018-06-27 18:05 ` Brandon Williams
2018-06-27 18:53 ` Junio C Hamano
2018-06-27 20:46 ` Brandon Williams
2018-06-27 20:59 ` Stefan Beller
2018-06-27 18:06 ` Jonathan Tan
2018-06-26 20:54 ` [PATCH v5 3/8] upload-pack: test negotiation with changing repository Brandon Williams
2018-06-26 21:34 ` Junio C Hamano
2018-06-27 18:09 ` Brandon Williams
2018-06-27 17:58 ` Jonathan Tan
2018-06-26 20:54 ` [PATCH v5 4/8] fetch: refactor the population of peer ref OIDs Brandon Williams
2018-06-26 20:54 ` [PATCH v5 5/8] fetch: refactor fetch_refs into two functions Brandon Williams
2018-06-26 20:54 ` [PATCH v5 6/8] fetch: refactor to make function args narrower Brandon Williams
2018-06-26 21:40 ` Junio C Hamano
2018-06-26 20:54 ` [PATCH v5 7/8] fetch-pack: put shallow info in output parameter Brandon Williams
2018-06-26 21:42 ` Junio C Hamano
2018-06-27 18:15 ` Brandon Williams
2018-06-26 20:54 ` [PATCH v5 8/8] fetch-pack: implement ref-in-want Brandon Williams
2018-06-27 18:09 ` Jonathan Tan
2018-06-27 18:18 ` Brandon Williams
2018-06-27 22:30 ` [PATCH v6 0/8] ref-in-want Brandon Williams
2018-06-27 22:30 ` [PATCH v6 1/8] test-pkt-line: add unpack-sideband subcommand Brandon Williams
2018-06-27 22:30 ` [PATCH v6 2/8] upload-pack: implement ref-in-want Brandon Williams
2018-06-27 22:30 ` [PATCH v6 3/8] upload-pack: test negotiation with changing repository Brandon Williams
2018-06-27 22:30 ` [PATCH v6 4/8] fetch: refactor the population of peer ref OIDs Brandon Williams
2018-06-27 22:30 ` [PATCH v6 5/8] fetch: refactor fetch_refs into two functions Brandon Williams
2018-06-27 22:30 ` [PATCH v6 6/8] fetch: refactor to make function args narrower Brandon Williams
2018-06-27 22:30 ` [PATCH v6 7/8] fetch-pack: put shallow info in output parameter Brandon Williams
2018-06-27 22:30 ` [PATCH v6 8/8] fetch-pack: implement ref-in-want Brandon Williams
2018-07-22 9:20 ` Duy Nguyen
2018-07-23 17:53 ` Brandon Williams
2018-07-23 18:13 ` Duy Nguyen
2018-07-23 21:28 ` Jonathan Nieder
2018-07-23 17:56 ` [PATCH] fetch-pack: mark die strings for translation Brandon Williams
2018-07-23 18:14 ` Stefan Beller
2018-07-23 21:29 ` Jonathan Nieder
2018-07-23 22:57 ` Junio C Hamano
2018-07-23 22:59 ` Junio C Hamano
2018-07-23 23:00 ` Brandon Williams
2018-06-15 19:04 ` [PATCH 0/8] ref-in-want Jonathan Tan
2018-06-19 17:32 ` Brandon Williams
2018-06-19 19:23 ` Jonathan Tan
2018-06-19 23:16 ` Brandon Williams
2018-06-19 23:38 ` 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=20180625174056.53053-1-jonathantanmy@google.com \
--to=jonathantanmy@google.com \
--cc=bmwill@google.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=sbeller@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).