Jacob Keller <jacob.e.keller@xxxxxxxxx> 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. 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 ---