From: Junio C Hamano Date: Fri, 10 Dec 2021 22:35:02 +0000 (-0800) Subject: Merge branch 'gc/remote-with-fewer-static-global-variables' X-Git-Tag: v2.35.0-rc0~123 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=6d1e149ac04717efff7e0748509036a87cbb95e1;p=thirdparty%2Fgit.git Merge branch 'gc/remote-with-fewer-static-global-variables' Code clean-up to eventually allow information on remotes defined for an arbitrary repository to be read. * gc/remote-with-fewer-static-global-variables: remote: die if branch is not found in repository remote: remove the_repository->remote_state from static methods remote: use remote_state parameter internally remote: move static variables into per-repository struct t5516: add test case for pushing remote refspecs --- 6d1e149ac04717efff7e0748509036a87cbb95e1 diff --cc remote.c index f958543d70,c97c626eaa..a6d8ec6c1a --- a/remote.c +++ b/remote.c @@@ -441,25 -498,26 +498,27 @@@ static void alias_all_urls(struct remot } } - static void read_config(void) + static void read_config(struct repository *repo) { - static int loaded; int flag; - if (loaded) + if (repo->remote_state->initialized) return; - loaded = 1; + repo->remote_state->initialized = 1; - current_branch = NULL; + repo->remote_state->current_branch = NULL; if (startup_info->have_repository) { - const char *head_ref = resolve_ref_unsafe("HEAD", 0, NULL, &flag); ++ int ignore_errno; + const char *head_ref = refs_resolve_ref_unsafe( - get_main_ref_store(repo), "HEAD", 0, NULL, &flag); ++ get_main_ref_store(repo), "HEAD", 0, NULL, &flag, &ignore_errno); if (head_ref && (flag & REF_ISSYMREF) && skip_prefix(head_ref, "refs/heads/", &head_ref)) { - current_branch = make_branch(head_ref, strlen(head_ref)); + repo->remote_state->current_branch = make_branch( + repo->remote_state, head_ref, strlen(head_ref)); } } - git_config(handle_config, NULL); - alias_all_urls(); + repo_config(repo, handle_config, repo->remote_state); + alias_all_urls(repo->remote_state); } static int valid_remote_nick(const char *name)