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

Re: [PATCH v4 6/6] fetch: delay user information post committing of transaction

From
Junio C Hamano <gitster@pobox.com>
Date
Jan 23, 2026, 17:57 UTC
Message-ID
<xmqqjyx8gqkg.fsf@gitster.g>
In-Reply-To
<CAOLa=ZSLPasvFrCgKzVOq7mDXiqX9SxoOf0MZdzBXOLn73okMQ@mail.gmail.com>
Karthik Nayak <karthik.188@gmail.com> writes:
Show 14 quoted lines
>>> +static void ref_update_display_info_free(struct ref_update_display_info *info)
>>> +{
>>> +	free((char *)info->summary);
>>> +	free((char *)info->success_detail);
>>> +	free((char *)info->fail_detail);
>>> +	free((char *)info->remote);
>>> +	free((char *)info->ref);
>>> +}
>>
>> This answers "no" to my previous question.  These are not borrowed,
>> but are owned by this structure.
>>
>
> Yup, cannot be borrowed, since those go out of scope much earlier.

And the reason why they are marked "const char *" which typically signals that they are borrowed is? After all, that is where these casts inside free() comes from.

There are two schools of thought. One (which I originally was in) marks resources we own with "const", if these members will not change once we initialize them and we want to avoid accidentally muck with the contents of these pieces of memory during the course of the program. Those of us in the school often have to cast away constness in their calls to free() like the above.

But I saw many of our developers squarely fall into the other camp, where they always use a non-const pointer to point at the resource the structure owns.

The latter school of thought opens us up to bugs caused by mistaken code that modifies these memory regions that those of us in the former school would use "const" to avoid, but it makes it easier to reason about memory ownership models by signalling if the enclosing structure owns or borrows the resources.

I'd say the latter school are majority of our developer base, and a lot of existing structures follow that rule. I was hinting that we may want to follow suit in this new structure.

Thanks.
Previous: Karthik NayakNext: Karthik Nayak
Message 10 of 13 in “refs: provide detailed error messages when using batched update”
  1. 0/6 refs: provide detailed error messages when using batched updateKarthik Nayak, Jan 22, 2026
  2. 1/6 refs: skip to next ref when current ref is rejectedKarthik Nayak, Jan 22, 2026
  3. 2/6 refs: add rejection detail to the callback functionKarthik Nayak, Jan 22, 2026
  4. 3/6 update-ref: utilize rejected error details if availableKarthik Nayak, Jan 22, 2026
  5. 4/6 fetch: utilize rejected ref error detailsKarthik Nayak, Jan 22, 2026
  6. 5/6 receive-pack: utilize rejected ref error detailsKarthik Nayak, Jan 22, 2026
  7. 6/6 fetch: delay user information post committing of transactionKarthik Nayak, Jan 22, 2026
  8. Junio C HamanoJan 22, 2026
  9. Karthik NayakJan 23, 2026
  10. Junio C HamanoJan 23, 2026
  11. Karthik NayakJan 25, 2026
  12. Phillip WoodJan 23, 2026
  13. Karthik NayakJan 23, 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.