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

Re: [PATCH v2 1/6] remote: fix tear down of struct branch and struct remote

From
Junio C Hamano <gitster@pobox.com>
Date
Jun 18, 2025, 11:20 UTC
Message-ID
<xmqq1prhguu3.fsf@gitster.g>
In-Reply-To
<xmqqldppu98s.fsf@gitster.g>
Junio C Hamano <gitster@pobox.com> writes:
Show 14 quoted lines
> Jacob Keller <jacob.e.keller@intel.com> writes:
>
>> We initialize branch->merge with set_merge() which is called by
>> branch_get() and which is the only way for callers external to remote.c
>> of getting a branch structure.
>>
>> The issue is that merge_nr can be non-zero because if no caller has done
>> a branch_get() on the given branch, we still have merge_nr is non-zero
>> and merge is NULL.
>
> Meaning merge_nr and merge are both uninitialized and unlikely to be
> 0 and NULL?  What values do they have, and if they are left
> uninitialized, shouldn't we be initializing them to predictable
> values?
Ah, no, I was just being stupid.

We read configuration files and accumulate things in .merge_name[] while incrementing .merge_nr but until set_merge() is called, .merge is NULL. We need to clear .merge[] only when it is not NULL, of course. And for that, it may be more readable if we had two loops.

Thanks.
Previous: Junio C HamanoNext: Jacob Keller
Message 6 of 18 in “submodule: improve remote lookup logic”
  1. 0/6 submodule: improve remote lookup logicJacob Keller, Jun 17, 2025
  2. 1/6 remote: fix tear down of struct branch and struct remoteJacob Keller, Jun 17, 2025
  3. Junio C HamanoJun 17, 2025
  4. Jacob KellerJun 17, 2025
  5. Junio C HamanoJun 18, 2025
  6. Junio C HamanoJun 18, 2025
  7. Jacob KellerJun 18, 2025
  8. Lidong YanJun 18, 2025
  9. Jacob KellerJun 17, 2025
  10. 2/6 dir: move starts_with_dot(_dot)_slash to dir.hJacob Keller, Jun 17, 2025
  11. 3/6 remote: remove the_repository from some functionsJacob Keller, Jun 17, 2025
  12. Junio C HamanoJun 17, 2025
  13. Jacob KellerJun 17, 2025
  14. 4/6 submodule--helper: improve logic for fallback remote nameJacob Keller, Jun 17, 2025
  15. Junio C HamanoJun 17, 2025
  16. Jacob KellerJun 17, 2025
  17. 5/6 submodule: move get_default_remote_submodule()Jacob Keller, Jun 17, 2025
  18. 6/6 submodule: look up remotes by URL firstJacob Keller, Jun 17, 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.