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
Lidong Yan <yldhome2d2@gmail.com>
Date
Jun 18, 2025, 02:44 UTC
Message-ID
<16C5347A-3EB4-4629-9C7A-575F60B86CA3@gmail.com>
In-Reply-To
<d72fb411-2e05-441e-aee4-d8a26d652fea@intel.com>
Jacob Keller <jacob.e.keller@intel.com> writes:
Show 9 quoted lines
> 
> 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. I suspect you're right that merge_name will never be
> NULL while merge_nr is non-zero.

Maybe we can initialize each branch->merge in read_config(). Then branch->merge will always as large as branch->merge_nr. Do you think this would be a good idea?

---
diff --git a/remote.c b/remote.c
index 4099183cac..835939c59e 100644
--- a/remote.c
+++ b/remote.c
@@ -596,6 +596,8 @@ static void alias_all_urls(struct remote_state *remote_state)
 
 static void read_config(struct repository *repo, int early)
 {
+       struct hashmap_iter iter;
+       struct branch *b;
        int flag;
 
        if (repo->remote_state->initialized)
@@ -614,6 +616,9 @@ static void read_config(struct repository *repo, int early)
        }
        repo_config(repo, handle_config, repo->remote_state);
        alias_all_urls(repo->remote_state);
+       hashmap_for_each_entry(&repo->remote_state->branches_hash, &item, b, ent) {
+               set_merge(repo->remote_state, b);
+       }
 }
 
 #ifndef WITH_BREAKING_CHANGES
---
Previous: Jacob KellerNext: Jacob Keller
Message 8 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.