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

Re: [PATCH v4] fetch: advertise fetched refs when backfilling tags

From
Karthik Nayak <karthik.188@gmail.com>
Date
Oct 23, 2026, 22:01 UTC
Message-ID
<CAOLa=ZSnhGwBevejqv1Nzw92q6tt6zMDM528qFb7xqY1-6mxrg@mail.gmail.com>
In-Reply-To
<attMR_XBdfkO3SHx@pks.im>
Patrick Steinhardt <ps@pks.im> writes:
Show 40 quoted lines
> On Fri, Oct 23, 2026 at 03:58:11AM -0700, Karthik Nayak wrote:
>> Patrick Steinhardt <ps@pks.im> writes:
>> > on thu, oct 22, 2026 at 11:00:16pm +0200, karthik nayak wrote:
>> >> diff --git a/builtin/fetch.c b/builtin/fetch.c
>> >> index b2decc6cfd..9867e8c2ef 100644
>> >> --- a/builtin/fetch.c
>> >> +++ b/builtin/fetch.c
>> >> @@ -1697,9 +1699,30 @@ static int backfill_tags(struct display_state *display_state,
>> >>  	transport_set_option(transport, TRANS_OPT_FOLLOWTAGS, NULL);
>> >>  	transport_set_option(transport, TRANS_OPT_DEPTH, "0");
>> >>  	transport_set_option(transport, TRANS_OPT_DEEPEN_RELATIVE, NULL);
>> >> +
>> >> +	/*
>> >> +	 * References fetched before the tag backfill aren't yet committed
>> >> +	 * to disk, so negotiation cannot discover them. Advertise them to
>> >> +	 * the server, so that it does not re-send objects we already have.
>> >> +	 */
>> >> +	if (fetched_tips && fetched_tips->nr && transport->smart_options) {
>> >> +		struct oid_array **include_tips =
>> >> +			&transport->smart_options->negotiation_include_tips;
>> >> +		if (!*include_tips)
>> >> +			*include_tips = to_free = xcalloc(1, sizeof(**include_tips));
>> >> +		for (size_t i = 0; i < fetched_tips->nr; i++)
>> >> +			oid_array_append(*include_tips, &fetched_tips->oid[i]);
>> >> +	}
>> >
>> > Curious. Why don't we have `struct oid_array` as a local variable and
>> > then simply `transport->smart_options->negotiation_include_tips =
>> > &extra_tips`?
>> >
>>
>> Because `transport->smart_options->negotiation_include_tips` may already
>> be set when this function is called, so we only free it when we are the
>> exclusive setters of the field.
>
> Ah, okay. But if it was set already, what does it contain? And is it
> okay that we essentially leak the fetched tips to our callers now if it
> was set?
>
> Patrick

So it is set when the user uses the '--negotiation-include' option and provides their own tips.

When I wrote this code, I didn't include the free'ing that you see here. But it triggered the leak sanitizer for 't5509-fetch-push-namespaces'. I assumed it was due to my code and added this logic, without digging too much into why my path specifically triggered it.

So, the transport does free the `negotiation_include_tips`, but only for transports which supports smart_options. Meaning, we should only add the tips for transports with smart options. As the other route doesn't use it and as such doesn't free the array.

Thanks for the pushback, I'll fix it up in the next version.
Previous: Patrick SteinhardtNext: Karthik Nayak
Message 20 of 36 in “fetch: commit references fetched before backfilling tags”
  1. fetch: commit references fetched before backfilling tagsKarthik Nayak, Oct 8, 2026
  2. Patrick SteinhardtOct 9, 2026
  3. Justin ToblerOct 9, 2026
  4. Karthik NayakOct 9, 2026
  5. Karthik NayakOct 9, 2026
  6. fetch: commit references fetched before backfilling tagsKarthik Nayak, Oct 12, 2026
  7. Junio C HamanoOct 12, 2026
  8. Karthik NayakOct 15, 2026
  9. fetch: commit references fetched before backfilling tagsKarthik Nayak, Oct 15, 2026
  10. Justin ToblerOct 20, 2026
  11. Patrick SteinhardtOct 21, 2026
  12. Karthik NayakOct 21, 2026
  13. Justin ToblerOct 21, 2026
  14. Karthik NayakOct 22, 2026
  15. Karthik NayakOct 21, 2026
  16. fetch: advertise fetched refs when backfilling tagsKarthik Nayak, Oct 22, 2026
  17. Patrick SteinhardtOct 23, 2026
  18. Karthik NayakOct 23, 2026
  19. Patrick SteinhardtOct 23, 2026
  20. Karthik NayakOct 23, 2026
  21. Karthik NayakOct 23, 2026
  22. 0/3 fetch: advertise fetched refs when backfilling tagsKarthik Nayak, Oct 28, 2026
  23. 1/3 transport: add `transport_options_release()`Karthik Nayak, Oct 28, 2026
  24. Patrick SteinhardtOct 28, 2026
  25. Karthik NayakOct 28, 2026
  26. Patrick SteinhardtOct 29, 2026
  27. Karthik NayakOct 29, 2026
  28. 2/3 fetch: advertise fetched refs when backfilling tagsKarthik Nayak, Oct 28, 2026
  29. 3/3 t5510: cover upstream info update on fetch failureKarthik Nayak, Oct 28, 2026
  30. Patrick SteinhardtOct 28, 2026
  31. Karthik NayakOct 28, 2026
  32. 0/3 fetch: advertise fetched refs when backfilling tagsKarthik Nayak, Oct 29, 2026
  33. 1/3 t5510: cover upstream info update on fetch failureKarthik Nayak, Oct 29, 2026
  34. 2/3 transport: add `transport_options_release()`Karthik Nayak, Oct 29, 2026
  35. 3/3 fetch: advertise fetched refs when backfilling tagsKarthik Nayak, Oct 29, 2026
  36. Patrick SteinhardtOct 29, 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.