From: Taylor Blau <ttaylorr@openai.com>
To: Ted Nyman <tnyman@openai.com>
Cc: git@vger.kernel.org, gitster@pobox.com, me@ttaylorr.com,
peff@peff.net, ps@pks.im, karthik.188@gmail.com,
sandals@crustytoothpaste.net, avarab@gmail.com
Subject: Re: [PATCH v4 3/3] fetch-pack: accept "pack" output for packfile URIs
Date: Fri, 24 Jul 2026 16:46:25 -0500 [thread overview]
Message-ID: <amPdMQH3QRLnDpl0@com-79390> (raw)
In-Reply-To: <d9063deb60354eb731e34c453cd6730e1098f905.1784874850.git.tnyman@openai.com>
On Fri, Jul 24, 2026 at 01:14:25AM -0700, Ted Nyman wrote:
> When index-pack finds an existing keep file it reports pack rather than
> keep. Accept either result from http-fetch, and only register a keep
> lockfile when this fetch created it.
>
> Read the pack/keep prefix and hash without consuming any following fsck
> output, validate the reported pack hash against the advertised hash, and
> exercise a packfile URI fetch with a pre-existing keep file.
>
> Signed-off-by: Ted Nyman <tnyman@openai.com>
> ---
> fetch-pack.c | 33 ++++++++++++++++++---------------
> t/t5702-protocol-v2.sh | 31 +++++++++++++++++++++++++++++++
> 2 files changed, 49 insertions(+), 15 deletions(-)
>
> diff --git a/fetch-pack.c b/fetch-pack.c
> index 29c41132ee..e9f24fbd63 100644
> --- a/fetch-pack.c
> +++ b/fetch-pack.c
> @@ -1887,9 +1887,10 @@ static struct ref *do_fetch_pack_v2(struct fetch_pack_args *args,
> }
>
> for (i = 0; i < packfile_uris.nr; i++) {
> + bool created_keep;
> int j;
> struct child_process cmd = CHILD_PROCESS_INIT;
> - char packname[GIT_MAX_HEXSZ + 1];
> + char packhash[GIT_MAX_HEXSZ + 1];
OK, so we keep track of whether or not we got "keep" as part of the
output.
While here, "packname" is renamed to "packhash", which I think is
reasonable, especially to indicate that the buffer is sized accordingly.
We happen to read the preceding "pack" or "keep" into that same buffer,
which I think is fine. If we wanted to be pedantic we could read that
into a separate buffer, but I don't think such separation is necessary.
> const char *uri = packfile_uris.items[i].string +
> the_hash_algo->hexsz + 1;
>
> @@ -1907,16 +1908,17 @@ static struct ref *do_fetch_pack_v2(struct fetch_pack_args *args,
> if (start_command(&cmd))
> die("fetch-pack: unable to spawn http-fetch");
>
> - if (read_in_full(cmd.out, packname, 5) < 0 ||
> - memcmp(packname, "keep\t", 5))
> - die("fetch-pack: expected keep then TAB at start of http-fetch output");
> + if (read_in_full(cmd.out, packhash, 5) != 5 ||
> + (memcmp(packhash, "keep\t", 5) &&
> + memcmp(packhash, "pack\t", 5)))
> + die("fetch-pack: expected pack or keep then TAB at start of http-fetch output");
> + created_keep = !memcmp(packhash, "keep\t", 5);
Makes sense.
>
> - if (read_in_full(cmd.out, packname,
> - the_hash_algo->hexsz + 1) < 0 ||
> - packname[the_hash_algo->hexsz] != '\n')
> - die("fetch-pack: expected hash then LF at end of http-fetch output");
> -
> - packname[the_hash_algo->hexsz] = '\0';
> + if (read_in_full(cmd.out, packhash,
> + the_hash_algo->hexsz + 1) != the_hash_algo->hexsz + 1 ||
> + packhash[the_hash_algo->hexsz] != '\n')
> + die("fetch-pack: expected hash then LF in http-fetch output");
> + packhash[the_hash_algo->hexsz] = '\0';
Likewise. The rest of this file and the test also look good.
Thanks,
Taylor
prev parent reply other threads:[~2026-07-24 21:46 UTC|newest]
Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-13 22:37 [PATCH 0/2] packfile URIs: support concurrent downloads Ted Nyman
2026-07-13 22:34 ` [PATCH 1/2] http: use unique tempfiles for packfile URI downloads Ted Nyman
2026-07-14 1:00 ` Junio C Hamano
2026-07-14 1:58 ` Ted Nyman
2026-07-14 4:07 ` Taylor Blau
2026-07-14 5:28 ` Jeff King
2026-07-14 18:10 ` Junio C Hamano
2026-07-14 18:31 ` Ted Nyman
2026-07-14 4:06 ` Taylor Blau
2026-07-14 5:44 ` Jeff King
2026-07-14 6:46 ` Jeff King
2026-07-13 22:34 ` [PATCH 2/2] fetch-pack: accept "pack" output for packfile URIs Ted Nyman
2026-07-14 7:12 ` Jeff King
2026-07-14 7:13 ` Jeff King
2026-07-14 18:38 ` Ted Nyman
2026-07-14 21:47 ` Jeff King
2026-07-14 4:13 ` [PATCH 0/2] packfile URIs: support concurrent downloads Taylor Blau
2026-07-20 22:33 ` [PATCH v2 " Ted Nyman
2026-07-20 22:33 ` [PATCH v2 1/2] http: avoid concurrent appends to partial packs Ted Nyman
2026-07-21 19:56 ` Junio C Hamano
2026-07-20 22:34 ` [PATCH v2 2/2] fetch-pack: accept "pack" output for packfile URIs Ted Nyman
2026-07-21 23:29 ` [PATCH v3 0/3] packfile URIs: support concurrent downloads Ted Nyman
2026-07-21 23:29 ` [PATCH v3 1/3] http-fetch: correct --index-pack-arg documentation Ted Nyman
2026-07-21 23:29 ` [PATCH v3 2/3] http: avoid concurrent appends to partial packs Ted Nyman
2026-07-21 23:29 ` [PATCH v3 3/3] fetch-pack: accept "pack" output for packfile URIs Ted Nyman
2026-07-24 4:43 ` [PATCH v3 0/3] packfile URIs: support concurrent downloads Junio C Hamano
2026-07-24 8:14 ` [PATCH v4 " Ted Nyman
2026-07-24 8:14 ` [PATCH v4 1/3] http-fetch: correct --index-pack-arg documentation Ted Nyman
2026-07-24 21:38 ` Taylor Blau
2026-07-24 8:14 ` [PATCH v4 2/3] http: avoid concurrent appends to partial packs Ted Nyman
2026-07-24 8:14 ` [PATCH v4 3/3] fetch-pack: accept "pack" output for packfile URIs Ted Nyman
2026-07-24 21:46 ` Taylor Blau [this message]
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=amPdMQH3QRLnDpl0@com-79390 \
--to=ttaylorr@openai.com \
--cc=avarab@gmail.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=karthik.188@gmail.com \
--cc=me@ttaylorr.com \
--cc=peff@peff.net \
--cc=ps@pks.im \
--cc=sandals@crustytoothpaste.net \
--cc=tnyman@openai.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