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

Re: [PATCH v2 2/2] upload-pack: don't ACK non-commits repeatedly in protocol v2

From
Jeff King <peff@peff.net>
Date
Sep 8, 2025, 16:51 UTC
Message-ID
<20250908165125.GA1324063@coredump.intra.peff.net>
In-Reply-To
<20250905-b4-pks-upload-pack-repeated-non-commit-acks-v2-2-d2e67f3cb94c@pks.im>
On Fri, Sep 05, 2025 at 08:18:02AM +0200, Patrick Steinhardt wrote:
Show 28 quoted lines
>  	if (o->type == OBJ_COMMIT) {
>  		struct commit_list *parents;
>  		struct commit *commit = (struct commit *)o;
> -		if (o->flags & THEY_HAVE)
> -			we_knew_they_have = 1;
> -		else
> -			o->flags |= THEY_HAVE;
> +
>  		if (!data->oldest_have || (commit->date < data->oldest_have))
>  			data->oldest_have = commit->date;
>  		for (parents = commit->parents;
> @@ -497,11 +494,13 @@ static int do_got_oid(struct upload_pack_data *data, const struct object_id *oid
>  		     parents = parents->next)
>  			parents->item->object.flags |= THEY_HAVE;
>  	}
> -	if (!we_knew_they_have) {
> -		add_object_array(o, NULL, &data->have_obj);
> -		return 1;
> -	}
> -	return 0;
> +
> +	if (o->flags & THEY_HAVE)
> +		return 0;
> +	o->flags |= THEY_HAVE;
> +
> +	add_object_array(o, NULL, &data->have_obj);
> +	return 1;
>  }

Just looking at the old code and its "we_knew_they_have" variable, I wondered why we didn't need it here anymore. In the old code, we set our (o->flags) THEY_HAVE flag up front, and then do some more processing on the parents, and then decide on our return value. So we need to remember the state before we set our flag.

In the new code, we do all of the parent processing and then return immediately. So we can just do so by checking the flag without an extra variable.

And we know that is correct to check the flag after the parent processing because we should not be setting THEY_HAVE on o->flags as part of that. It would imply that a commit is its own parent.

So I think this looks fine, but I wanted to read through carefully (and out loud) to make sure there wasn't a subtle gotcha.

-Peff
Previous: Patrick SteinhardtNext: Junio C Hamano
Message 12 of 13 in “upload-pack: don't ACK non-commits repeatedly”
  1. 0/2 upload-pack: don't ACK non-commits repeatedlyPatrick Steinhardt, Sep 3, 2025
  2. 1/2 t5530: modernize testsPatrick Steinhardt, Sep 3, 2025
  3. Junio C HamanoSep 4, 2025
  4. 2/2 upload-pack: don't ACK non-commits repeatedly in protocol v2Patrick Steinhardt, Sep 3, 2025
  5. Junio C HamanoSep 4, 2025
  6. Patrick SteinhardtSep 4, 2025
  7. Junio C HamanoSep 4, 2025
  8. Patrick SteinhardtSep 5, 2025
  9. 0/2 upload-pack: don't ACK non-commits repeatedlyPatrick Steinhardt, Sep 5, 2025
  10. 1/2 t5530: modernize testsPatrick Steinhardt, Sep 5, 2025
  11. 2/2 upload-pack: don't ACK non-commits repeatedly in protocol v2Patrick Steinhardt, Sep 5, 2025
  12. Jeff KingSep 8, 2025
  13. Junio C HamanoSep 5, 2025

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.