git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH v4 3/3] fetch-pack: accept "pack" output for packfile URIs

From
Taylor Blau <ttaylorr@openai.com>
Date
Jul 24, 2026, 21:46 UTC
Message-ID
<amPdMQH3QRLnDpl0@com-79390>
In-Reply-To
<d9063deb60354eb731e34c453cd6730e1098f905.1784874850.git.tnyman@openai.com>
On Fri, Jul 24, 2026 at 01:14:25AM -0700, Ted Nyman wrote:
Show 27 quoted lines
> 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.

Show 15 quoted lines
>  		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.
Show 12 quoted lines
>
> -		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

Previous: Ted NymanNext: Ted Nyman
Message 37 of 57 in “packfile URIs: support concurrent downloads”
  1. 0/2 packfile URIs: support concurrent downloadsTed Nyman, Jul 13, 2026
  2. 1/2 http: use unique tempfiles for packfile URI downloadsTed Nyman, Jul 13, 2026
  3. Junio C HamanoJul 14, 2026
  4. Ted NymanJul 14, 2026
  5. Taylor BlauJul 14, 2026
  6. Jeff KingJul 14, 2026
  7. Junio C HamanoJul 14, 2026
  8. Ted NymanJul 14, 2026
  9. Taylor BlauJul 14, 2026
  10. Jeff KingJul 14, 2026
  11. Jeff KingJul 14, 2026
  12. 2/2 fetch-pack: accept "pack" output for packfile URIsTed Nyman, Jul 13, 2026
  13. Jeff KingJul 14, 2026
  14. Jeff KingJul 14, 2026
  15. Ted NymanJul 14, 2026
  16. Jeff KingJul 14, 2026
  17. Taylor BlauJul 14, 2026
  18. 0/2 packfile URIs: support concurrent downloadsTed Nyman, Jul 20, 2026
  19. 1/2 http: avoid concurrent appends to partial packsTed Nyman, Jul 20, 2026
  20. Junio C HamanoJul 21, 2026
  21. 2/2 fetch-pack: accept "pack" output for packfile URIsTed Nyman, Jul 20, 2026
  22. 0/3 packfile URIs: support concurrent downloadsTed Nyman, Jul 21, 2026
  23. 1/3 http-fetch: correct --index-pack-arg documentationTed Nyman, Jul 21, 2026
  24. 2/3 http: avoid concurrent appends to partial packsTed Nyman, Jul 21, 2026
  25. 3/3 fetch-pack: accept "pack" output for packfile URIsTed Nyman, Jul 21, 2026
  26. Junio C HamanoJul 24, 2026
  27. Jeff KingJul 25, 2026
  28. Jeff KingJul 25, 2026
  29. Jeff KingJul 25, 2026
  30. Jeff KingJul 25, 2026
  31. Junio C HamanoJul 25, 2026
  32. 0/3 packfile URIs: support concurrent downloadsTed Nyman, Jul 24, 2026
  33. 1/3 http-fetch: correct --index-pack-arg documentationTed Nyman, Jul 24, 2026
  34. Taylor BlauJul 24, 2026
  35. 2/3 http: avoid concurrent appends to partial packsTed Nyman, Jul 24, 2026
  36. 3/3 fetch-pack: accept "pack" output for packfile URIsTed Nyman, Jul 24, 2026
  37. Taylor BlauJul 24, 2026
  38. 0/3 packfile URIs: support concurrent downloadsTed Nyman, Jul 26, 2026
  39. 1/3 http-fetch: correct --index-pack-arg documentationTed Nyman, Jul 26, 2026
  40. 2/3 http: avoid concurrent appends to partial packsTed Nyman, Jul 26, 2026
  41. Jeff KingJul 26, 2026
  42. Ted NymanJul 26, 2026
  43. Jeff KingJul 26, 2026
  44. 3/3 fetch-pack: accept "pack" output for packfile URIsTed Nyman, Jul 26, 2026
  45. Jeff KingJul 26, 2026
  46. 0/6 packfile URIs: support concurrent downloadsTed Nyman, Jul 27, 2026
  47. 1/6 http-fetch: correct --index-pack-arg documentationTed Nyman, Jul 27, 2026
  48. 2/6 http: avoid closing index-pack input twiceTed Nyman, Jul 27, 2026
  49. Jeff KingAug 1, 2026
  50. 3/6 http: accept HTTP 416 for complete partial packsTed Nyman, Jul 27, 2026
  51. Jeff KingAug 1, 2026
  52. 4/6 http: avoid concurrent appends to partial packsTed Nyman, Jul 27, 2026
  53. 5/6 http: permit unlinking partial packs on WindowsTed Nyman, Jul 27, 2026
  54. 6/6 fetch-pack: accept "pack" output for packfile URIsTed Nyman, Jul 27, 2026
  55. Junio C HamanoJul 29, 2026
  56. Jeff KingAug 1, 2026
  57. Junio C HamanoAug 8, 2026

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.